您的足迹:首页 > 我的代码 >aardio/用post方式登录dedecms织梦管理后台

aardio/用post方式登录dedecms织梦管理后台

二种。均是登录后。取cookies的。

第一种:

import console;
import inet.whttp;
whttp = inet.whttp();
var tmptab,cookietab = {},{}
whttp.afterSend = function(statusCode,contentLength){
    whttp.readHeader()
    for m in string.gmatch(whttp.responseHeaders ,"Set-Cookie\:\s*(.*?);") { 
        tmptab = string.split(m,"=",2)
        if(#tmptab == 2){
            cookietab[tmptab[1]] = tmptab[2]
        }
    }
    whttp.cookies = ""
    for(k,v in cookietab){
        whttp.cookies += k+"="+v+"; "
    }
} 
whttp.get("http://aa.com/dede/login.php")
html = whttp.post( "http://aa.com/dede/login.php", {
    userid="testqq";
    pwd="testqq";
    dopost="login";
    adminstyle="newdedecms";
} );
if( string.indexOf( html , "成功登录" ) ){ console.log( "成功登录" ); }
console.log(whttp.cookies)
var whttp2 = inet.whttp()
whttp2.beforeSend = function(){
     whttp2.writeHeader("Cookie:"+whttp.cookies)
}
html = whttp2.get("http://aa.com/dede/index.php",'');
console.log( html );
console.pause();


第二种:

import console;

getMyCookies = function( cks ){
    result ="";
    try{
        a1 = (string.match(cks,"PHPSESSID=([^;]+);"));
        a2 = (string.match(cks,"DedeUserID=([^;]+);"));
        a3 = (string.match(cks,"DedeUserID__ckMd5=([^;]+);"));
        a4 = (string.match(cks,"DedeLoginTime=([^;]+);"));
        a5 = (string.match(cks,"DedeLoginTime__ckMd5=([^;]+)"));
        cks = "PHPSESSID="++a1++"; DedeUserID="++a2++"; DedeUserID__ckMd5="++a3++"; DedeLoginTime="++a4++"; DedeLoginTime__ckMd5="++a5++"; ";
        result = cks;   
    }
    return "";
}
import inet.whttp;
whttp = inet.whttp();
cookies = null;
whttp.afterSend = function(statusCode,contentLength){
    if( !cookies ) cookies = whttp.readHeader();
    else {
        cookies = cookies ++ '\r\n' ++ whttp.readHeader();
    }
}

html = whttp.get( "http://aa.com/dede/login.php");

html = whttp.post( "http://aa.com/dede/login.php", {
    userid="testqq";
    pwd="testqq";
    dopost="login";
    adminstyle="newdedecms";
} );
if( string.indexOf( html , "成功登录" ) ){ console.log( "成功登录" ); }

console.varDump( cookies )
cookies = getMyCookies( cookies );
console.log( cookies );

//whttp.beforeSend = function(){    whttp.writeHeader("Cookie: " ++ cookies );  }
html = whttp.post("http://aa.com/dede/index.php",'');
console.log( html );  

console.pause();



本博客所有文章如无特别注明均为原创。作者:恶猫复制或转载请以超链接形式注明转自 恶猫的博客
原文地址《aardio/用post方式登录dedecms织梦管理后台

相关推荐

分享本文至:

发表评论

路人甲 表情
看不清楚?点图切换 Ctrl+Enter快速提交

网友评论(0)

恶猫的博客 -记录自己日常,代码,美图,电影,音乐,新闻,只是个人博客而已

浙ICP备15011757号-4 网站地图 联系我