Customize your own Trojan file-5

admin 2022年8月29日04:53:02评论30 views字数 1601阅读5分20秒阅读模式


介绍


免责声明:


本系列文章提供的程序(方法)可能带有攻击性,仅供安全研究与教学之用,如果将其信息做其他用途,由读者承担全部法律及连带责任,本实验室不承担任何法律及连带责任。


本篇文章是定制自己的木马系列的第五篇文章,也是最后一篇,在本篇中我们会将C语言编写的木马文件运行在任何系统中。


需要用到的东西:


  • Visual Studio

  • Kali Linux

  • Windows靶机


基础


一般程序生成恶意软件都需要对特定系统进行编码,而使用 Cosmopolitan 项目则可以将文件本身转换为多系统平台的可执行程序。


使用该项目可以将C语言编写的木马文件同时在MacOS、Windows、FreeBSD、OpenBSD 和 NetBSD 上运行。


原理就是将Windows PE文件编码为UNIX的shell脚本:


MZqFpD='BIOS BOOT SECTOR'exec 7<> $(command -v $0)printf '177ELF...LINKER-ENCODED-FREEBSD-HEADER' >&7exec "$0" "$@"exec qemu-x86_64 "$0" "$@"exit 1REAL MODE...ELF SEGMENTS...OPENBSD NOTE...NETBSD NOTE...MACHO HEADERS...CODE AND DATA...ZIP DIRECTORY...


下载


在Linux系统或Kali Linux系统上运行命令下载库:


wget https://justine.lol/cosmopolitan/cosmopolitan-amalgamation-2.0.1.zip


解压该文件:


unzip cosmopolitan-amalgamation-2.0.1.zip


Customize your own Trojan file-5


编写可执行文件


简单编写一个可在多系统运行的代码文件:


test.c

main() {        char * OS = "None";        if(isdirectory("C:\"))                OS = "windows";        else if(isdirectory("/root"))                OS = "linux";

printf("the system is %sn", OS);}


该代码通过系统目录来判断系统。


gcc编译


在 cosmopolitan 当前目录输入命令进行编译:


gcc -g -Os -static -nostdlib -nostdinc -fno-pie -no-pie -mno-red-zone   -fno-omit-frame-pointer -pg -mnop-mcount   -o test.com.dbg test.c -fuse-ld=bfd -Wl,-T,ape.lds   -include cosmopolitan.h crt.o ape.o cosmopolitan.aobjcopy -S -O binary test.com.dbg test.com


Customize your own Trojan file-5


test.com为多系统执行文件,test.com.dbg只能在本地系统执行。


该执行文件在Windows系统上运行效果:


Customize your own Trojan file-5


该执行文件在 Linux 上运行效果:


Customize your own Trojan file-5


项目首页 | APE介绍


小结


长篇系列完结,众所周知,因为不可抗力的因素,木马文件的其他危害较大的功能是不允许写的,所以差不多该系列就到这里完结吧~


如果你也喜欢二进制和编写恶意木马,可以看看外网的书籍:


  • The Art of Computer Virus Research and Defense

  • The Giant Black Book of Computer Viruses

  • Designing BSD Rootkits: An Introduction to Kernel Hacking

  • Rootkits and Bootkits

  • The Antivirus Hackers' Handbook



Ghost Wolf Lab
Customize your own Trojan file-5


本系列文章由Ghost Wolf Lab 编写,严禁未经过授权的转载、复制粘贴等行为供商业牟利。

Customize your own Trojan file-5










原文始发于微信公众号(Ghost Wolf):Customize your own Trojan file-5

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2022年8月29日04:53:02
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   Customize your own Trojan file-5https://cn-sec.com/archives/1260109.html

发表评论

匿名网友 填写信息