├── .gitignore ├── logo.png ├── Makefile ├── go.mod ├── .github └── workflows │ └── build.yml ├── rules ├── Bew_Backdoor_Miner.yara ├── Helios_Malware.yara ├── Erebus_Ransomware.yara ├── Rocke_Group_Toolkit.yara ├── KORKERDS_Miner.yara ├── Dacls_Trojan.yara ├── GreedyAntd_Malware.yara ├── LemonDuck_Miner.yara ├── Vit_Virus.yara ├── RedGhost_Malware.yara ├── DirtyCow_Exploit.yara ├── Chicken_DOS.yara ├── XMRig_Miner_Strings.yara ├── Winnti_Malware.yara ├── ACBackdoor_Malware.yara ├── GodLua_Malware.yara ├── Mirai_Okiru_Malware.yara ├── Torte_ELF_Malware.yara ├── Mirai_Satori_Malware.yara ├── EvilGnome_Malware.yara ├── Sofacy_Backdoor.yara ├── Mandibule_Toolkit.yara ├── Op_Windigo_Malware.yara ├── ELF_Malware_Strings.yara ├── Moose_Malware.yara ├── Rebirth_Vulcan_Malware.yara ├── TinyShell_Backdoor.yara ├── WatchDog_Malware.yara ├── Misc_Malware.yara ├── LuckyJoe_Ransomware.yara ├── KillDisk_Ransomware.yara ├── Kraken_Ransomware.yara ├── Derubsi_Malware.yara └── Equation_Group_Toolkit_2.yara ├── docs └── recommended-iam-policy.md ├── go.sum ├── README.md ├── LICENSE └── main.go /.gitignore: -------------------------------------------------------------------------------- 1 | patrolaroid 2 | patrolaroid.tar.gz 3 | -------------------------------------------------------------------------------- /logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpetrich/patrolaroid/HEAD/logo.png -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: all 2 | all: patrolaroid 3 | 4 | .PHONY: clean 5 | clean: 6 | rm -rf patrolaroid patrolaroid.tar.gz 7 | 8 | patrolaroid: main.go 9 | CGO_ENABLED=1 go build -ldflags "-linkmode external -extldflags -static" -tags netgo -o patrolaroid main.go 10 | 11 | patrolaroid.tar.gz: patrolaroid 12 | tar cfz patrolaroid.tar.gz patrolaroid rules/ 13 | 14 | .PHONY: package 15 | package: patrolaroid.tar.gz 16 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/rpetrich/patrolaroid 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/aws/aws-sdk-go-v2/config v1.3.0 7 | github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.1.1 8 | github.com/aws/aws-sdk-go-v2/service/ec2 v1.7.1 9 | github.com/aws/aws-sdk-go-v2/service/s3 v1.9.0 10 | github.com/capsule8/go-yara v1.1.10-0.20210523225711-dafe562e8c6e 11 | github.com/hillu/go-yara/v4 v4.0.6 // indirect 12 | ) 13 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | on: [push] 3 | jobs: 4 | Build: 5 | runs-on: ubuntu-20.04 6 | steps: 7 | - name: Check out repository code 8 | uses: actions/checkout@v2 9 | - name: Build package 10 | run: make package 11 | - name: Archive patrolaroid binary 12 | uses: actions/upload-artifact@v2 13 | with: 14 | name: patrolaroid 15 | path: patrolaroid.tar.gz 16 | -------------------------------------------------------------------------------- /rules/Bew_Backdoor_Miner.yara: -------------------------------------------------------------------------------- 1 | /* Source: https://github.com/Yara-Rules/rules/blob/3872244500f584491cde7c633f12f1f043a61c13/malware/MALW_LinuxBew.yar */ 2 | 3 | rule LinuxBew: MALW 4 | { 5 | meta: 6 | description = "Linux.Bew Backdoor" 7 | author = "Joan Soriano / @w0lfvan" 8 | date = "2017-07-10" 9 | version = "1.0" 10 | MD5 = "27d857e12b9be5d43f935b8cc86eaabf" 11 | SHA256 = "80c4d1a1ef433ac44c4fe72e6ca42395261fbca36eff243b07438263a1b1cf06" 12 | strings: 13 | $a = "src/secp256k1.c" 14 | $b = "hfir.u230.org" 15 | $c = "tempfile-x11session" 16 | condition: 17 | all of them 18 | } 19 | -------------------------------------------------------------------------------- /rules/Helios_Malware.yara: -------------------------------------------------------------------------------- 1 | /* Source: https://github.com/Yara-Rules/rules/blob/3872244500f584491cde7c633f12f1f043a61c13/malware/MALW_LinuxHelios.yar */ 2 | 3 | rule LinuxHelios: MALW 4 | { 5 | meta: 6 | description = "Linux.Helios" 7 | author = "Joan Soriano / @w0lfvan" 8 | date = "2017-10-19" 9 | version = "1.0" 10 | MD5 = "1a35193f3761662a9a1bd38b66327f49" 11 | SHA256 = "72c2e804f185bef777e854fe86cff3e86f00290f32ae8b3cb56deedf201f1719" 12 | strings: 13 | $a = "LIKE A GOD!!! IP:%s User:%s Pass:%s" 14 | $b = "smack" 15 | $c = "PEACE OUT IMMA DUP\n" 16 | condition: 17 | all of them 18 | } -------------------------------------------------------------------------------- /rules/Erebus_Ransomware.yara: -------------------------------------------------------------------------------- 1 | /* Source: https://github.com/Yara-Rules/rules/blob/3872244500f584491cde7c633f12f1f043a61c13/malware/RANSOM_Erebus.yar */ 2 | 3 | rule Erebus: ransom 4 | { 5 | meta: 6 | description = "Erebus Ransomware" 7 | author = "Joan Soriano / @joanbtl" 8 | date = "2017-06-23" 9 | version = "1.0" 10 | MD5 = "27d857e12b9be5d43f935b8cc86eaabf" 11 | SHA256 = "0b7996bca486575be15e68dba7cbd802b1e5f90436ba23f802da66292c8a055f" 12 | ref1 = "http://blog.trendmicro.com/trendlabs-security-intelligence/erebus-resurfaces-as-linux-ransomware/" 13 | strings: 14 | $a = "/{5f58d6f0-bb9c-46e2-a4da-8ebc746f24a5}//log.log" 15 | $b = "EREBUS IS BEST." 16 | condition: 17 | all of them 18 | } 19 | -------------------------------------------------------------------------------- /rules/Rocke_Group_Toolkit.yara: -------------------------------------------------------------------------------- 1 | rule Rocke_Groupe_Toolkit 2 | { 3 | meta: 4 | Author = "Kelly Shortridge" 5 | Repo = "https://github.com/rpetrich/patrolaroid/tree/main/rules" 6 | description = "Strings related to the Rocke Group's toolkit" 7 | ref1 = "https://unit42.paloaltonetworks.com/malware-used-by-rocke-group-evolves-to-evade-detection-by-cloud-security-products/" 8 | 9 | strings: 10 | $string00 = "ps aux | grep -i '[a]liyun';" fullword nocase wide ascii 11 | $string01 = "https://pastebin.com/raw/*" fullword nocase wide ascii 12 | $string02 = "blog.sydwzl.cn" fullword nocase wide ascii 13 | $string03 = "echo /usr/local/lib/*.so >> /etc/ld.so.preload" fullword nocase wide ascii 14 | 15 | condition: 16 | any of them 17 | } 18 | 19 | -------------------------------------------------------------------------------- /docs/recommended-iam-policy.md: -------------------------------------------------------------------------------- 1 | # Recommended AWS IAM policy 2 | 3 | For individuals comfortable applying [custom IAM policies](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements.html) in AWS, we recommend using the below IAM policy instead of `AmazonEC2FullAccess` when creating the AWS role for Patrolaroid. 4 | 5 | ``` 6 | { 7 | "Version": "2012-10-17", 8 | "Statement": [ 9 | { 10 | "Sid": "Stmt1622650196578", 11 | "Action": [ 12 | "ec2:AttachVolume", 13 | "ec2:CreateSnapshot", 14 | "ec2:CreateVolume", 15 | "ec2:DeleteVolume", 16 | "ec2:DescribeSnapshots", 17 | "ec2:DescribeVolumes", 18 | "ec2:DetachVolume", 19 | "s3:ListBuckets", 20 | "s3:ListObjects", 21 | "s3:GetObject" 22 | ], 23 | "Effect": "Allow", 24 | "Resource": "*" 25 | } 26 | ] 27 | } 28 | ``` 29 | 30 | Thanks to @Jonty for the suggestion. 31 | -------------------------------------------------------------------------------- /rules/KORKERDS_Miner.yara: -------------------------------------------------------------------------------- 1 | rule KORKERDS_Miner 2 | { 3 | meta: 4 | Author = "Kelly Shortridge" 5 | Repo = "https://github.com/rpetrich/patrolaroid/tree/main/rules" 6 | description = "Strings related to the KORKERDS Miner" 7 | ref1 = "https://www.trendmicro.com/vinfo/us/security/news/cybercrime-and-digital-threats/cryptocurrency-mining-malware-targets-linux-systems-uses-rootkit-for-stealth" 8 | ref2 = "https://documents.trendmicro.com/images/TEx/articles/linux-miner-rootkit-2.png" 9 | 10 | strings: 11 | $string00 = "/bin/.httpdns" fullword nocase wide ascii 12 | $string01 = "https://pastebin.com/raw/*" fullword nocase wide ascii 13 | $string02 = "/tmp/kworkerds" fullword nocase wide ascii 14 | $string03 = "minerxmr.ru" fullword nocase wide ascii 15 | $string04 = "downloadrunxm" fullword nocase wide ascii 16 | $string05 = "echo /usr/local/lib/libdns.so > /etc/ld.so.preload" fullword nocase wide ascii 17 | 18 | condition: 19 | any of them 20 | } -------------------------------------------------------------------------------- /rules/Dacls_Trojan.yara: -------------------------------------------------------------------------------- 1 | /* Source: https://github.com/deadbits/yara-rules/blob/master/rules/Dacls_Linux.yara */ 2 | 3 | rule Dacls_Trojan_Linux 4 | { 5 | meta: 6 | Author = "Adam M. Swanda" 7 | Repo = "https://github.com/deadbits/yara-rules" 8 | 9 | strings: 10 | $cls00 = "c_2910.cls" ascii fullword 11 | $cls01 = "k_3872.cls" ascii fullword 12 | 13 | $str00 = "{\"result\":\"ok\"}" ascii fullword 14 | $str01 = "SCAN %s %d.%d.%d.%d %d" ascii fullword 15 | $str02 = "/var/run/init.pid" ascii fullword 16 | $str03 = "/flash/bin/mountd" ascii fullword 17 | $str04 = "Name:" ascii fullword 18 | $str05 = "Uid:" ascii fullword 19 | $str06 = "Gid:" ascii fullword 20 | $str08 = "PPid:" ascii fullword 21 | $str09 = "session_id" ascii fullword 22 | 23 | condition: 24 | uint32be(0x0) == 0x7f454c46 25 | and 26 | ( 27 | (all of ($cls*)) 28 | 29 | or 30 | 31 | (all of ($str*)) 32 | 33 | ) 34 | } 35 | -------------------------------------------------------------------------------- /rules/GreedyAntd_Malware.yara: -------------------------------------------------------------------------------- 1 | /* Source: https://github.com/intezer/yara-rules/blob/master/GreedyAntd.yar */ 2 | 3 | rule GreedyAntd 4 | { 5 | meta: 6 | copyright = "Intezer Labs" 7 | author = "Intezer Labs" 8 | reference = "https://www.intezer.com" 9 | strings: 10 | $a0 = { 66 ?? ?? ?? ?? 49 ?? ?? ?? 66 ?? ?? ?? ?? ?? ?? ?? 66 ?? ?? ?? ?? ?? ?? ?? ?? 66 ?? ?? ?? ?? 4C ?? ?? 66 ?? ?? ?? ?? 66 ?? ?? ?? ?? 48 ?? ?? ?? 0F 1F [0-128] F3 ?? ?? ?? ?? ?? F3 ?? ?? ?? ?? ?? 66 ?? ?? ?? ?? 66} 11 | $a2 = { E8 ?? ?? ?? ?? BE ?? ?? ?? ?? 48 ?? ?? E8 ?? ?? ?? ?? 48 ?? ?? E8 ?? ?? ?? ?? 85 ?? 74 [0-128] 31 ?? BA ?? ?? ?? ?? 48 ?? ?? E8 ?? ?? ?? ?? 48 ?? ?? 4C ?? ?? E8 ?? ?? ?? ?? BE ?? ?? ?? ?? 48 ?? ?? E8 ?? ?? ?? ?? 48 ?? ?? E8 ?? ?? ?? ?? 85 ?? 74 } 12 | $a3 = { 8B ?? ?? ?? BE ?? ?? ?? ?? 48 ?? ?? B9 ?? ?? ?? ?? 66 ?? ?? ?? 83 ?? ?? B8 ?? ?? ?? ?? 45 ?? ?? ?? ?? ?? 0F 45 ?? 48 ?? ?? ?? 45 ?? ?? ?? ?? ?? 48 ?? ?? ?? ?? B8 ?? ?? ?? ?? F3 ?? 48 ?? ?? ?? 89 ?? ?? 48 ?? ?? ?? 48 ?? ?? ?? ?? 44 ?? ?? ?? 48 } 13 | condition: 14 | any of them 15 | } -------------------------------------------------------------------------------- /rules/LemonDuck_Miner.yara: -------------------------------------------------------------------------------- 1 | rule LemonDuck_Miner 2 | { 3 | meta: 4 | Author = "Kelly Shortridge" 5 | Repo = "https://github.com/rpetrich/patrolaroid/tree/main/rules" 6 | description = "Strings related to the Lemon Duck Miner" 7 | ref1 = "https://github.com/sophoslabs/IoCs/blob/master/Trojan-LDMiner.csv" 8 | 9 | strings: 10 | $string00 = "./xr -o lplp.ackng.com:444 --opencl --donate-level=1 --nicehash -B --http-host=0.0.0.0 --http-port=65529" fullword nocase wide ascii 11 | $string01 = "blackball" fullword nocase wide ascii 12 | $string02 = "nvd.zip" fullword nocase wide ascii 13 | $string03 = "xr.zip" fullword nocase wide ascii 14 | $string04 = "http://t.amynx.com/*" fullword nocase wide ascii 15 | $string05 = "http://d.ackng.com/*" fullword nocase wide ascii 16 | 17 | condition: 18 | any of them 19 | } 20 | 21 | rule LemonDuck_Lateral 22 | { 23 | meta: 24 | Author = "Kelly Shortridge" 25 | Repo = "https://github.com/rpetrich/patrolaroid/rules" 26 | description = "Strings related to the Lemon Duck Miner's lateral movement behavior" 27 | ref1 = "https://news.sophos.com/en-us/2020/08/25/lemon_duck-cryptominer-targets-cloud-apps-linux/" 28 | 29 | strings: 30 | $string00 = "-f root/.ssh/known_hosts" 31 | $string01 = "export src=sshcopy" 32 | 33 | condition: 34 | all of them 35 | } -------------------------------------------------------------------------------- /rules/Vit_Virus.yara: -------------------------------------------------------------------------------- 1 | /* Source: https://github.com/reversinglabs/reversinglabs-yara-rules/blob/5147a2978cc942b1d514a368e9a8245e95483872/yara/virus/Linux.Virus.Vit.yara */ 2 | 3 | import "elf" 4 | 5 | rule Linux_Virus_Vit : tc_detection malicious 6 | { 7 | meta: 8 | 9 | author = "ReversingLabs" 10 | 11 | source = "ReversingLabs" 12 | status = "RELEASED" 13 | sharing = "TLP:WHITE" 14 | category = "MALWARE" 15 | malware = "VIT" 16 | description = "Yara rule that detects Vit virus." 17 | 18 | tc_detection_type = "Virus" 19 | tc_detection_name = "Vit" 20 | tc_detection_factor = 5 21 | 22 | strings: 23 | 24 | $vit_entry_point = { 25 | 55 89 E5 81 EC 40 31 00 00 57 56 50 53 51 52 C7 85 D8 CE FF FF 00 00 00 00 C7 85 D4 26 | CE FF FF 00 00 00 00 C7 85 FC CF FF FF CA 08 00 00 C7 85 F8 CF FF FF B8 06 00 00 C7 27 | 85 F4 CF FF FF AD 08 00 00 C7 85 F0 CF FF FF 50 06 00 00 6A 00 6A 00 8B 45 08 50 E8 28 | 18 FA FF FF 89 C6 83 C4 0C 85 F6 0F 8C E6 01 00 00 6A 00 68 ?? ?? ?? ?? 56 E8 2E FA 29 | FF FF 83 C4 0C 85 C0 0F 8C C4 01 00 00 8B 85 FC CF FF FF 50 8D 85 00 D0 FF FF 50 56 30 | E8 2A FA FF FF 89 C2 8B 85 FC CF FF FF 83 C4 0C 39 C2 0F 85 9D 01 00 00 56 E8 E1 F9 31 | FF FF BE FF FF FF FF 6A 00 6A 00 E9 32 | } 33 | 34 | $vit_str = "vi324.tmp" 35 | 36 | condition: 37 | uint32(0) == 0x464C457F and $vit_entry_point at elf.entry_point and $vit_str 38 | } -------------------------------------------------------------------------------- /rules/RedGhost_Malware.yara: -------------------------------------------------------------------------------- 1 | /* Source: https://github.com/deadbits/yara-rules/blob/master/rules/RedGhost_Linux.yara */ 2 | 3 | rule RedGhost_Linux: postexploitation linuxmalware 4 | { 5 | meta: 6 | 7 | Author = "Adam M. Swanda" 8 | Website = "https://www.deadbits.org" 9 | Repo = "https://github.com/deadbits/yara-rules" 10 | Date = "2019-08-07" 11 | Reference = "https://github.com/d4rk007/RedGhost/" 12 | 13 | strings: 14 | $name = "[ R E D G H O S T - P O S T E X P L O I T - T O O L]" ascii 15 | 16 | $feature0 = "Payloads" ascii 17 | $feature1 = "SudoInject" ascii 18 | $feature2 = "lsInject" ascii 19 | $feature3 = "Crontab" ascii 20 | $feature4 = "GetRoot" ascii 21 | $feature5 = "Clearlogs" ascii 22 | $feature6 = "MassinfoGrab" ascii 23 | $feature7 = "CheckVM" ascii 24 | $feature8 = "MemoryExec" ascii 25 | $feature9 = "BanIP" ascii 26 | 27 | $func0 = "checkVM(){" ascii 28 | $func1 = "memoryexec(){" ascii 29 | $func2 = "banip(){" ascii 30 | $func3 = "linprivesc(){" ascii 31 | $func4 = "dirty(){" ascii 32 | $func5 = "Ocr(){" ascii 33 | $func6 = "clearlog(){" ascii 34 | $func7 = "conmethods(){" ascii 35 | $func8 = "add2sys(){" ascii 36 | 37 | //$header = "#!/bin/bash" ascii 38 | 39 | condition: 40 | // #!/bin/bash header 41 | (uint16be(0x0) == 0x2321 and 42 | for any i in (0..64) : ( 43 | uint16be(i) == 0x2f62 and uint8(i+2) == 0x68 44 | )) 45 | and 46 | ($name or 5 of them) 47 | } 48 | -------------------------------------------------------------------------------- /rules/DirtyCow_Exploit.yara: -------------------------------------------------------------------------------- 1 | /* Source: https://github.com/Yara-Rules/rules/blob/3872244500f584491cde7c633f12f1f043a61c13/cve_rules/CVE-2016-5195.yar */ 2 | 3 | /* 4 | This Yara ruleset is under the GNU-GPLv2 license (http://www.gnu.org/licenses/gpl-2.0.html) and open to any user or organization, as long as you use it under this license. 5 | */ 6 | 7 | rule Linux_DirtyCow_Exploit { 8 | meta: 9 | description = "Detects Linux Dirty Cow Exploit - CVE-2012-0056 and CVE-2016-5195" 10 | author = "Florian Roth" 11 | reference = "http://dirtycow.ninja/" 12 | date = "2016-10-21" 13 | strings: 14 | $a1 = { 48 89 D6 41 B9 00 00 00 00 41 89 C0 B9 02 00 00 00 BA 01 00 00 00 BF 00 00 00 00 } 15 | 16 | $b1 = { E8 ?? FC FF FF 48 8B 45 E8 BE 00 00 00 00 48 89 C7 E8 ?? FC FF FF 48 8B 45 F0 BE 00 00 00 00 48 89 } 17 | $b2 = { E8 ?? FC FF FF B8 00 00 00 00 } 18 | 19 | $source1 = "madvise(map,100,MADV_DONTNEED);" 20 | $source2 = "=open(\"/proc/self/mem\",O_RDWR);" 21 | $source3 = ",map,SEEK_SET);" 22 | 23 | $source_printf1 = "mmap %x" 24 | $source_printf2 = "procselfmem %d" 25 | $source_printf3 = "madvise %d" 26 | $source_printf4 = "[-] failed to patch payload" 27 | $source_printf5 = "[-] failed to win race condition..." 28 | $source_printf6 = "[*] waiting for reverse connect shell..." 29 | 30 | $s1 = "/proc/self/mem" 31 | $s2 = "/proc/%d/mem" 32 | $s3 = "/proc/self/map" 33 | $s4 = "/proc/%d/map" 34 | 35 | $p1 = "pthread_create" fullword ascii 36 | $p2 = "pthread_join" fullword ascii 37 | condition: 38 | ( uint16(0) == 0x457f and $a1 ) or 39 | all of ($b*) or 40 | 3 of ($source*) or 41 | ( uint16(0) == 0x457f and 1 of ($s*) and all of ($p*) and filesize < 20KB ) 42 | } 43 | -------------------------------------------------------------------------------- /rules/Chicken_DOS.yara: -------------------------------------------------------------------------------- 1 | /* Source: https://github.com/Yara-Rules/rules/blob/3872244500f584491cde7c633f12f1f043a61c13/malware/MALW_Chicken.yar /* 2 | 3 | /* 4 | This Yara ruleset is under the GNU-GPLv2 license (http://www.gnu.org/licenses/gpl-2.0.html) and open to any user or organization, as 5 | long as you use it under this license. 6 | */ 7 | 8 | rule ChickenDOS 9 | { 10 | 11 | meta: 12 | author = "Jason Jones " 13 | description = "Win32-variant of Chicken ident for both dropper and dropped file" 14 | source = "https://github.com/arbor/yara/blob/master/chicken.yara" 15 | 16 | strings: 17 | $pdb1 = "\\Chicken\\Release\\svchost.pdb" 18 | $pdb2 = "\\IntergrateCHK\\Release\\IntergrateCHK.pdb" 19 | $str2 = "fake.cf" 20 | $str3 = "8.8.8.8" 21 | $str4 = "Processor(%d)\\" 22 | $str5 = "DbProtectSupport" 23 | $str1 = "dm1712/`jvpnpkte/bpl" 24 | $str6 = "InstallService NPF %d" 25 | $str7 = "68961" 26 | $str8 = "InstallService DbProtectSupport %d" 27 | $str9 = "C:\\Program Files\\DbProtectSupport\\npf.sys" 28 | 29 | condition: 30 | ($pdb1 or $pdb2) and 5 of ($str*) 31 | } 32 | 33 | rule ChickenDOS_Linux 34 | { 35 | 36 | meta: 37 | author = "Jason Jones " 38 | description = "Linux-variant of Chicken ident for both dropper and dropped file" 39 | source = "https://github.com/arbor/yara/blob/master/chicken.yara" 40 | 41 | strings: 42 | $cfg = "fake.cfg" 43 | $file1 = "ThreadAttack.cpp" 44 | $file2 = "Fake.cpp" 45 | $str1 = "dns_array" 46 | $str2 = "DomainRandEx" 47 | $str3 = "cpu %llu %llu %llu %llu" 48 | $str4 = "[ %02d.%02d %02d:%02d:%02d.%03ld ] [%lu] [%s] %s" ascii 49 | 50 | condition: 51 | $cfg and all of ($file*) and 3 of ($str*) 52 | } 53 | -------------------------------------------------------------------------------- /rules/XMRig_Miner_Strings.yara: -------------------------------------------------------------------------------- 1 | /* Source: https://gist.github.com/GelosSnake/c2d4d6ef6f93ccb7d3afb5b1e26c7b4e */ 2 | 3 | rule MinerGate 4 | { 5 | strings: 6 | $a1 = "minergate.com" 7 | condition: 8 | $a1 9 | } 10 | 11 | rule MoneroOrg 12 | { 13 | strings: 14 | $a1 = "POOL.MONERO.ORG" 15 | $a2 = "pool.monero.org" 16 | condition: 17 | $a1 or $a2 18 | } 19 | 20 | rule cryptonotepool 21 | { 22 | strings: 23 | $a1 = "cryptonotepool.org.uk" 24 | condition: 25 | $a1 26 | } 27 | 28 | rule minexmr 29 | { 30 | strings: 31 | $a1 = "minexmr.com" 32 | $a2 = "x.opmoner.com" 33 | condition: 34 | $a1 or $a2 35 | } 36 | 37 | rule monerocryptopoolfr 38 | { 39 | strings: 40 | $a1 = "monero.crypto-pool.fr" 41 | condition: 42 | $a1 43 | } 44 | 45 | rule monerobackuppoolcom 46 | { 47 | strings: 48 | $a1 = "monero.backup-pool.com" 49 | condition: 50 | $a1 51 | } 52 | 53 | rule monerohashcom 54 | { 55 | strings: 56 | $a1 = "monerohash.com" 57 | condition: 58 | $a1 59 | } 60 | 61 | rule mropooltobe 62 | { 63 | strings: 64 | $a1 = "mro.poolto.be" 65 | condition: 66 | $a1 67 | } 68 | 69 | rule moneroxminingpoolcom 70 | { 71 | strings: 72 | $a1 = "monero.xminingpool.com" 73 | condition: 74 | $a1 75 | } 76 | 77 | rule xmrprohashnet 78 | { 79 | strings: 80 | $a1 = "xmr.prohash.net" 81 | condition: 82 | $a1 83 | } 84 | 85 | rule dwarfpoolcom 86 | { 87 | strings: 88 | $a1 = "dwarfpool.com" 89 | condition: 90 | $a1 91 | } 92 | 93 | rule xmrcryptopoolsorg 94 | { 95 | strings: 96 | $a1 = "xmr.crypto-pools.org" 97 | condition: 98 | $a1 99 | } 100 | 101 | rule moneronet 102 | { 103 | strings: 104 | $a1 = "monero.net" 105 | condition: 106 | $a1 107 | } 108 | 109 | rule hashinvestnet 110 | { 111 | strings: 112 | $a1 = "hashinvest.net" 113 | condition: 114 | $a1 115 | } 116 | 117 | rule stratum_tcp_general 118 | { 119 | strings: 120 | $a1 = "stratum+tcp" 121 | condition: 122 | $a1 123 | } -------------------------------------------------------------------------------- /rules/Winnti_Malware.yara: -------------------------------------------------------------------------------- 1 | /* Source: https://raw.githubusercontent.com/deadbits/yara-rules/master/rules/winnti_linux.yara */ 2 | 3 | rule Winnti_Linux: linuxmalware 4 | { 5 | meta: 6 | Author = "Adam M. Swanda" 7 | Website = "https://www.deadbits.org" 8 | Repo = "https://github.com/deadbits/yara-rules" 9 | Date = "2019-07-18" 10 | 11 | strings: 12 | $str0 = "HIDE_THIS_SHELL=x" 13 | $str1 = "/usr/sbin/dmidecode | grep -i 'UUID' |cut -d' ' -f2 2>/dev/null" ascii fullword 14 | $str2 = "mutex.max: %lu" ascii fullword 15 | $str3 = "mutex.err: %lu" ascii fullword 16 | $str4 = "/tmp/ans.log" ascii fullword 17 | $str5 = "mutex.used: %lu" ascii fullword 18 | $str6 = "Warning: Some of the worker threads may have failed to exit." ascii fullword 19 | $str7 = "line %d - " ascii fullword 20 | $str8 = "Warning an error has occurred when trying to obtain a worker task." ascii fullword 21 | $str9 = "6CMutex" ascii fullword 22 | $str10 = "Failed to obtain an empty task from the free tasks queue." ascii fullword 23 | $str11 = "A problem was detected in the queue (expected NULL, but found a different value)." ascii fullword 24 | $str12 = "Failed to a task to the free tasks queue during initialization." ascii fullword 25 | $str13 = "/var/run/libudev1.pid" ascii fullword 26 | $str14 = "__pthread_key_create" ascii fullword 27 | $str15 = "The threadpool received as argument is NULL." ascii fullword 28 | $str16 = "Failed to enqueue a task to free tasks queue." ascii fullword 29 | $str17 = "Failed to obtain a task from the jobs queue." ascii fullword 30 | $str18 = "Failed to add a new task to the tasks queue." ascii fullword 31 | $str19 = "setsockopt failed" ascii fullword 32 | $str20 = "libxselinux.so" ascii fullword 33 | $str21 = "/lib/libxselinux" ascii fullword 34 | 35 | condition: 36 | uint16(0) == 0x457f 37 | and 38 | 8 of them 39 | } 40 | -------------------------------------------------------------------------------- /rules/ACBackdoor_Malware.yara: -------------------------------------------------------------------------------- 1 | /* Source: https://raw.githubusercontent.com/deadbits/yara-rules/master/rules/ACBackdoor_Linux.yara */ 2 | 3 | rule ACBackdoor_ELF: linux malware backdoor 4 | { 5 | meta: 6 | author = "Adam M. Swanda" 7 | date = "Nov 2019" 8 | reference = "https://www.intezer.com/blog-acbackdoor-analysis-of-a-new-multiplatform-backdoor/" 9 | 10 | strings: 11 | $ua_str = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.1.4322)" ascii fullword 12 | $header1 = "Access-Control:" ascii fullword 13 | $header2 = "X-Access" ascii 14 | 15 | $initd = "/etc/init.d/update-notifier" ascii fullword 16 | $str001 = "#!/bin/sh -e" ascii fullword 17 | $str002 = "### BEGIN INIT INFO" ascii fullword 18 | $str003 = "# Provides: update-notifier" ascii fullword 19 | $str004 = "# Required-Start: $local_fs" ascii fullword 20 | $str005 = "# Required-Stop:" ascii fullword 21 | $str006 = "# Default-Start: S" ascii fullword 22 | $str007 = "# Default-Stop:" ascii fullword 23 | $str008 = "### END INIT INFO" ascii fullword 24 | $str010 = " *) echo \"Usage: $0 {start|stop|restart|force-reload}\" >&2; ;;" ascii fullword 25 | $str011 = "esac" ascii fullword 26 | $str012 = "[ -x /usr/local/bin/update-notifier ] \\" ascii fullword 27 | $str013 = " && exec /usr/local/bin/update-notifier" ascii fullword 28 | $rcd01 = "/etc/rc2.d/S01update-notifier" ascii fullword 29 | $rcd02 = "/etc/rc3.d/S01update-notifier" ascii fullword 30 | $rcd03 = "/etc/rc5.d/S01update-notifier" ascii fullword 31 | 32 | condition: 33 | /* trigger = '{7f 45 4c 46}' - ELF magic bytes */ 34 | (uint32be(0x0) == 0x7f454c46) 35 | and 36 | ( 37 | ($ua_str and all of ($header*) and $initd and all of ($rcd*)) 38 | or 39 | ( 40 | $ua_str and all of ($header*) and 10 of ($str*) 41 | ) 42 | ) 43 | } 44 | -------------------------------------------------------------------------------- /rules/GodLua_Malware.yara: -------------------------------------------------------------------------------- 1 | /* Source: https://github.com/deadbits/yara-rules/blob/master/rules/godlua_linux.yara */ 2 | 3 | rule GodLua_Linux: linuxmalware 4 | { 5 | meta: 6 | Author = "Adam M. Swanda" 7 | Website = "https://www.deadbits.org" 8 | Repo = "https://github.com/deadbits/yara-rules" 9 | Date = "2019-07-18" 10 | 11 | strings: 12 | 13 | $tmp0 = "/tmp" ascii fullword 14 | $tmp1 = "TMPDIR" ascii 15 | 16 | $str1 = "\"description\": \"" ascii fullword 17 | $str2 = "searchers" ascii fullword 18 | $str3 = "/dev/misc/watchdog" ascii fullword 19 | $str4 = "/dev/wdt" ascii fullword 20 | $str5 = "/dev/misc/wdt" 21 | $str6 = "lcurl.safe" ascii fullword 22 | $str7 = "luachild" ascii fullword 23 | $str8 = "cjson.safe" ascii fullword 24 | $str9 = "HostUrl" ascii fullword 25 | $str10 = "HostConnect" ascii fullword 26 | $str11 = "LUABOX" ascii fullword 27 | $str12 = "Infinity" ascii fullword 28 | $str13 = "/bin/sh" ascii fullword 29 | $str14 = /\.onion(\.)?/ ascii fullword 30 | $str15 = "/etc/resolv.conf" ascii fullword 31 | $str16 = "hosts:" ascii fullword 32 | 33 | $resolvers = /([0-9]{1,3}\.){3}[0-9]{1,3}:53,([0-9]{1,3}\.){3}[0-9]{1,3},([0-9]{1,3}\.){3}[0-9]{1,3}:5353,([0-9]{1,3}\.){3}[0-9]{1,3}:443/ ascii 34 | 35 | $identifier0 = "$LuaVersion: God " ascii 36 | $identifier1 = /fbi\/d\.\/d.\/d/ ascii 37 | $identifier2 = "Copyright (C) FBI Systems, 2012-2019, https://fbi.gov" fullword ascii 38 | $identifier3 = "God 5.1" 39 | 40 | condition: 41 | uint16(0) == 0x457f 42 | and 43 | ( 44 | all of them 45 | or 46 | ( 47 | any of ($identifier*) 48 | and $resolvers 49 | and any of ($tmp*) 50 | and 4 of ($str*) 51 | ) 52 | or 53 | ( 54 | any of ($identifier*) 55 | and any of ($tmp*) 56 | and 4 of ($str*) 57 | ) 58 | ) 59 | } 60 | 61 | -------------------------------------------------------------------------------- /rules/Mirai_Okiru_Malware.yara: -------------------------------------------------------------------------------- 1 | /* Source: https://github.com/Yara-Rules/rules/blob/3872244500f584491cde7c633f12f1f043a61c13/malware/MALW_Mirai_Okiru_ELF.yar */ 2 | 3 | /* Yara rule to detect Mirai Okiru generic 4 | This Yara ruleset is under the GNU-GPLv2 license (http://www.gnu.org/licenses/gpl-2.0.html) 5 | and open to any user or organization, as long as you use it under this license. 6 | */ 7 | 8 | 9 | private rule is__elf { 10 | meta: 11 | author = "@mmorenog,@yararules" 12 | strings: 13 | $header = { 7F 45 4C 46 } 14 | condition: 15 | $header at 0 16 | } 17 | 18 | private rule is__Mirai_gen7 { 19 | meta: 20 | description = "Generic detection for MiraiX version 7" 21 | reference = "http://blog.malwaremustdie.org/2016/08/mmd-0056-2016-linuxmirai-just.html" 22 | author = "unixfreaxjp" 23 | org = "MalwareMustDie" 24 | date = "2018-01-05" 25 | 26 | strings: 27 | $st01 = "/bin/busybox rm" fullword nocase wide ascii 28 | $st02 = "/bin/busybox echo" fullword nocase wide ascii 29 | $st03 = "/bin/busybox wget" fullword nocase wide ascii 30 | $st04 = "/bin/busybox tftp" fullword nocase wide ascii 31 | $st05 = "/bin/busybox cp" fullword nocase wide ascii 32 | $st06 = "/bin/busybox chmod" fullword nocase wide ascii 33 | $st07 = "/bin/busybox cat" fullword nocase wide ascii 34 | 35 | condition: 36 | 5 of them 37 | } 38 | 39 | rule Mirai_Okiru { 40 | meta: 41 | description = "Detects Mirai Okiru MALW" 42 | reference = "https://www.reddit.com/r/LinuxMalware/comments/7p00i3/quick_notes_for_okiru_satori_variant_of_mirai/" 43 | date = "2018-01-05" 44 | 45 | strings: 46 | $hexsts01 = { 68 7f 27 70 60 62 73 3c 27 28 65 6e 69 28 65 72 } 47 | $hexsts02 = { 74 7e 65 68 7f 27 73 61 73 77 3c 27 28 65 6e 69 } 48 | // noted some Okiru variant doesnt have below function, uncomment to seek specific x86 bins 49 | // $st07 = "iptables -F\n" fullword nocase wide ascii 50 | 51 | condition: 52 | all of them 53 | and is__elf 54 | and is__Mirai_gen7 55 | and filesize < 100KB 56 | } 57 | -------------------------------------------------------------------------------- /rules/Torte_ELF_Malware.yara: -------------------------------------------------------------------------------- 1 | /* Source: https://github.com/Yara-Rules/rules/blob/3872244500f584491cde7c633f12f1f043a61c13/malware/MALW_Torte_ELF.yar /* 2 | 3 | /* 4 | This Yara ruleset is under the GNU-GPLv2 license (http://www.gnu.org/licenses/gpl-2.0.html) and open to any user or organization, as 5 | long as you use it under this license. 6 | */ 7 | 8 | private rule is__elf { 9 | meta: 10 | author = "@mmorenog,@yararules" 11 | strings: 12 | $header = { 7F 45 4C 46 } 13 | condition: 14 | $header at 0 15 | } 16 | 17 | rule ELF_Linux_Torte : Linux ELF 18 | 19 | { 20 | meta: 21 | author = "@mmorenog,@yararules" 22 | description = "Detects ELF Linux/Torte infection" 23 | ref = "http://blog.malwaremustdie.org/2016/01/mmd-0050-2016-incident-report-elf.html" 24 | hash1 = "1faf27f6b8e8a9cadb611f668a01cf73" 25 | hash2 = "cb0477445fef9c5f1a5b6689bbfb941e" 26 | 27 | strings: 28 | $s0 = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.6)" 29 | $s1 = "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.7.6)" 30 | $s2 = "?sessd=" 31 | $s3 = "&sessc=" 32 | $s4 = "&sessk=" 33 | $s5 = "3a08fe7b8c4da6ed09f21c3ef97efce2" 34 | $s6 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" 35 | $s7 = "_ZN11CThreadPool10getBatchesERSt6vectorISt4pairISsiESaIS2_EE" 36 | $s8 = "_ZNSs4_Rep10_M_destroyERKSaIcE@@GLIBCXX_3.4" 37 | $s9 = "_ZNSt6vectorImSaImEE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPmS1_EERKm" 38 | $s10 = "_ZNSt6vectorISt4pairISsiESaIS1_EE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPS1_S3_EERKS1_" 39 | $s11 = "_ZSt20__throw_out_of_rangePKc@@GLIBCXX_3.4" 40 | 41 | condition: 42 | is__elf and all of ($s*) 43 | } 44 | 45 | 46 | rule ELF_Linux_Torte_domains { 47 | meta: 48 | author = "@mmorenog,@yararules" 49 | description = "Detects ELF Linux/Torte infection" 50 | ref1 = "http://blog.malwaremustdie.org/2016/01/mmd-0050-2016-incident-report-elf.html" 51 | strings: 52 | $1 = "pages.touchpadz.com" ascii wide nocase 53 | $2 = "bat.touchpadz.com" ascii wide nocase 54 | $3 = "stat.touchpadz.com" ascii wide nocase 55 | $4 = "sk2.touchpadz.com" ascii wide nocase 56 | 57 | condition: 58 | any of them 59 | } 60 | -------------------------------------------------------------------------------- /rules/Mirai_Satori_Malware.yara: -------------------------------------------------------------------------------- 1 | /* Source: https://github.com/Yara-Rules/rules/blob/3872244500f584491cde7c633f12f1f043a61c13/malware/MALW_Mirai_Satori_ELF.yar */ 2 | 3 | /* Yara rule to detect Mirai Satori generic 4 | This Yara ruleset is under the GNU-GPLv2 license (http://www.gnu.org/licenses/gpl-2.0.html) 5 | and open to any user or organization, as long as you use it under this license. 6 | */ 7 | 8 | private rule is__elf { 9 | meta: 10 | author = "@mmorenog,@yararules" 11 | strings: 12 | $header = { 7F 45 4C 46 } 13 | condition: 14 | $header at 0 15 | } 16 | 17 | private rule is__Mirai_gen7 { 18 | meta: 19 | description = "Generic detection for MiraiX version 7" 20 | reference = "http://blog.malwaremustdie.org/2016/08/mmd-0056-2016-linuxmirai-just.html" 21 | author = "unixfreaxjp" 22 | org = "MalwareMustDie" 23 | date = "2018-01-05" 24 | 25 | strings: 26 | $st01 = "/bin/busybox rm" fullword nocase wide ascii 27 | $st02 = "/bin/busybox echo" fullword nocase wide ascii 28 | $st03 = "/bin/busybox wget" fullword nocase wide ascii 29 | $st04 = "/bin/busybox tftp" fullword nocase wide ascii 30 | $st05 = "/bin/busybox cp" fullword nocase wide ascii 31 | $st06 = "/bin/busybox chmod" fullword nocase wide ascii 32 | $st07 = "/bin/busybox cat" fullword nocase wide ascii 33 | 34 | condition: 35 | 5 of them 36 | } 37 | 38 | private rule is__Mirai_Satori_gen { 39 | meta: 40 | description = "Detects Mirai Satori_gen" 41 | reference = "https://www.reddit.com/r/LinuxMalware/comments/7p00i3/quick_notes_for_okiru_satori_variant_of_mirai/" 42 | date = "2018-01-05" 43 | 44 | strings: 45 | $st08 = "tftp -r satori" fullword nocase wide ascii 46 | $st09 = "/bins/satori" fullword nocase wide ascii 47 | $st10 = "satori" fullword nocase wide ascii 48 | $st11 = "SATORI" fullword nocase wide ascii 49 | 50 | condition: 51 | 2 of them 52 | } 53 | 54 | rule Mirai_Satori { 55 | meta: 56 | description = "Detects Mirai Satori MALW" 57 | date = "2018-01-09" 58 | 59 | strings: 60 | $hexsts01 = { 63 71 75 ?? 62 6B 77 62 75 } 61 | $hexsts02 = { 53 54 68 72 75 64 62 } 62 | $hexsts03 = { 28 63 62 71 28 70 66 73 64 6F 63 68 60 } 63 | 64 | condition: 65 | all of them 66 | and is__elf 67 | and is__Mirai_gen7 68 | and is__Mirai_Satori_gen 69 | and filesize < 100KB 70 | } 71 | -------------------------------------------------------------------------------- /rules/EvilGnome_Malware.yara: -------------------------------------------------------------------------------- 1 | /* Source: https://github.com/deadbits/yara-rules/blob/master/rules/EvilGnome_Linux.yara */ 2 | 3 | rule EvilGnome_Linux: infostealer linuxmalware 4 | { 5 | meta: 6 | Description = "Detects the EvilGnome backdoor malware designed for Linux desktops, which disguises itself as a Gnome extension." 7 | Reference = "https://www.intezer.com/blog-evilgnome-rare-malware-spying-on-linux-desktop-users/" 8 | 9 | strings: 10 | 11 | $ftype0 = ".doc" ascii fullword 12 | $ftype1 = ".docx" ascii fullword 13 | $ftype2 = ".pdf" ascii fullword 14 | $ftype3 = ".rtf" ascii fullword 15 | 16 | $cpp0 = "_GLOBAL__sub_I_application.cpp" ascii 17 | $cpp1 = "_GLOBAL__sub_I_shooterPing.cpp" ascii 18 | $cpp2 = "_GLOBAL__sub_I_packetBase.cpp" ascii 19 | $cpp3 = "_GLOBAL__sub_I_parameters.cpp" ascii 20 | $cpp4 = "_GLOBAL__sub_I_session.cpp" ascii 21 | $cpp5 = "_GLOBAL__sub_I_packet.cpp" ascii 22 | $cpp6 = "_GLOBAL__sub_I_rc5.cpp" ascii 23 | $cpp7 = "shooterImage.cpp" ascii 24 | $cpp8 = "shooterSound.cpp" ascii 25 | $cpp9 = "shooterFile.cpp" ascii 26 | $cpp10 = "../session.cpp" ascii 27 | $cpp12 = "shooterKey.cpp" ascii 28 | $cpp13 = "tcpSocket.cpp" ascii 29 | $cpp14 = "shooter.cpp" ascii 30 | $cpp15 = "logger.cpp" ascii 31 | $cpp16 = "engine.cpp" ascii 32 | $cpp17 = "main.cpp" ascii 33 | 34 | $path0 = ".lib" ascii fullword 35 | $path1 = "opt" ascii fullword 36 | $path2 = "proc" ascii fullword 37 | $path3 = "root" ascii fullword 38 | $path4 = "run" ascii fullword 39 | $path5 = "sbin" ascii fullword 40 | $path6 = "snap" ascii fullword 41 | $path7 = "srv" ascii fullword 42 | $path8 = "sys" ascii fullword 43 | $path9 = "tmp" ascii fullword 44 | $path10 = "usr" ascii fullword 45 | $path11 = "boot" ascii fullword 46 | $path12 = "var" ascii fullword 47 | $path13 = "cdrom" ascii fullword 48 | $path14 = "dev" ascii fullword 49 | $path15 = "etc" ascii fullword 50 | $path16 = "lib" ascii fullword 51 | $path17 = "lib32" ascii fullword 52 | $path18 = "lib64" ascii fullword 53 | $path19 = "lost+found" ascii fullword 54 | 55 | condition: 56 | (uint32be(0x0) == 0x7f454c46) 57 | and 58 | 10 of ($cpp*) 59 | and all of ($ftype*) 60 | and all of ($path*) 61 | } 62 | -------------------------------------------------------------------------------- /rules/Sofacy_Backdoor.yara: -------------------------------------------------------------------------------- 1 | /* Source: https://github.com/Yara-Rules/rules/blob/3872244500f584491cde7c633f12f1f043a61c13/malware/APT_Sofacy_Fysbis.yar /* 2 | 3 | /* 4 | This Yara ruleset is under the GNU-GPLv2 license (http://www.gnu.org/licenses/gpl-2.0.html) and open to any user or organization, as long as you use it under this license. 5 | 6 | */ 7 | /* 8 | Yara Rule Set 9 | Author: Florian Roth 10 | Date: 2016-02-13 11 | Identifier: Sofacy Fysbis 12 | */ 13 | 14 | rule Sofacy_Fybis_ELF_Backdoor_Gen1 15 | { 16 | 17 | meta: 18 | description = "Detects Sofacy Fysbis Linux Backdoor_Naikon_APT_Sample1" 19 | author = "Florian Roth" 20 | reference = "http://researchcenter.paloaltonetworks.com/2016/02/a-look-into-fysbis-sofacys-linux-backdoor/" 21 | date = "2016-02-13" 22 | score = 80 23 | hash1 = "02c7cf55fd5c5809ce2dce56085ba43795f2480423a4256537bfdfda0df85592" 24 | hash2 = "8bca0031f3b691421cb15f9c6e71ce193355d2d8cf2b190438b6962761d0c6bb" 25 | 26 | strings: 27 | $x1 = "Your command not writed to pipe" fullword ascii 28 | $x2 = "Terminal don`t started for executing command" fullword ascii 29 | $x3 = "Command will have end with \\n" fullword ascii 30 | $s1 = "WantedBy=multi-user.target' >> /usr/lib/systemd/system/" fullword ascii 31 | $s2 = "Success execute command or long for waiting executing your command" fullword ascii 32 | $s3 = "ls /etc | egrep -e\"fedora*|debian*|gentoo*|mandriva*|mandrake*|meego*|redhat*|lsb-*|sun-*|SUSE*|release\"" fullword ascii 33 | $s4 = "rm -f /usr/lib/systemd/system/" fullword ascii 34 | $s5 = "ExecStart=" fullword ascii 35 | $s6 = "" fullword ascii 36 | 37 | condition: 38 | ( uint16(0) == 0x457f and filesize < 500KB and 1 of ($x*) ) or ( 1 of ($x*) and 3 of ($s*) ) 39 | } 40 | 41 | rule Sofacy_Fysbis_ELF_Backdoor_Gen2 42 | { 43 | 44 | meta: 45 | description = "Detects Sofacy Fysbis Linux Backdoor" 46 | author = "Florian Roth" 47 | reference = "http://researchcenter.paloaltonetworks.com/2016/02/a-look-into-fysbis-sofacys-linux-backdoor/" 48 | date = "2016-02-13" 49 | score = 80 50 | hash1 = "02c7cf55fd5c5809ce2dce56085ba43795f2480423a4256537bfdfda0df85592" 51 | hash2 = "8bca0031f3b691421cb15f9c6e71ce193355d2d8cf2b190438b6962761d0c6bb" 52 | hash3 = "fd8b2ea9a2e8a67e4cb3904b49c789d57ed9b1ce5bebfe54fe3d98214d6a0f61" 53 | 54 | strings: 55 | $s1 = "RemoteShell" ascii 56 | $s2 = "basic_string::_M_replace_dispatch" fullword ascii 57 | $s3 = "HttpChannel" ascii 58 | 59 | condition: 60 | uint16(0) == 0x457f and filesize < 500KB and all of them 61 | } 62 | 63 | -------------------------------------------------------------------------------- /rules/Mandibule_Toolkit.yara: -------------------------------------------------------------------------------- 1 | private rule is__elf { 2 | meta: 3 | author = "@mmorenog,@yararules" 4 | strings: 5 | $header = { 7F 45 4C 46 } 6 | condition: 7 | $header at 0 8 | } 9 | 10 | /* Source: https://github.com/Yara-Rules/rules/blob/3872244500f584491cde7c633f12f1f043a61c13/malware/TOOLKIT_Mandibule.yar */ 11 | 12 | /* Yara rule to detect ELF Linux process injector toolkit "mandibule" generic. 13 | name: TOOLKIT_Mandibule.yar analyzed by unixfreaxjp. 14 | result: 15 | TOOLKIT_Mandibule ./mandibule//mandibule-dynx86-stripped 16 | TOOLKIT_Mandibule ./mandibule//mandibule-dynx86-UNstripped 17 | TOOLKIT_Mandibule ./mandibule//mandibule-dun64-UNstripped 18 | TOOLKIT_Mandibule ./mandibule//mandibule-dyn64-stripped 19 | 20 | This Yara ruleset is under the GNU-GPLv2 license (http://www.gnu.org/licenses/gpl-2.0.html) 21 | and open to any user or organization, as long as you use it under this license. 22 | */ 23 | 24 | private rule is__str_mandibule_gen1 { 25 | meta: 26 | author = "unixfreaxjp" 27 | date = "2018-05-31" 28 | strings: 29 | $str01 = "shared arguments too big" fullword nocase wide ascii 30 | $str02 = "self inject pid: %" fullword nocase wide ascii 31 | $str03 = "injected shellcode at 0x%lx" fullword nocase wide ascii 32 | $str04 = "target pid: %d" fullword nocase wide ascii 33 | $str05 = "mapping '%s' into memory at 0x%lx" fullword nocase wide ascii 34 | $str06 = "shellcode injection addr: 0x%lx" fullword nocase wide ascii 35 | $str07 = "loading elf at: 0x%llx" fullword nocase wide ascii 36 | condition: 37 | 4 of them 38 | } 39 | 40 | private rule is__hex_top_mandibule64 { 41 | meta: 42 | author = "unixfreaxjp" 43 | date = "2018-05-31" 44 | strings: 45 | $hex01 = { 48 8D 05 43 01 00 00 48 89 E7 FF D0 } // st 46 | $hex02 = { 53 48 83 EC 50 48 89 7C 24 08 48 8B 44 24 08 } // mn 47 | $hex03 = { 48 81 EC 18 02 00 00 89 7C 24 1C 48 89 74 } // pt 48 | $hex04 = { 53 48 81 EC 70 01 01 00 48 89 7C 24 08 48 8D 44 24 20 48 05 00 00 } // ld 49 | condition: 50 | 3 of them 51 | } 52 | 53 | private rule is__hex_mid_mandibule32 { 54 | meta: 55 | author = "unixfreaxjp" 56 | date = "2018-06-01" 57 | strings: 58 | $hex05 = { E8 09 07 00 00 81 C1 FC 1F 00 00 8D 81 26 E1 FF FF } // st 59 | $hex06 = { 56 53 83 EC 24 E8 E1 05 00 00 81 C3 D0 1E 00 00 8B 44 24 30} // mn 60 | $hex07 = { 81 C3 E8 29 00 00 C7 44 24 0C } // pt 61 | $hex08 = { E8 C6 D5 FF FF 83 C4 0C 68 00 01 00 00 } // ld 62 | condition: 63 | 3 of them 64 | } 65 | 66 | rule TOOLKIT_Mandibule { 67 | meta: 68 | description = "Generic detection for ELF Linux process injector mandibule generic" 69 | reference = "https://imgur.com/a/MuHSZtC" 70 | author = "unixfreaxjp" 71 | org = "MalwareMustDie" 72 | date = "2018-06-01" 73 | condition: 74 | ((is__str_mandibule_gen1) or (is__hex_mid_mandibule32)) 75 | or ((is__str_mandibule_gen1) or (is__hex_top_mandibule64)) 76 | and is__elf 77 | and filesize < 30KB 78 | } 79 | -------------------------------------------------------------------------------- /rules/Op_Windigo_Malware.yara: -------------------------------------------------------------------------------- 1 | /* Source: https://github.com/Yara-Rules/rules/blob/3872244500f584491cde7c633f12f1f043a61c13/malware/APT_Windigo_Onimiki.yar */ 2 | 3 | /* 4 | This Yara ruleset is under the GNU-GPLv2 license (http://www.gnu.org/licenses/gpl-2.0.html) and open to any user or organization, as long as you use it under this license. 5 | 6 | */ 7 | 8 | // Operation Windigo yara rules 9 | // For feedback or questions contact us at: windigo@eset.sk 10 | // https://github.com/eset/malware-ioc/ 11 | // 12 | // These yara rules are provided to the community under the two-clause BSD 13 | // license as follows: 14 | // 15 | // Copyright (c) 2014, ESET 16 | // All rights reserved. 17 | // 18 | // Redistribution and use in source and binary forms, with or without 19 | // modification, are permitted provided that the following conditions are met: 20 | // 21 | // 1. Redistributions of source code must retain the above copyright notice, this 22 | // list of conditions and the following disclaimer. 23 | // 24 | // 2. Redistributions in binary form must reproduce the above copyright notice, 25 | // this list of conditions and the following disclaimer in the documentation 26 | // and/or other materials provided with the distribution. 27 | // 28 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 29 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 30 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 31 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 32 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 34 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 35 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 36 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 37 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 38 | // 39 | rule onimiki 40 | { 41 | 42 | meta: 43 | description = "Linux/Onimiki malicious DNS server" 44 | malware = "Linux/Onimiki" 45 | operation = "Windigo" 46 | author = "Olivier Bilodeau " 47 | created = "2014-02-06" 48 | reference = "http://www.welivesecurity.com/wp-content/uploads/2014/03/operation_windigo.pdf" 49 | contact = "windigo@eset.sk" 50 | source = "https://github.com/eset/malware-ioc/" 51 | license = "BSD 2-Clause" 52 | 53 | strings: 54 | // code from offset: 0x46CBCD 55 | $a1 = {43 0F B6 74 2A 0E 43 0F B6 0C 2A 8D 7C 3D 00 8D} 56 | $a2 = {74 35 00 8D 4C 0D 00 89 F8 41 F7 E3 89 F8 29 D0} 57 | $a3 = {D1 E8 01 C2 89 F0 C1 EA 04 44 8D 0C 92 46 8D 0C} 58 | $a4 = {8A 41 F7 E3 89 F0 44 29 CF 29 D0 D1 E8 01 C2 89} 59 | $a5 = {C8 C1 EA 04 44 8D 04 92 46 8D 04 82 41 F7 E3 89} 60 | $a6 = {C8 44 29 C6 29 D0 D1 E8 01 C2 C1 EA 04 8D 04 92} 61 | $a7 = {8D 04 82 29 C1 42 0F B6 04 21 42 88 84 14 C0 01} 62 | $a8 = {00 00 42 0F B6 04 27 43 88 04 32 42 0F B6 04 26} 63 | $a9 = {42 88 84 14 A0 01 00 00 49 83 C2 01 49 83 FA 07} 64 | 65 | condition: 66 | all of them 67 | } 68 | -------------------------------------------------------------------------------- /rules/ELF_Malware_Strings.yara: -------------------------------------------------------------------------------- 1 | /* Source: https://github.com/Yara-Rules/rules/blob/3872244500f584491cde7c633f12f1f043a61c13/malware/MALW_Httpsd_ELF.yar /* 2 | 3 | /* Yara rule to detect Linux/Httpsd generic 4 | This Yara ruleset is under the GNU-GPLv2 license (http://www.gnu.org/licenses/gpl-2.0.html) 5 | and open to any user or organization, as long as you use it under this license. 6 | */ 7 | 8 | private rule is__elf { 9 | meta: 10 | author = "@mmorenog,@yararules" 11 | strings: 12 | $header = { 7F 45 4C 46 } 13 | condition: 14 | $header at 0 15 | } 16 | 17 | private rule is__LinuxHttpsdStrings { 18 | 19 | meta: 20 | description = "Strings of ELF Linux/Httpsd (backdoor, downloader, remote command execution)" 21 | ref1 = "https://imgur.com/a/8mFGk" 22 | ref2 = "https://otx.alienvault.com/pulse/5a49115f93199b171b90a212" 23 | ref3 = "https://misppriv.circl.lu/events/view/9952" 24 | author = "unixfreaxjp" 25 | org = "MalwareMustDie" 26 | date = "2018-01-02" 27 | sha256 = "dd1266561fe7fcd54d1eb17efbbb6babaa9c1f44b36cef6e06052e22ce275ccd" 28 | sha256 = "1b3718698fae20b63fbe6ab32411a02b0b08625f95014e03301b49afaee9d559" 29 | 30 | strings: 31 | $st01 = "k.conectionapis.com" fullword nocase wide ascii 32 | $st02 = "key=%s&host_name=%s&cpu_count=%d&os_type=%s&core_count=%s" fullword nocase wide ascii 33 | $st03 = "id=%d&result=%s" fullword nocase wide ascii 34 | $st04 = "rtime" fullword nocase wide ascii 35 | $st05 = "down" fullword nocase wide ascii 36 | $st06 = "cmd" fullword nocase wide ascii 37 | $st07 = "0 */6 * * * root" fullword nocase wide ascii 38 | $st08 = "/etc/cron.d/httpsd" fullword nocase wide ascii 39 | $st09 = "cat /proc/cpuinfo |grep processor|wc -l" fullword nocase wide ascii 40 | $st10 = "k.conectionapis.com" fullword nocase wide ascii 41 | $st11 = "/api" fullword nocase wide ascii 42 | $st12 = "/tmp/.httpslog" fullword nocase wide ascii 43 | $st13 = "/bin/.httpsd" fullword nocase wide ascii 44 | $st14 = "/tmp/.httpsd" fullword nocase wide ascii 45 | $st15 = "/tmp/.httpspid" fullword nocase wide ascii 46 | $st16 = "/tmp/.httpskey" fullword nocase wide ascii 47 | 48 | condition: 49 | all of them 50 | } 51 | 52 | rule Linux_Httpsd_malware_ARM { 53 | 54 | meta: 55 | description = "Detects Linux/Httpsd ARMv5" 56 | date = "2017-12-31" 57 | 58 | strings: 59 | $hexsts01 = { f0 4f 2d e9 1e db 4d e2 ec d0 4d e2 01 40 a0 e1 } // main 60 | $hexsts02 = { f0 45 2d e9 0b db 4d e2 04 d0 4d e2 3c 01 9f e5 } // self-rclocal 61 | $hexsts03 = { f0 45 2d e9 01 db 4d e2 04 d0 4d e2 bc 01 9f e5 } // copy-self 62 | 63 | condition: 64 | all of them 65 | and is__elf 66 | and is__LinuxHttpsdStrings 67 | and filesize < 200KB 68 | } 69 | 70 | rule Linux_Httpsd_malware_i686 { 71 | 72 | meta: 73 | description = "Detects ELF Linux/Httpsd i686" 74 | date = "2018-01-02" 75 | 76 | 77 | strings: 78 | $hexsts01 = { 8d 4c 24 04 83 e4 f0 ff 71 fc 55 89 e5 57 56 53 } // main 79 | $hexsts02 = { 55 89 e5 57 56 53 81 ec 14 2c 00 00 68 7a 83 05 } // self-rclocal 80 | $hexsts03 = { 55 89 e5 57 56 53 81 ec 10 04 00 00 68 00 04 00 } // copy-self 81 | 82 | condition: 83 | all of them 84 | and is__elf 85 | and is__LinuxHttpsdStrings 86 | and filesize < 200KB 87 | } 88 | -------------------------------------------------------------------------------- /rules/Moose_Malware.yara: -------------------------------------------------------------------------------- 1 | /* Source: https://github.com/Yara-Rules/rules/blob/3872244500f584491cde7c633f12f1f043a61c13/malware/MALW_LinuxMoose.yar /* 2 | 3 | /* 4 | This Yara ruleset is under the GNU-GPLv2 license (http://www.gnu.org/licenses/gpl-2.0.html) and open to any user or organization, as long as you use it under this license. 5 | 6 | */ 7 | 8 | // Linux/Moose yara rules 9 | // For feedback or questions contact us at: github@eset.com 10 | // https://github.com/eset/malware-ioc/ 11 | // 12 | // These yara rules are provided to the community under the two-clause BSD 13 | // license as follows: 14 | // 15 | // Copyright (c) 2015, ESET 16 | // All rights reserved. 17 | // 18 | // Redistribution and use in source and binary forms, with or without 19 | // modification, are permitted provided that the following conditions are met: 20 | // 21 | // 1. Redistributions of source code must retain the above copyright notice, this 22 | // list of conditions and the following disclaimer. 23 | // 24 | // 2. Redistributions in binary form must reproduce the above copyright notice, 25 | // this list of conditions and the following disclaimer in the documentation 26 | // and/or other materials provided with the distribution. 27 | // 28 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 29 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 30 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 31 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 32 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 34 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 35 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 36 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 37 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 38 | // 39 | 40 | private rule is_elf 41 | { 42 | strings: 43 | $header = { 7F 45 4C 46 } 44 | 45 | condition: 46 | $header at 0 47 | } 48 | 49 | rule moose 50 | { 51 | meta: 52 | Author = "Thomas Dupuy" 53 | Date = "2015/04/21" 54 | Description = "Linux/Moose malware" 55 | Reference = "http://www.welivesecurity.com/wp-content/uploads/2015/05/Dissecting-LinuxMoose.pdf" 56 | Source = "https://github.com/eset/malware-ioc/" 57 | Contact = "github@eset.com" 58 | License = "BSD 2-Clause" 59 | 60 | strings: 61 | $s0 = "Status: OK" 62 | $s1 = "--scrypt" 63 | $s2 = "stratum+tcp://" 64 | $s3 = "cmd.so" 65 | $s4 = "/Challenge" 66 | $s7 = "processor" 67 | $s9 = "cpu model" 68 | $s21 = "password is wrong" 69 | $s22 = "password:" 70 | $s23 = "uthentication failed" 71 | $s24 = "sh" 72 | $s25 = "ps" 73 | $s26 = "echo -n -e " 74 | $s27 = "chmod" 75 | $s28 = "elan2" 76 | $s29 = "elan3" 77 | $s30 = "chmod: not found" 78 | $s31 = "cat /proc/cpuinfo" 79 | $s32 = "/proc/%s/cmdline" 80 | $s33 = "kill %s" 81 | 82 | condition: 83 | is_elf and all of them 84 | } 85 | -------------------------------------------------------------------------------- /rules/Rebirth_Vulcan_Malware.yara: -------------------------------------------------------------------------------- 1 | /* Source: https://github.com/Yara-Rules/rules/blob/3872244500f584491cde7c633f12f1f043a61c13/malware/MALW_Rebirth_Vulcan_ELF.yar */ 2 | 3 | /* Yara rule to detect ELF Linux malware Rebirth Vulcan (Torlus next-gen) generic 4 | This Yara ruleset is under the GNU-GPLv2 license (http://www.gnu.org/licenses/gpl-2.0.html) 5 | and open to any user or organization, as long as you use it under this license. 6 | */ 7 | 8 | private rule is__elf { 9 | meta: 10 | author = "@mmorenog,@yararules" 11 | strings: 12 | $header = { 7F 45 4C 46 } 13 | condition: 14 | $header at 0 15 | } 16 | 17 | private rule is__str_Rebirth_gen3 { 18 | meta: 19 | description = "Generic detection for Vulcan branch Rebirth or Katrina from Torlus nextgen" 20 | reference = "https://imgur.com/a/SSKmu" 21 | reference = "https://www.reddit.com/r/LinuxMalware/comments/7rprnx/vulcan_aka_linuxrebirth_or_katrina_variant_of/" 22 | author = "unixfreaxjp" 23 | org = "MalwareMustDie" 24 | date = "2018-01-21" 25 | strings: 26 | $str01 = "/usr/bin/python" fullword nocase wide ascii 27 | $str02 = "nameserver 8.8.8.8\nnameserver 8.8.4.4\n" fullword nocase wide ascii 28 | $str03 = "Telnet Range %d->%d" fullword nocase wide ascii 29 | $str04 = "Mirai Range %d->%d" fullword nocase wide ascii 30 | $str05 = "[Updating] [%s:%s]" fullword nocase wide ascii 31 | $str06 = "rm -rf /tmp/* /var/* /var/run/* /var/tmp/*" fullword nocase wide ascii 32 | $str07 = "\x1B[96m[DEVICE] \x1B[97mConnected" fullword nocase wide ascii 33 | condition: 34 | 4 of them 35 | } 36 | 37 | private rule is__hex_Rebirth_gen3 { 38 | meta: 39 | author = "unixfreaxjp" 40 | date = "2018-01-21" 41 | strings: 42 | $hex01 = { 0D C0 A0 E1 00 D8 2D E9 } 43 | $hex02 = { 3C 1C 00 06 27 9C 97 98 } 44 | $hex03 = { 94 21 EF 80 7C 08 02 A6 } 45 | $hex04 = { E6 2F 22 4F 76 91 18 3F } 46 | $hex05 = { 06 00 1C 3C 20 98 9C 27 } 47 | $hex06 = { 55 89 E5 81 EC ?? 10 00 } 48 | $hex07 = { 55 48 89 E5 48 81 EC 90 } 49 | $hex08 = { 6F 67 69 6E 00 } 50 | condition: 51 | 2 of them 52 | } 53 | 54 | private rule is__bot_Rebirth_gen3 { 55 | meta: 56 | author = "unixfreaxjp" 57 | date = "2018-01-21" 58 | strings: 59 | $bot01 = "MIRAITEST" fullword nocase wide ascii 60 | $bot02 = "TELNETTEST" fullword nocase wide ascii 61 | $bot03 = "UPDATE" fullword nocase wide ascii 62 | $bot04 = "PHONE" fullword nocase wide ascii 63 | $bot05 = "RANGE" fullword nocase wide ascii 64 | $bot06 = "KILLATTK" fullword nocase wide ascii 65 | $bot07 = "STD" fullword nocase wide ascii 66 | $bot08 = "BCM" fullword nocase wide ascii 67 | $bot09 = "NETIS" fullword nocase wide ascii 68 | $bot10 = "FASTLOAD" fullword nocase wide ascii 69 | condition: 70 | 6 of them 71 | } 72 | 73 | rule MALW_Rebirth_Vulcan_ELF { 74 | meta: 75 | description = "Detects Rebirth Vulcan variant a torlus NextGen MALW" 76 | description = "Just adjust or omit below two strings for next version they code :) @unixfreaxjp" 77 | date = "2018-01-21" 78 | strings: 79 | $spec01 = "vulcan.sh" fullword nocase wide ascii 80 | $spec02 = "Vulcan" fullword nocase wide ascii 81 | condition: 82 | all of them 83 | and is__elf 84 | and is__str_Rebirth_gen3 85 | and is__hex_Rebirth_gen3 86 | and is__bot_Rebirth_gen3 87 | and filesize < 300KB 88 | } 89 | -------------------------------------------------------------------------------- /rules/TinyShell_Backdoor.yara: -------------------------------------------------------------------------------- 1 | /* Source: https://github.com/Yara-Rules/rules/blob/3872244500f584491cde7c633f12f1f043a61c13/malware/MALW_TinyShell_Backdoor_gen.yar */ 2 | 3 | /* Description: 4 | Detects ELF or MachO tinyshell backdoor on static, dynamic binary form. 5 | It is commonly used as backdoor in Linux, FreeBSD or MacOSX operating systems. 6 | This rule by default is NOT designed to scan the CNC client side. 7 | Category: ELF or MachO, backdoor, hacktool, RAT, shell 8 | License: 9 | This Yara ruleset is under the GNU-GPLv2 license (http://www.gnu.org/licenses/gpl-2.0.html) 10 | Version 1-20180211, author:unixfreaxjp 11 | */ 12 | 13 | private rule is__elf { 14 | meta: 15 | author = "@mmorenog,@yararules" 16 | strings: 17 | $header = { 7F 45 4C 46 } 18 | condition: 19 | $header at 0 20 | } 21 | 22 | private rule is__osx 23 | { 24 | meta: 25 | date = "2018-02-12" 26 | author = "@unixfreaxjp" 27 | condition: 28 | uint32(0) == 0xfeedface or uint32(0) == 0xcafebabe 29 | or uint32(0) == 0xbebafeca or uint32(0) == 0xcefaedfe 30 | or uint32(0) == 0xfeedfacf or uint32(0) == 0xcffaedfe 31 | } 32 | 33 | private rule priv01 { 34 | meta: 35 | date = "2018-02-11" 36 | author = "@unixfreaxjp" 37 | strings: 38 | $vara01 = { 73 3A 70 3A 00 } 39 | $vara02 = "Usage: %s" fullword nocase wide ascii 40 | $vara03 = "[ -s secret ]" fullword nocase wide ascii 41 | $vara04 = "[ -p port ]" fullword nocase wide ascii 42 | condition: 43 | all of them 44 | } 45 | 46 | private rule priv03 { 47 | meta: 48 | date = "2018-02-10" 49 | author = "@unixfreaxjp" 50 | strings: 51 | $varb01 = { 41 57 41 56 41 55 41 54 55 53 0F B6 06 } 52 | $varb02 = { 48 C7 07 00 00 00 00 48 C7 47 08 00 00 } 53 | $vard01 = { 55 48 89 E5 41 57 41 56 41 55 41 54 53 } 54 | $vard02 = { 55 48 89 E5 48 C7 47 08 00 00 00 00 48 } 55 | // can be added 56 | condition: 57 | (2 of ($varb*)) or (2 of ($vard*)) 58 | } 59 | 60 | private rule priv04 { 61 | meta: 62 | date = "2018-02-11" 63 | author = "@unixfreaxjp" 64 | strings: 65 | $varb03 = { 89 DF E8 FB A4 FF FF 83 C3 01 81 FB 00 04 } 66 | $vard03 = { 66 89 05 7D 5E 00 00 } 67 | // can be added 68 | condition: 69 | 1 of them 70 | } 71 | 72 | private rule priv02 { 73 | meta: 74 | date = "2018-02-10" 75 | author = "@unixfreaxjp" 76 | strings: 77 | $vare01 = "socket" fullword nocase wide ascii 78 | $vare02 = "connect" fullword nocase wide ascii 79 | $vare03 = "alarm" fullword nocase wide ascii 80 | $vare04 = "dup2" fullword nocase wide ascii 81 | $vare05 = "execl" fullword nocase wide ascii 82 | $vare06 = "openpty" fullword nocase wide ascii 83 | $vare07 = "putenv" fullword nocase wide ascii 84 | $vare08 = "setsid" fullword nocase wide ascii 85 | $vare09 = "ttyname" fullword nocase wide ascii 86 | $vare00 = "waitpid" fullword nocase wide ascii 87 | $varc01 = "HISTFIL" fullword nocase wide ascii 88 | $varc02 = "TERML" fullword nocase wide ascii 89 | $varc03 = "/bin/sh" fullword nocase wide ascii 90 | condition: 91 | (5 of ($vare*) 92 | or (2 of ($varc*))) 93 | } 94 | 95 | rule MALW_TinyShell_backconnect_OSX { 96 | meta: 97 | date = "2018-02-10" 98 | author = "@unixfreaxjp" 99 | condition: 100 | is__osx 101 | and priv01 102 | and priv02 103 | and priv03 104 | and priv04 105 | and filesize < 100KB 106 | } 107 | 108 | rule MALW_TinyShell_backconnect_ELF { 109 | meta: 110 | date = "2018-02-10" 111 | author = "@unixfreaxjp" 112 | condition: 113 | is__elf 114 | and priv01 115 | and ((priv02) 116 | or ((priv03) 117 | or (priv04))) 118 | and filesize < 100KB 119 | } 120 | 121 | rule MALW_TinyShell_backconnect_Gen { 122 | meta: 123 | date = "2018-02-11" 124 | author = "@unixfreaxjp" 125 | condition: 126 | ((is__elf) or (is__osx)) 127 | and priv01 128 | and priv02 129 | and filesize < 100KB 130 | } 131 | 132 | rule MALW_TinyShell_backdoor_Gen { 133 | meta: 134 | date = "2018-02-11" 135 | author = "@unixfreaxjp" 136 | condition: 137 | ((is__elf) or (is__osx)) 138 | and priv01 139 | and filesize > 20KB 140 | } -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | github.com/aws/aws-sdk-go-v2 v1.6.0 h1:r20hdhm8wZmKkClREfacXrKfX0Y7/s0aOoeraFbf/sY= 2 | github.com/aws/aws-sdk-go-v2 v1.6.0/go.mod h1:tI4KhsR5VkzlUa2DZAdwx7wCAYGwkZZ1H31PYrBFx1w= 3 | github.com/aws/aws-sdk-go-v2/config v1.3.0 h1:0JAnp0WcsgKilFLiZEScUTKIvTKa2LkicadZADza+u0= 4 | github.com/aws/aws-sdk-go-v2/config v1.3.0/go.mod h1:lOxzHWDt/k7MMidA/K8DgXL4+ynnZYsDq65Qhs/l3dg= 5 | github.com/aws/aws-sdk-go-v2/credentials v1.2.1 h1:AqQ8PzWll1wegNUOfIKcbp/JspTbJl54gNonrO6VUsY= 6 | github.com/aws/aws-sdk-go-v2/credentials v1.2.1/go.mod h1:Rfvim1eZTC9W5s8YJyYYtl1KMk6e8fHv+wMRQGO4Ru0= 7 | github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.1.1 h1:w1ocBIhQkLgupEB3d0uOuBddqVYl0xpubz7HSTzWG8A= 8 | github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.1.1/go.mod h1:GTXAhrxHQOj9N+J5tYVjwt+rpRyy/42qLjlgw9pz1a0= 9 | github.com/aws/aws-sdk-go-v2/internal/ini v1.0.0 h1:k7I9E6tyVWBo7H9ffpnxDWudtjau6Qt9rnOYgV+ciEQ= 10 | github.com/aws/aws-sdk-go-v2/internal/ini v1.0.0/go.mod h1:g3XMXuxvqSMUjnsXXp/960152w0wFS4CXVYgQaSVOHE= 11 | github.com/aws/aws-sdk-go-v2/service/ec2 v1.7.1 h1:2I6fU3pLkiGOrSRCn8lcftG9Xw57ucxXzf+rOLTR6PY= 12 | github.com/aws/aws-sdk-go-v2/service/ec2 v1.7.1/go.mod h1:XzzkrryeCoPUd9jxcdDnI2/UmlfIp13nBSpjl2SDSCM= 13 | github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.1.0 h1:XwqxIO9LtNXznBbEMNGumtLN60k4nVqDpVwVWx3XU/o= 14 | github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.1.0/go.mod h1:zdjOOy0ojUn3iNELo6ycIHSMCp4xUbycSHfb8PnbbyM= 15 | github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.1.1 h1:l7pDLsmOGrnR8LT+3gIv8NlHpUhs7220E457KEC2UM0= 16 | github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.1.1/go.mod h1:2+ehJPkdIdl46VCj67Emz/EH2hpebHZtaLdzqg+sWOI= 17 | github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.3.1 h1:VH1Y4k+IZ5kcRVqSNw7eAkXyfS7k2/ibKjrNtbhYhV4= 18 | github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.3.1/go.mod h1:IpjxfORBAFfkMM0VEx5gPPnEy6WV4Hk0F/+zb/SUWyw= 19 | github.com/aws/aws-sdk-go-v2/service/s3 v1.9.0 h1:FZ5UL5aiybSJKiJglPT7YMMwc431IgOX5gvlFAzSjzs= 20 | github.com/aws/aws-sdk-go-v2/service/s3 v1.9.0/go.mod h1:zHCjYoODbYRLz/iFicYswq1gRoxBnHvpY5h2Vg3/tJ4= 21 | github.com/aws/aws-sdk-go-v2/service/sso v1.2.1 h1:alpXc5UG7al7QnttHe/9hfvUfitV8r3w0onPpPkGzi0= 22 | github.com/aws/aws-sdk-go-v2/service/sso v1.2.1/go.mod h1:VimPFPltQ/920i1X0Sb0VJBROLIHkDg2MNP10D46OGs= 23 | github.com/aws/aws-sdk-go-v2/service/sts v1.4.1 h1:9Z00tExoaLutWVDmY6LyvIAcKjHetkbdmpRt4JN/FN0= 24 | github.com/aws/aws-sdk-go-v2/service/sts v1.4.1/go.mod h1:G9osDWA52WQ38BDcj65VY1cNmcAQXAXTsE8IWH8j81w= 25 | github.com/aws/smithy-go v1.4.0 h1:3rsQpgRe+OoQgJhEwGNpIkosl0fJLdmQqF4gSFRjg+4= 26 | github.com/aws/smithy-go v1.4.0/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAmR5n+E= 27 | github.com/capsule8/go-yara v1.1.10-0.20210523225711-dafe562e8c6e h1:jKNpfCay8qZh0DQ2ZGvKg0ycnVtmcIAUSHUGuETdGQI= 28 | github.com/capsule8/go-yara v1.1.10-0.20210523225711-dafe562e8c6e/go.mod h1:1V9YJD3e2pMs5UnKmADWw3tQgzaGRIZ60dIRPQT8EZY= 29 | github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= 30 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 31 | github.com/google/go-cmp v0.5.4 h1:L8R9j+yAqZuZjsqh/z+F1NCffTKKLShY6zXTItVIZ8M= 32 | github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 33 | github.com/hillu/go-yara/v4 v4.0.6 h1:2fHGPatCXQL1RgWWvPJDdaCkXAzvMx8SpVtKpqVMHDo= 34 | github.com/hillu/go-yara/v4 v4.0.6/go.mod h1:rkb/gSAoO8qcmj+pv6fDZN4tOa3N7R+qqGlEkzT4iys= 35 | github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= 36 | github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= 37 | github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= 38 | github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= 39 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 40 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 41 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 42 | golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= 43 | golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 44 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 45 | gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= 46 | gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 47 | -------------------------------------------------------------------------------- /rules/WatchDog_Malware.yara: -------------------------------------------------------------------------------- 1 | /* Source: https://github.com/deadbits/yara-rules/blob/master/rules/WatchBog_Linux.yara */ 2 | 3 | rule WatchDog_Botnet: botnet linuxmalware exploitation cve_2019_11581 cve_2019_10149 4 | { 5 | meta: 6 | 7 | Author = "Adam M. Swanda" 8 | Website = "https://www.deadbits.org" 9 | Repo = "https://github.com/deadbits/yara-rules" 10 | Date = "2019-07-22" 11 | Reference = "https://twitter.com/polarply/status/1153232987762376704" 12 | 13 | strings: 14 | 15 | // $email = "jeff4r@watchbog.com" 16 | $py0 = "libpython" ascii 17 | //$py1 = "jail.py" ascii fullword 18 | 19 | //$rcpt1 = "RCPT TO:<${run{\x2Fbin\x2Fsh\t-c\t\x22bash\x20\x2Ftmp\x2Fbaby\x22}}@localhost>" ascii fullword 20 | //$rcpt2 = /RCPT TO:<\$\{run\{\\x2Fbin\\x2Fsh\\t-c\\t\\x22curl\\x20https\\x3a\\x2F\\x2Fpastebin.com\\x2Fraw/ 21 | 22 | $str0 = "*/3 * * * * root wget -q -O- https://pastebin.com/raw/" ascii 23 | $str1 = "*/1 * * * * root curl -fsSL https://pastebin.com/raw/" ascii 24 | $str6 = "onion.to" 25 | $str7 = /https?:\/\/pastebin.com\/raw/ nocase 26 | $str8 = "http://icanhazip.com/" 27 | $str9 = "http://ident.me/" 28 | 29 | $scan0 = "Scan_run" 30 | $scan1 = "scan_nexus" 31 | $scan2 = "scan_couchdb" 32 | $scan3 = "scan_jenkins" 33 | $scan4 = "scan_laravel" 34 | $scan5 = "scan_redis" 35 | 36 | $exploit01 = "CVE_2015_4335" 37 | $exploit02 = "CVE_2018_1000861" 38 | $exploit03 = "CVE_2018_8007" 39 | $exploit04 = "CVE_2019_1014" 40 | $exploit05 = "CVE_2019_11581" 41 | $exploit06 = "CVE_2019_7238" 42 | 43 | $pwn0 = "pwn_couchdb" 44 | $pwn1 = "pwn_jenkins" 45 | $pwn2 = "pwn_jira" 46 | $pwn3 = "pwn_nexus" 47 | $pwn4 = "pwn_redis" 48 | $pwn5 = "pwn_exim" 49 | 50 | $payload = /payload(s)/ nocase 51 | $jira_token = "atlassian.xsrf.token=%s" ascii fullword 52 | $jira_cmd = "set ($cmd=\"%s\")" ascii fullword 53 | $jira_id = "JSESSIONID=%s" ascii fullword 54 | 55 | /* 56 | dont know if i really want to add these 57 | 58 | $user_agent00 = "Mozilla_4_0_compatible_MSIE_6_0" 59 | $user_agent00 = "Mozilla_4_0_compatible_MSIE_6_0_2" 60 | $user_agent00 = "Mozilla_4_0_compatible_MSIE_6_0_3" 61 | $user_agent00 = "Mozilla_4_0_compatible_MSIE_7_0" 62 | $user_agent00 = "Mozilla_4_0_compatible_MSIE_7_0_2" 63 | $user_agent00 = "Mozilla_4_0_compatible_MSIE_7_0_3" 64 | $user_agent00 = "Mozilla_4_0_compatible_MSIE_7_0_4" 65 | $user_agent00 = "Mozilla_4_0_compatible_MSIE_7_0b" 66 | $user_agent00 = "Mozilla_5_0_Macintosh_Intel_Mac" 67 | $user_agent00 = "Mozilla_5_0_Windows_NT_5_1_Apple" 68 | $user_agent00 = "Mozilla_5_0_Windows_NT_6_1_WOW64" 69 | $user_agent00 = "Mozilla_5_0_Windows_NT_6_1_WOW64_2" 70 | $user_agent00 = "Mozilla_5_0_Windows_NT_6_1_WOW64_3" 71 | $user_agent00 = "Mozilla_5_0_Windows_NT_6_1_WOW64_4" 72 | $user_agent00 = "Mozilla_5_0_Windows_NT_6_1_WOW64_5" 73 | $user_agent00 = "Mozilla_5_0_Windows_NT_6_1_WOW64_6" 74 | $user_agent00 = "Mozilla_5_0_Windows_NT_6_1_Win64" 75 | $user_agent00 = "Mozilla_5_0_Windows_U_MSIE_9_0_W" 76 | $user_agent00 = "Mozilla_5_0_Windows_U_Windows_NT" 77 | $user_agent00 = "Mozilla_5_0_Windows_U_Windows_NT_2" 78 | $user_agent00 = "Mozilla_5_0_Windows_U_Windows_NT_3" 79 | $user_agent00 = "Mozilla_5_0_X11_Linux_i686_U_Gec" 80 | $user_agent00 = "Mozilla_5_0_X11_U_Linux_en_US_Ap" 81 | $user_agent00 = "Mozilla_5_0_X11_U_Linux_i686_en" 82 | $user_agent00 = "Mozilla_5_0_X11_U_Linux_x86_64_z" 83 | $user_agent00 = "Mozilla_5_0_X11_Ubuntu_Linux_x86" 84 | $user_agent00 = "Mozilla_5_0_compatible_MSIE_8_0" 85 | $user_agent00 = "Mozilla_5_0_compatible_MSIE_9_0" 86 | $user_agent00 = "Mozilla_5_0_compatible_MSIE_9_0_2" 87 | $user_agent00 = "Mozilla_5_0_compatible_MSIE_9_0_3" 88 | $user_agent00 = "Mozilla_5_0_iPad_U_CPU_OS_4_2_1" 89 | */ 90 | 91 | condition: 92 | uint32be(0x0) == 0x7f454c46 93 | and $py0 94 | and 95 | ( 96 | (all of ($pwn*) and all of ($scan*)) 97 | or 98 | ($payload and all of ($jira*) and 5 of ($str*)) 99 | or 100 | (all of ($str*) and all of ($exploit*)) 101 | ) 102 | } 103 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 |

4 | 5 |

Patrolaroid

6 | 7 |
8 | 9 | Patrolaroid is an instant camera for capturing cloud workload risks. It’s a prod-friendly scanner that makes finding security issues in AWS instances and buckets less annoying and disruptive for software engineers and cloud admins. 10 | 11 | Patrolaroid scans production infrastructure from a safe distance rather than within production, so you don’t have to install an agent, run code, or perform other invasive infosec rituals to use it. 12 | 13 | ## Overview 14 | Patrolaroid snapshots AWS instances and buckets to uncover malware, backdoors, cryptominers, toolkits, and other attacker tomfoolery that you probably don’t want in your prod. Software engineers, security engineers, and cloud administrators only need familiarity with YARA and the AWS Management Console to use it. 15 | 16 | Patrolaroid does not require running an agent or code in prod, only needs read-only access to cloud assets, and generally avoids the myriad stability and performance sins of security tools. 17 | 18 | ## Why? 19 | ### The tired way 20 | Most commercial “cloud security” scanners that aim to detect malware in cloud workloads ironically operate pretty similarly to malware. Their mode of operation is: 21 | 1. Just-in-time installation of an agent via SSH 22 | 2. Running the agent from `/tmp` 23 | 3. Deleting themselves once the scan completes 24 | 25 | This results in the security agent stealing compute cycles and I/O from the host it’s scanning, which is veritably unstonkly – as is the chance that prod is borked if the agent screws up. 26 | 27 | ### The inspired way 28 | Patrolaroid avoids these problems by scanning prod instances and buckets for security problems while staying safely out of prod. After the engineer or admin identifies the AWS account containing the resources they want to scan, Patrolaroid then: 29 | 1. Runs from an AWS instance within the same account as the target instances or buckets 30 | 2. Snapshots each instance 31 | 3. Uses [YARA rules](https://github.com/rpetrich/patrolaroid/tree/main/rules) to scan the instance’s filesystem for matches (and generates an alert if there is a match) 32 | 4. Deletes the snapshot volume 33 | 34 | In short, Patrolaroid provides "point-and-shoot" malware scanning of AWS assets without the malware-like tactics of existing “cloud security” tools. 35 | 36 | 37 | # Getting Started with Patrolaroid 38 | 39 | All you need is an AWS account and the ability to create an AWS role and EC2 instance to get Patrolaroid up and running. Getting started involves creating a dedicated EC2 instance for Patrolaroid in the same AWS account and availability zones as the assets you want to scan. 40 | 41 | ## Step 1: Create an AWS role 42 | :cloud: Make sure to use the account and availability zone you want to scan to create the role :cloud: 43 | 1. Log into your AWS account and access the Identity and Access Management (IAM) service in the AWS Management Console, then choose [**Create Role**](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-service.html) (you can also use the AWS CLI if you prefer) 44 | 2. Select **AWS service** for type of trusted entity 45 | 3. Select **EC2** as the allowed service and use case, then choose **Next: Permissions** 46 | 4. Select the [**AmazonEC2FullAccess**](https://console.aws.amazon.com/iam/home?region=us-east-1#/policies/arn%3Aaws%3Aiam%3A%3Aaws%3Apolicy%2FAmazonEC2FullAccess) and[**AmazonS3FullAccess**](https://console.aws.amazon.com/iam/home?region=us-east-1#/policies/arn%3Aaws%3Aiam%3A%3Aaws%3Apolicy%2FAmazonS3FullAccess) policies or paste [our recommended policy](https://github.com/rpetrich/patrolaroid/tree/main/docs/recommended-iam-policy.md) (with tighter permissions) into [the JSON editor](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_create-console.html#access_policies_create-json-editor), then choose **Next: Tags** 47 | 5. No tags are needed, so select **Next: Review** 48 | 6. Type **Patrolaroid** for the **Role name** 49 | 7. Review the role and, if satisfied, choose **Create role** 50 | 51 | ## Step 2: Create an EC2 instance 52 | :cloud: Make sure you’re still logged into the account you want to scan before proceeding :cloud: 53 | 1. Open the [AWS EC2 console](https://console.aws.amazon.com/ec2/), then choose **Launch instance** 54 | 2. On the Step 1: Choose an Amazon Machine Image (AMI) page, select **Ubuntu Server 20.04 LTS (HVM), SSD Volume Type** 55 | 3. On the Step 2: Choose an Instance Type page, select the **t2.micro** type, then click **Next: Configure Instance Details** 56 | 4. For IAM role, select the **Patrolaroid** role you created 57 | 5. Click **Review and Launch** 58 | 59 | ## Step 3: Install dependencies 60 | 1. [Connect to your new EC2 instance via SSH](https://docs.aws.amazon.com/quickstarts/latest/vmlaunch/step-2-connect-to-instance.html) (or PuTTY if using Windows) 61 | 2. Install `curl` by running the command: 62 | ``` 63 | sudo apt-get install curl 64 | ``` 65 | 66 | ## Step 4: Install Patrolaroid 67 | Ensure you are connected to your dedicated EC2 instance and then download Patrolaroid to it by running: 68 | ``` 69 | curl -L https://github.com/rpetrich/patrolaroid/releases/download/v0.3/patrolaroid.tar.gz | tar xz 70 | ``` 71 | 72 | ## Step 5: Run Patrolaroid 73 | Start scanning by running Patrolaroid via `sudo`: 74 | ``` 75 | sudo ./patrolaroid 76 | ``` 77 | Enjoy your :cloud: :lock: :camera: :black_heart: 78 | -------------------------------------------------------------------------------- /rules/Misc_Malware.yara: -------------------------------------------------------------------------------- 1 | /* Source: https://github.com/Yara-Rules/rules/blob/3872244500f584491cde7c633f12f1f043a61c13/malware/MALW_Miscelanea_Linux.yar /* 2 | 3 | /* 4 | This Yara ruleset is under the GNU-GPLv2 license (http://www.gnu.org/licenses/gpl-2.0.html) and open to any user or organization, as long as you use it under this license. 5 | 6 | */ 7 | 8 | import "pe" 9 | 10 | 11 | rule LinuxAESDDoS 12 | { 13 | meta: 14 | Author = "@benkow_" 15 | Date = "2014/09/12" 16 | Description = "Strings inside" 17 | Reference = "http://www.kernelmode.info/forum/viewtopic.php?f=16&t=3483" 18 | 19 | strings: 20 | $a = "3AES" 21 | $b = "Hacker" 22 | $c = "VERSONEX" 23 | 24 | condition: 25 | 2 of them 26 | } 27 | 28 | rule LinuxBillGates 29 | { 30 | meta: 31 | Author = "@benkow_" 32 | Date = "2014/08/11" 33 | Description = "Strings inside" 34 | Reference = "http://www.kernelmode.info/forum/viewtopic.php?f=16&t=3429" 35 | 36 | strings: 37 | $a= "12CUpdateGates" 38 | $b= "11CUpdateBill" 39 | 40 | condition: 41 | $a and $b 42 | } 43 | 44 | rule LinuxElknot 45 | { 46 | meta: 47 | Author = "@benkow_" 48 | Date = "2013/12/24" 49 | Description = "Strings inside" 50 | Reference = "http://www.kernelmode.info/forum/viewtopic.php?f=16&t=3099" 51 | 52 | strings: 53 | $a = "ZN8CUtility7DeCryptEPciPKci" 54 | $b = "ZN13CThreadAttack5StartEP11CCmdMessage" 55 | 56 | condition: 57 | all of them 58 | } 59 | 60 | rule LinuxMrBlack 61 | { 62 | meta: 63 | Author = "@benkow_" 64 | Date = "2014/09/12" 65 | Description = "Strings inside" 66 | Reference = "http://www.kernelmode.info/forum/viewtopic.php?f=16&t=3483" 67 | 68 | strings: 69 | $a = "Mr.Black" 70 | $b = "VERS0NEX:%s|%d|%d|%s" 71 | condition: 72 | $a and $b 73 | } 74 | 75 | rule LinuxTsunami 76 | { 77 | meta: 78 | 79 | Author = "@benkow_" 80 | Date = "2014/09/12" 81 | Description = "Strings inside" 82 | Reference = "http://www.kernelmode.info/forum/viewtopic.php?f=16&t=3483" 83 | 84 | strings: 85 | $a = "PRIVMSG %s :[STD]Hitting %s" 86 | $b = "NOTICE %s :TSUNAMI " 87 | $c = "NOTICE %s :I'm having a problem resolving my host, someone will have to SPOOFS me manually." 88 | condition: 89 | $a or $b or $c 90 | } 91 | 92 | /* Disabling rootkit rule, since it fires on System.maps which are likely to be on linux filesystems 93 | 94 | rule rootkit 95 | { 96 | meta: 97 | author="xorseed" 98 | reference= "https://stuff.rop.io/" 99 | strings: 100 | $sys1 = "sys_write" nocase ascii wide 101 | $sys2 = "sys_getdents" nocase ascii wide 102 | $sys3 = "sys_getdents64" nocase ascii wide 103 | $sys4 = "sys_getpgid" nocase ascii wide 104 | $sys5 = "sys_getsid" nocase ascii wide 105 | $sys6 = "sys_setpgid" nocase ascii wide 106 | $sys7 = "sys_kill" nocase ascii wide 107 | $sys8 = "sys_tgkill" nocase ascii wide 108 | $sys9 = "sys_tkill" nocase ascii wide 109 | $sys10 = "sys_sched_setscheduler" nocase ascii wide 110 | $sys11 = "sys_sched_setparam" nocase ascii wide 111 | $sys12 = "sys_sched_getscheduler" nocase ascii wide 112 | $sys13 = "sys_sched_getparam" nocase ascii wide 113 | $sys14 = "sys_sched_setaffinity" nocase ascii wide 114 | $sys15 = "sys_sched_getaffinity" nocase ascii wide 115 | $sys16 = "sys_sched_rr_get_interval" nocase ascii wide 116 | $sys17 = "sys_wait4" nocase ascii wide 117 | $sys18 = "sys_waitid" nocase ascii wide 118 | $sys19 = "sys_rt_tgsigqueueinfo" nocase ascii wide 119 | $sys20 = "sys_rt_sigqueueinfo" nocase ascii wide 120 | $sys21 = "sys_prlimit64" nocase ascii wide 121 | $sys22 = "sys_ptrace" nocase ascii wide 122 | $sys23 = "sys_migrate_pages" nocase ascii wide 123 | $sys24 = "sys_move_pages" nocase ascii wide 124 | $sys25 = "sys_get_robust_list" nocase ascii wide 125 | $sys26 = "sys_perf_event_open" nocase ascii wide 126 | $sys27 = "sys_uname" nocase ascii wide 127 | $sys28 = "sys_unlink" nocase ascii wide 128 | $sys29 = "sys_unlikat" nocase ascii wide 129 | $sys30 = "sys_rename" nocase ascii wide 130 | $sys31 = "sys_read" nocase ascii wide 131 | $sys32 = "kobject_del" nocase ascii wide 132 | $sys33 = "list_del_init" nocase ascii wide 133 | $sys34 = "inet_ioctl" nocase ascii wide 134 | condition: 135 | 9 of them 136 | } 137 | 138 | */ 139 | 140 | rule exploit 141 | { 142 | meta: 143 | author="xorseed" 144 | reference= "https://stuff.rop.io/" 145 | strings: 146 | $xpl1 = "set_fs_root" nocase ascii wide 147 | $xpl2 = "set_fs_pwd" nocase ascii wide 148 | $xpl3 = "__virt_addr_valid" nocase ascii wide 149 | $xpl4 = "init_task" nocase ascii wide 150 | $xpl5 = "init_fs" nocase ascii wide 151 | $xpl6 = "bad_file_ops" nocase ascii wide 152 | $xpl7 = "bad_file_aio_read" nocase ascii wide 153 | $xpl8 = "security_ops" nocase ascii wide 154 | $xpl9 = "default_security_ops" nocase ascii wide 155 | $xpl10 = "audit_enabled" nocase ascii wide 156 | $xpl11 = "commit_creds" nocase ascii wide 157 | $xpl12 = "prepare_kernel_cred" nocase ascii wide 158 | $xpl13 = "ptmx_fops" nocase ascii wide 159 | $xpl14 = "node_states" nocase ascii wide 160 | condition: 161 | 7 of them 162 | } 163 | 164 | -------------------------------------------------------------------------------- /rules/LuckyJoe_Ransomware.yara: -------------------------------------------------------------------------------- 1 | /* Source: https://github.com/reversinglabs/reversinglabs-yara-rules/blob/5147a2978cc942b1d514a368e9a8245e95483872/yara/ransomware/Linux.Ransomware.LuckyJoe.yara */ 2 | 3 | rule Linux_Ransomware_LuckyJoe : tc_detection malicious 4 | { 5 | meta: 6 | 7 | author = "ReversingLabs" 8 | 9 | source = "ReversingLabs" 10 | status = "RELEASED" 11 | sharing = "TLP:WHITE" 12 | category = "MALWARE" 13 | malware = "LUCKYJOE" 14 | description = "Yara rule that detects LuckyJoe ransomware." 15 | 16 | tc_detection_type = "Ransomware" 17 | tc_detection_name = "LuckyJoe" 18 | tc_detection_factor = 5 19 | 20 | strings: 21 | 22 | $main_call_p1 = { 23 | 55 48 89 E5 48 81 EC ?? ?? ?? ?? 48 C7 45 ?? ?? ?? ?? ?? 48 C7 45 ?? ?? ?? ?? ?? 48 24 | C7 45 ?? ?? ?? ?? ?? 48 C7 45 ?? ?? ?? ?? ?? E8 ?? ?? ?? ?? 48 89 C7 E8 ?? ?? ?? ?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8B 45 ?? 48 89 C7 E8 ?? ?? ?? ?? 48 89 45 ?? 48 83 7D ?? ?? 0F 99 | 85 ?? ?? ?? ?? 48 8B 45 ?? 48 89 C7 E8 ?? ?? ?? ?? 48 81 C4 ?? ?? ?? ?? 5B 5D C3 100 | } 101 | 102 | $encrypt_internal_message_p1 = { 103 | 55 48 89 E5 53 48 83 EC ?? 48 89 7D ?? 48 89 75 ?? 48 C7 45 ?? ?? ?? ?? ?? BF ?? ?? 104 | ?? ?? E8 ?? ?? ?? ?? 48 89 45 ?? 48 8B 45 ?? 48 89 C7 E8 ?? ?? ?? ?? 89 45 ?? 48 8B 105 | 45 ?? 48 89 C7 E8 ?? ?? ?? ?? 89 45 ?? 8B 45 ?? 83 C0 ?? 48 98 48 89 C7 E8 ?? ?? ?? 106 | ?? 48 89 45 ?? 8B 45 ?? 83 C0 ?? 48 63 D0 48 8B 45 ?? BE ?? ?? ?? ?? 48 89 C7 E8 ?? 107 | ?? ?? ?? 8B 45 ?? 48 63 D0 48 8B 4D ?? 48 8B 45 ?? 48 89 CE 48 89 C7 E8 ?? ?? ?? ?? 108 | 8B 45 ?? 48 98 48 89 C7 E8 ?? ?? ?? ?? 48 89 45 ?? C7 45 ?? ?? ?? ?? ?? C7 45 ?? ?? 109 | ?? ?? ?? 8B 45 ?? 83 E8 ?? 89 45 ?? C7 45 ?? ?? ?? ?? ?? 66 0F EF C0 F2 0F 2A 45 ?? 110 | 66 0F EF C9 F2 0F 2A 4D ?? F2 0F 5E C1 E8 ?? ?? ?? ?? F2 0F 2C C0 89 45 ?? 8B 45 ?? 111 | 0F AF 45 ?? 48 98 48 89 C7 E8 ?? ?? ?? ?? 48 89 45 ?? 8B 45 ?? 0F AF 45 ?? 48 63 D0 112 | 48 8B 45 ?? BE ?? ?? ?? ?? 48 89 C7 E8 ?? ?? ?? ?? 8B 45 ?? 0F AF 45 ?? 89 C3 48 8B 113 | 45 ?? 48 89 C7 E8 ?? ?? ?? ?? 48 89 C6 8B 45 ?? 89 C1 89 DA BF ?? ?? ?? ?? B8 ?? ?? 114 | ?? ?? E8 ?? ?? ?? ?? C7 45 ?? ?? ?? ?? ?? 48 C7 45 ?? ?? ?? ?? ?? C7 45 ?? ?? ?? ?? 115 | ?? E9 ?? ?? ?? ?? 8B 45 ?? 2B 45 ?? 3B 45 ?? 7D ?? 8B 45 ?? 2B 45 ?? 89 45 ?? 8B 45 116 | ?? 48 63 D0 48 8B 45 ?? BE ?? ?? ?? ?? 48 89 C7 E8 ?? ?? ?? ?? 8B 45 ?? 2B 45 ?? 89 117 | } 118 | 119 | $encrypt_internal_message_p2 = { 120 | C6 BF ?? ?? ?? ?? B8 ?? ?? ?? ?? E8 ?? ?? ?? ?? 8B 45 ?? 48 63 D0 48 8B 45 ?? 48 8D 121 | 34 02 48 8B 4D ?? 48 8B 55 ?? 8B 45 ?? 41 B8 ?? ?? ?? ?? 89 C7 E8 ?? ?? ?? ?? 89 45 122 | ?? 8B 45 ?? 89 C6 BF ?? ?? ?? ?? B8 ?? ?? ?? ?? E8 ?? ?? ?? ?? 83 7D ?? ?? 75 ?? E8 123 | ?? ?? ?? ?? E8 ?? ?? ?? ?? 48 89 C2 48 8B 45 ?? 48 89 C6 48 89 D7 E8 ?? ?? ?? ?? 48 124 | 8B 05 ?? ?? ?? ?? 48 8B 55 ?? BE ?? ?? ?? ?? 48 89 C7 B8 ?? ?? ?? ?? E8 ?? ?? ?? ?? 125 | 48 8B 45 ?? 48 89 C7 E8 ?? ?? ?? ?? 48 8B 45 ?? 48 89 C7 E8 ?? ?? ?? ?? 48 8B 45 ?? 126 | 48 89 C7 E8 ?? ?? ?? ?? 48 8B 45 ?? 48 89 C7 E8 ?? ?? ?? ?? B8 ?? ?? ?? ?? E9 ?? ?? 127 | ?? ?? 8B 45 ?? 48 63 D0 8B 45 ?? 48 63 C8 48 8B 45 ?? 48 01 C1 48 8B 45 ?? 48 89 C6 128 | 48 89 CF E8 ?? ?? ?? ?? 48 8B 45 ?? 48 89 C7 E8 ?? ?? ?? ?? 48 89 C6 BF ?? ?? ?? ?? 129 | B8 ?? ?? ?? ?? E8 ?? ?? ?? ?? 8B 45 ?? 01 45 ?? 8B 45 ?? 01 45 ?? 48 8B 45 ?? 48 89 130 | C7 E8 ?? ?? ?? ?? 83 45 ?? ?? 8B 45 ?? 3B 45 ?? 0F 8E ?? ?? ?? ?? 48 8B 45 ?? 48 89 131 | C7 E8 ?? ?? ?? ?? 48 8B 45 ?? 48 89 C7 E8 ?? ?? ?? ?? 8B 4D ?? 48 8B 45 ?? BA ?? ?? 132 | ?? ?? 89 CE 48 89 C7 E8 ?? ?? ?? ?? 48 89 45 ?? 48 8B 45 ?? 48 89 C7 E8 ?? ?? ?? ?? 133 | 48 89 C6 BF ?? ?? ?? ?? B8 ?? ?? ?? ?? E8 ?? ?? ?? ?? 48 8B 45 ?? 48 83 C4 ?? 5B 5D 134 | C3 135 | } 136 | 137 | condition: 138 | uint32(0) == 0x464C457F and 139 | ( 140 | all of ($main_call_p*) 141 | ) and 142 | ( 143 | all of ($encrypt_files_p*) 144 | ) and 145 | ( 146 | all of ($encrypt_internal_message_p*) 147 | ) 148 | } -------------------------------------------------------------------------------- /rules/KillDisk_Ransomware.yara: -------------------------------------------------------------------------------- 1 | /* Source: https://github.com/reversinglabs/reversinglabs-yara-rules/blob/5147a2978cc942b1d514a368e9a8245e95483872/yara/ransomware/Linux.Ransomware.KillDisk.yara */ 2 | 3 | rule Linux_Ransomware_KillDisk : tc_detection malicious 4 | { 5 | meta: 6 | 7 | author = "ReversingLabs" 8 | 9 | source = "ReversingLabs" 10 | status = "RELEASED" 11 | sharing = "TLP:WHITE" 12 | category = "MALWARE" 13 | malware = "KILLDISK" 14 | description = "Yara rule that detects KillDisk ransomware." 15 | 16 | tc_detection_type = "Ransomware" 17 | tc_detection_name = "KillDisk" 18 | tc_detection_factor = 5 19 | 20 | strings: 21 | 22 | $encrypt_files_1 = { 23 | 55 48 89 E5 48 81 EC ?? ?? ?? ?? 48 89 B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?? ?? 74 ?? E8 ?? ?? ?? ?? C9 C3 137 | } 138 | 139 | condition: 140 | uint32(0) == 0x464C457F and 141 | ( 142 | $search_files and 143 | (all of ($encrypt_files_*)) and 144 | (all of ($subvert_grub_*)) 145 | ) 146 | } -------------------------------------------------------------------------------- /rules/Kraken_Ransomware.yara: -------------------------------------------------------------------------------- 1 | /* Source: https://github.com/reversinglabs/reversinglabs-yara-rules/blob/5147a2978cc942b1d514a368e9a8245e95483872/yara/ransomware/Win32.Ransomware.Kraken.yara */ 2 | 3 | rule Linux_Ransomware_Kraken : tc_detection malicious 4 | { 5 | meta: 6 | 7 | author = "ReversingLabs" 8 | 9 | source = "ReversingLabs" 10 | status = "RELEASED" 11 | sharing = "TLP:WHITE" 12 | category = "MALWARE" 13 | malware = "KRAKEN" 14 | description = "Yara rule that detects Kraken ransomware." 15 | 16 | tc_detection_type = "Ransomware" 17 | tc_detection_name = "Kraken" 18 | tc_detection_factor = 5 19 | 20 | strings: 21 | 22 | $enum_volumes = { 23 | 55 8B EC 6A ?? 68 ?? ?? ?? ?? 64 A1 ?? ?? ?? ?? ?? ?? ?? ?? 04 ?? 00 A1 ?? ?? ?? ?? 24 | 33 C5 89 45 ?? 53 56 57 50 8D 45 ?? 64 A3 ?? ?? ?? ?? ?? ?? ?? ?? 50 45 4C 00 C7 45 25 | FC 00 00 00 00 B9 ?? ?? ?? ?? E8 ?? ?? ?? ?? 50 E8 ?? ?? ?? ?? 83 C4 ?? 8D 85 ?? ?? 26 | ?? ?? 50 68 ?? ?? ?? ?? FF 15 ?? ?? ?? ?? 8D B5 ?? ?? ?? ?? 0F 1F 84 00 ?? ?? ?? ?? 27 | 8A 06 84 C0 0F 84 ?? ?? ?? ?? 3C ?? 0F 84 ?? ?? ?? ?? BA ?? ?? ?? ?? B9 ?? ?? ?? ?? 28 | E8 ?? ?? ?? ?? 8B D6 8B C8 E8 ?? ?? ?? ?? 50 E8 ?? ?? ?? ?? 83 C4 ?? 83 EC ?? 8B D4 29 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?? ?? 6A ?? 53 FF 130 | 15 ?? ?? ?? ?? E8 ?? ?? ?? ?? 99 6A ?? 8B F0 8B FA 8D 45 ?? 50 FF 75 ?? FF 35 ?? ?? 131 | ?? ?? 53 FF 15 ?? ?? ?? ?? E8 ?? ?? ?? ?? 99 2B C6 53 1B D7 01 05 ?? ?? ?? ?? 11 15 132 | ?? ?? ?? ?? FF 15 ?? ?? ?? ?? 51 8D 55 ?? 8D 4D ?? E8 ?? ?? ?? ?? 8B C8 83 C4 ?? 83 133 | 79 ?? ?? 72 ?? 8B 09 83 7D ?? ?? 8D 45 ?? 51 0F 43 45 ?? 50 FF 15 ?? ?? ?? ?? 8D 4D 134 | ?? E8 ?? ?? ?? ?? 83 05 ?? ?? ?? ?? ?? 83 15 ?? ?? ?? ?? ?? EB ?? 53 FF 15 ?? ?? ?? 135 | ?? 8D 4D ?? E8 ?? ?? ?? ?? 8D 4D ?? E8 ?? ?? ?? ?? 8D 4D ?? E8 ?? ?? ?? ?? 8B 4D ?? 136 | 64 89 0D ?? ?? ?? ?? 59 5F 5E 5B 8B 4D ?? 33 CD E8 ?? ?? ?? ?? 8B E5 5D C3 137 | } 138 | 139 | 140 | condition: 141 | uint16(0) == 0x5A4D and 142 | ( 143 | $enum_volumes and 144 | $find_files and 145 | ( 146 | all of ($enum_shares_p*) 147 | ) and 148 | ( 149 | all of ($encrypt_files_p*) 150 | ) 151 | ) 152 | 153 | } -------------------------------------------------------------------------------- /rules/Derubsi_Malware.yara: -------------------------------------------------------------------------------- 1 | /* Source: https://github.com/Yara-Rules/rules/blob/3872244500f584491cde7c633f12f1f043a61c13/malware/APT_Derusbi.yar */ 2 | 3 | /* 4 | This Yara ruleset is under the GNU-GPLv2 license (http://www.gnu.org/licenses/gpl-2.0.html) and open to any user or organization, as long as you use it under this license. 5 | 6 | */ 7 | 8 | rule apt_nix_elf_derusbi 9 | { 10 | 11 | meta: 12 | Author = "@seifreed" 13 | 14 | strings: 15 | $ = "LxMain" 16 | $ = "execve" 17 | $ = "kill" 18 | $ = "cp -a %s %s" 19 | $ = "%s &" 20 | $ = "dbus-daemon" 21 | $ = "--noprofile" 22 | $ = "--norc" 23 | $ = "TERM=vt100" 24 | $ = "/proc/%u/cmdline" 25 | $ = "loadso" 26 | $ = "/proc/self/exe" 27 | $ = "Proxy-Connection: Keep-Alive" 28 | $ = "Connection: Keep-Alive" 29 | $ = "CONNECT %s" 30 | $ = "HOST: %s:%d" 31 | $ = "User-Agent: Mozilla/4.0" 32 | $ = "Proxy-Authorization: Basic %s" 33 | $ = "Server: Apache" 34 | $ = "Proxy-Authenticate" 35 | $ = "gettimeofday" 36 | $ = "pthread_create" 37 | $ = "pthread_join" 38 | $ = "pthread_mutex_init" 39 | $ = "pthread_mutex_destroy" 40 | $ = "pthread_mutex_lock" 41 | $ = "getsockopt" 42 | $ = "socket" 43 | $ = "setsockopt" 44 | $ = "select" 45 | $ = "bind" 46 | $ = "shutdown" 47 | $ = "listen" 48 | $ = "opendir" 49 | $ = "readdir" 50 | $ = "closedir" 51 | $ = "rename" 52 | 53 | condition: 54 | (uint32(0) == 0x4464c457f) and (all of them) 55 | } 56 | 57 | rule apt_nix_elf_derusbi_kernelModule 58 | { 59 | 60 | meta: 61 | Author = "@seifreed" 62 | 63 | strings: 64 | $ = "__this_module" 65 | $ = "init_module" 66 | $ = "unhide_pid" 67 | $ = "is_hidden_pid" 68 | $ = "clear_hidden_pid" 69 | $ = "hide_pid" 70 | $ = "license" 71 | $ = "description" 72 | $ = "srcversion=" 73 | $ = "depends=" 74 | $ = "vermagic=" 75 | $ = "current_task" 76 | $ = "sock_release" 77 | $ = "module_layout" 78 | $ = "init_uts_ns" 79 | $ = "init_net" 80 | $ = "init_task" 81 | $ = "filp_open" 82 | $ = "__netlink_kernel_create" 83 | $ = "kfree_skb" 84 | 85 | condition: 86 | (uint32(0) == 0x4464c457f) and (all of them) 87 | } 88 | 89 | rule apt_nix_elf_Derusbi_Linux_SharedMemCreation 90 | { 91 | 92 | meta: 93 | Author = "@seifreed" 94 | 95 | strings: 96 | $byte1 = { B6 03 00 00 ?? 40 00 00 00 ?? 0D 5F 01 82 } 97 | 98 | condition: 99 | (uint32(0) == 0x464C457F) and (any of them) 100 | } 101 | 102 | rule apt_nix_elf_Derusbi_Linux_Strings 103 | { 104 | 105 | meta: 106 | Author = "@seifreed" 107 | 108 | strings: 109 | $a1 = "loadso" wide ascii fullword 110 | $a2 = "\nuname -a\n\n" wide ascii 111 | $a3 = "/dev/shm/.x11.id" wide ascii 112 | $a4 = "LxMain64" wide ascii nocase 113 | $a5 = "# \\u@\\h:\\w \\$ " wide ascii 114 | $b1 = "0123456789abcdefghijklmnopqrstuvwxyz" wide 115 | $b2 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" wide 116 | $b3 = "ret %d" wide fullword 117 | $b4 = "uname -a\n\n" wide ascii 118 | $b5 = "/proc/%u/cmdline" wide ascii 119 | $b6 = "/proc/self/exe" wide ascii 120 | $b7 = "cp -a %s %s" wide ascii 121 | $c1 = "/dev/pts/4" wide ascii fullword 122 | $c2 = "/tmp/1408.log" wide ascii fullword 123 | 124 | condition: 125 | uint32(0) == 0x464C457F and ((1 of ($a*) and 4 of ($b*)) or (1 of ($a*) and 1 of ($c*)) or 2 of ($a*) or all of ($b*)) 126 | } 127 | 128 | rule apt_win_exe_trojan_derusbi 129 | { 130 | 131 | meta: 132 | Author = "@seifreed" 133 | 134 | strings: 135 | $sa_1 = "USB" wide ascii 136 | $sa_2 = "RAM" wide ascii 137 | $sa_3 = "SHARE" wide ascii 138 | $sa_4 = "HOST: %s:%d" 139 | $sa_5 = "POST" 140 | $sa_6 = "User-Agent: Mozilla" 141 | $sa_7 = "Proxy-Connection: Keep-Alive" 142 | $sa_8 = "Connection: Keep-Alive" 143 | $sa_9 = "Server: Apache" 144 | $sa_10 = "HTTP/1.1" 145 | $sa_11 = "ImagePath" 146 | $sa_12 = "ZwUnloadDriver" 147 | $sa_13 = "ZwLoadDriver" 148 | $sa_14 = "ServiceMain" 149 | $sa_15 = "regsvr32.exe" 150 | $sa_16 = "/s /u" wide ascii 151 | $sa_17 = "rand" 152 | $sa_18 = "_time64" 153 | $sa_19 = "DllRegisterServer" 154 | $sa_20 = "DllUnregisterServer" 155 | $sa_21 = { 8b [5] 8b ?? d3 ?? 83 ?? 08 30 [5] 40 3b [5] 72 } // Decode Driver 156 | $sb_1 = "PCC_CMD_PACKET" 157 | $sb_2 = "PCC_CMD" 158 | $sb_3 = "PCC_BASEMOD" 159 | $sb_4 = "PCC_PROXY" 160 | $sb_5 = "PCC_SYS" 161 | $sb_6 = "PCC_PROCESS" 162 | $sb_7 = "PCC_FILE" 163 | $sb_8 = "PCC_SOCK" 164 | $sc_1 = "bcdedit -set testsigning" wide ascii 165 | $sc_2 = "update.microsoft.com" wide ascii 166 | $sc_3 = "_crt_debugger_hook" wide ascii 167 | $sc_4 = "ue8G5" wide ascii 168 | $sd_1 = "NET" wide ascii 169 | $sd_2 = "\\\\.\\pipe\\%s" wide ascii 170 | $sd_3 = ".dat" wide ascii 171 | $sd_4 = "CONNECT %s:%d" wide ascii 172 | $sd_5 = "\\Device\\" wide ascii 173 | $se_1 = "-%s-%04d" wide ascii 174 | $se_2 = "-%04d" wide ascii 175 | $se_3 = "FAL" wide ascii 176 | $se_4 = "OK" wide ascii 177 | $se_5 = "2.03" wide ascii 178 | $se_6 = "XXXXXXXXXXXXXXX" wide ascii 179 | 180 | condition: 181 | (uint16(0) == 0x5A4D) and ( (all of ($sa_*)) or ((13 of ($sa_*)) and ( (5 of ($sb_*)) or (3 of ($sc_*)) or (all of ($sd_*)) or ( (1 of ($sc_*)) and (all of ($se_*)) ) ) ) ) 182 | } 183 | 184 | 185 | rule Trojan_Derusbi 186 | { 187 | 188 | meta: 189 | Author = "RSA_IR" 190 | Date = "4Sept13" 191 | File = "derusbi_variants v 1.3" 192 | MD5 = " c0d4c5b669cc5b51862db37e972d31ec " 193 | 194 | strings: 195 | $b1 = {8b 15 ?? ?? ?? ?? 8b ce d3 ea 83 c6 ?? 30 90 ?? ?? ?? ?? 40 3b 05 ?? ?? ?? ?? 72 ??} 196 | $b2 = {F3 5D 88 2E ?? ?? 00 00 BE 07 18 2E F0 5D 88 2E F7 5D 88 2E 0C A2 88 2E 4B 5D 88 2E F3 5D 88 2E} 197 | $b3 = {4E E6 40 BB} 198 | $b4 = {B1 19 BF 44} 199 | $b5 = {6A F5 44 3D ?? ?? 00 00 27 AF D4 3D 69 F5 44 3D 6E F5 44 3D 95 0A 44 3D D2 F5 44 3D 6A F5 44 3D} 200 | $b6 = {F3 5D 88 2E ?? ?? 00 00 BE 07 18 2E F0 5D 88 2E} 201 | $b7 = {D6 D5 A4 A3 ?? ?? 00 00 9B 8F 34 A3 D5 D5 A4 A3 D2 D5 A4 A3 29 2A A4 A3} 202 | $b8 = {C3 76 33 9F ?? ?? 00 00 8E 2C A3 9F C0 76 33 9F C7 76 33 9F 3C 89 33 9F} 203 | 204 | condition: 205 | 2 of ($b1, $b2, $b3, $b4) and 1 of ($b5, $b6, $b7, $b8) 206 | } 207 | 208 | rule APT_Derusbi_DeepPanda 209 | { 210 | 211 | meta: 212 | author = "ThreatConnect Intelligence Research Team" 213 | reference = "http://www.crowdstrike.com/sites/default/files/AdversaryIntelligenceReport_DeepPanda_0.pdf" 214 | 215 | strings: 216 | $D = "Dom4!nUserP4ss" wide ascii 217 | 218 | condition: 219 | $D 220 | } 221 | 222 | 223 | rule APT_Derusbi_Gen 224 | { 225 | 226 | meta: 227 | author = "ThreatConnect Intelligence Research Team" 228 | 229 | strings: 230 | $2 = "273ce6-b29f-90d618c0" wide ascii 231 | $A = "Ace123dx" fullword wide ascii 232 | $A1 = "Ace123dxl!" fullword wide ascii 233 | $A2 = "Ace123dx!@#x" fullword wide ascii 234 | $C = "/Catelog/login1.asp" wide ascii 235 | $DF = "~DFTMP$$$$$.1" wide ascii 236 | $G = "GET /Query.asp?loginid=" wide ascii 237 | $L = "LoadConfigFromReg failded" wide ascii 238 | $L1 = "LoadConfigFromBuildin success" wide ascii 239 | $ph = "/photoe/photo.asp HTTP" wide ascii 240 | $PO = "POST /photos/photo.asp" wide ascii 241 | $PC = "PCC_IDENT" wide ascii 242 | 243 | condition: 244 | any of them 245 | } 246 | 247 | /* 248 | Yara Rule Set 249 | Author: Airbus Defence and Space Cybersecurity CSIRT - Fabien Perigaud 250 | Date: 2015-12-09 251 | Reference = http://blog.airbuscybersecurity.com/post/2015/11/Newcomers-in-the-Derusbi-family 252 | Identifier: Derusbi Dez 2015 253 | */ 254 | 255 | rule derusbi_kernel 256 | { 257 | 258 | meta: 259 | description = "Derusbi Driver version" 260 | date = "2015-12-09" 261 | author = "Airbus Defence and Space Cybersecurity CSIRT - Fabien Perigaud" 262 | 263 | strings: 264 | $token1 = "$$$--Hello" 265 | $token2 = "Wrod--$$$" 266 | $cfg = "XXXXXXXXXXXXXXX" 267 | $class = ".?AVPCC_BASEMOD@@" 268 | $MZ = "MZ" 269 | 270 | condition: 271 | $MZ at 0 and $token1 and $token2 and $cfg and $class 272 | } 273 | 274 | rule derusbi_linux 275 | { 276 | 277 | meta: 278 | description = "Derusbi Server Linux version" 279 | date = "2015-12-09" 280 | author = "Airbus Defence and Space Cybersecurity CSIRT - Fabien Perigaud" 281 | 282 | strings: 283 | $PS1 = "PS1=RK# \\u@\\h:\\w \\$" 284 | $cmd = "unset LS_OPTIONS;uname -a" 285 | $pname = "[diskio]" 286 | $rkfile = "/tmp/.secure" 287 | $ELF = "\x7fELF" 288 | 289 | condition: 290 | $ELF at 0 and $PS1 and $cmd and $pname and $rkfile 291 | } 292 | 293 | /* 294 | Yara Rule Set 295 | Author: Florian Roth 296 | Date: 2015-12-15 297 | Identifier: Derusbi Dez 2015 298 | */ 299 | 300 | rule Derusbi_Kernel_Driver_WD_UDFS 301 | { 302 | 303 | meta: 304 | description = "Detects Derusbi Kernel Driver" 305 | author = "Florian Roth" 306 | reference = "http://blog.airbuscybersecurity.com/post/2015/11/Newcomers-in-the-Derusbi-family" 307 | date = "2015-12-15" 308 | score = 80 309 | hash1 = "1b449121300b0188ff9f6a8c399fb818d0cf53fd36cf012e6908a2665a27f016" 310 | hash2 = "50174311e524b97ea5cb4f3ea571dd477d1f0eee06cd3ed73af39a15f3e6484a" 311 | hash3 = "6cdb65dbfb2c236b6d149fd9836cb484d0608ea082cf5bd88edde31ad11a0d58" 312 | hash4 = "e27fb16dce7fff714f4b05f2cef53e1919a34d7ec0e595f2eaa155861a213e59" 313 | 314 | strings: 315 | $x1 = "\\\\.\\pipe\\usbpcex%d" fullword wide 316 | $x2 = "\\\\.\\pipe\\usbpcg%d" fullword wide 317 | $x3 = "\\??\\pipe\\usbpcex%d" fullword wide 318 | $x4 = "\\??\\pipe\\usbpcg%d" fullword wide 319 | $x5 = "$$$--Hello" fullword ascii 320 | $x6 = "Wrod--$$$" fullword ascii 321 | $s1 = "\\Registry\\User\\%s\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings" fullword wide 322 | $s2 = "Update.dll" fullword ascii 323 | $s3 = "\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\WMI" fullword wide 324 | $s4 = "\\Driver\\nsiproxy" fullword wide 325 | $s5 = "HOST: %s" fullword ascii 326 | 327 | condition: 328 | uint16(0) == 0x5a4d and filesize < 800KB and (2 of ($x*) or all of ($s*)) 329 | } 330 | 331 | rule Derusbi_Code_Signing_Cert 332 | { 333 | 334 | meta: 335 | description = "Detects an executable signed with a certificate also used for Derusbi Trojan - suspicious" 336 | author = "Florian Roth" 337 | reference = "http://blog.airbuscybersecurity.com/post/2015/11/Newcomers-in-the-Derusbi-family" 338 | date = "2015-12-15" 339 | score = 40 340 | 341 | strings: 342 | $s1 = "Fuqing Dawu Technology Co.,Ltd.0" fullword ascii 343 | $s2 = "XL Games Co.,Ltd.0" fullword ascii 344 | $s3 = "Wemade Entertainment co.,Ltd0" fullword ascii 345 | 346 | condition: 347 | uint16(0) == 0x5a4d and filesize < 800KB and 1 of them 348 | } 349 | 350 | rule XOR_4byte_Key 351 | { 352 | 353 | meta: 354 | description = "Detects an executable encrypted with a 4 byte XOR (also used for Derusbi Trojan)" 355 | author = "Florian Roth" 356 | reference = "http://blog.airbuscybersecurity.com/post/2015/11/Newcomers-in-the-Derusbi-family" 357 | date = "2015-12-15" 358 | score = 60 359 | 360 | strings: 361 | /* Op Code */ 362 | $s1 = { 85 C9 74 0A 31 06 01 1E 83 C6 04 49 EB F2 } 363 | /* 364 | test ecx, ecx 365 | jz short loc_590170 366 | xor [esi], eax 367 | add [esi], ebx 368 | add esi, 4 369 | dec ecx 370 | jmp short loc_590162 371 | */ 372 | 373 | condition: 374 | uint16(0) == 0x5a4d and filesize < 900KB and all of them 375 | } 376 | 377 | rule apt_win32_dll_bergard_pgv_pvid_variant 378 | { 379 | 380 | meta: 381 | copyright = "Fidelis Cybersecurity" 382 | reference = "http://www.threatgeek.com/2016/05/turbo-twist-two-64-bit-derusbi-strains-converge.html" 383 | 384 | strings: 385 | $ = "Accept:" 386 | $ = "User-Agent: %s" 387 | $ = "Host: %s:%d" 388 | $ = "Cache-Control: no-cache" 389 | $ = "Connection: Keep-Alive" 390 | $ = "Cookie: pgv_pvid=" 391 | $ = "Content-Type: application/x-octet-stream" 392 | $ = "User-Agent: %s" 393 | $ = "Host: %s:%d" 394 | $ = "Pragma: no-cache" 395 | $ = "Connection: Keep-Alive" 396 | $ = "HTTP/1.0" 397 | 398 | condition: 399 | (uint16(0) == 0x5A4D) and (all of them) 400 | } 401 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "flag" 6 | "fmt" 7 | "io" 8 | "io/ioutil" 9 | "log" 10 | "os" 11 | "path/filepath" 12 | "strings" 13 | "sync" 14 | "syscall" 15 | "time" 16 | 17 | "github.com/aws/aws-sdk-go-v2/config" 18 | "github.com/aws/aws-sdk-go-v2/feature/ec2/imds" 19 | "github.com/aws/aws-sdk-go-v2/service/ec2" 20 | "github.com/aws/aws-sdk-go-v2/service/ec2/types" 21 | "github.com/aws/aws-sdk-go-v2/service/s3" 22 | yara "github.com/capsule8/go-yara" 23 | ) 24 | 25 | type volumeInfo struct { 26 | VolumeId string 27 | Attachments []string 28 | } 29 | 30 | func (i volumeInfo) String() string { 31 | if len(i.Attachments) == 0 { 32 | return i.VolumeId 33 | } 34 | return fmt.Sprintf("%s (attached to %v)", i.VolumeId, strings.Join(i.Attachments, ", ")) 35 | } 36 | 37 | func run() int { 38 | // load the AWS config 39 | ctx := context.Background() 40 | cfg, err := config.LoadDefaultConfig(ctx) 41 | if err != nil { 42 | log.Fatalf("unable to load AWS config: %v", err) 43 | } 44 | // connect to local instance metadata service 45 | metadataService := imds.NewFromConfig(cfg) 46 | metadataResponse, err := metadataService.GetMetadata(ctx, &imds.GetMetadataInput{ 47 | Path: "placement/availability-zone", 48 | }) 49 | if err != nil { 50 | log.Fatalf("failed to lookup availability zone instance metadata: %v", err) 51 | } 52 | azBytes, err := ioutil.ReadAll(metadataResponse.Content) 53 | if err != nil { 54 | log.Fatalf("failed to read availability zone content: %v", err) 55 | } 56 | az := string(azBytes) 57 | cfg, err = config.LoadDefaultConfig(ctx, 58 | config.WithRegion(az[:len(az)-1]), 59 | ) 60 | if err != nil { 61 | log.Fatalf("unable to reload AWS config: %v", err) 62 | } 63 | metadataResponse, err = metadataService.GetMetadata(ctx, &imds.GetMetadataInput{ 64 | Path: "instance-id", 65 | }) 66 | if err != nil { 67 | log.Fatalf("failed to lookup instance id instance metadata: %v", err) 68 | } 69 | instanceIdBytes, err := ioutil.ReadAll(metadataResponse.Content) 70 | if err != nil { 71 | log.Fatalf("failed to read instance id content: %v", err) 72 | } 73 | instanceId := string(instanceIdBytes) 74 | // parse arguments 75 | signaturePathFlag := flag.String("signatures", "./rules", "a path to YARA signatures") 76 | volumeIdsFlag := flag.String("volume-ids", "all", "a comma separated list of volume IDs to scan") 77 | bucketIdsFlag := flag.String("bucket-ids", "all", "a comma separated list of bucket IDs to scan") 78 | flag.Parse() 79 | // load YARA 80 | compiler, err := yara.NewCompiler() 81 | if err != nil { 82 | log.Fatalf("Could not initialize yara compiler: %v", err) 83 | } 84 | defer compiler.Destroy() 85 | // read rules from filesystem 86 | ruleCount := 0 87 | err = filepath.Walk(*signaturePathFlag, func(recursivePath string, info os.FileInfo, err error) error { 88 | if err != nil { 89 | return nil 90 | } 91 | if info.IsDir() { 92 | return nil 93 | } 94 | ext := filepath.Ext(recursivePath) 95 | if ext != ".yar" && ext != ".yara" { 96 | return nil 97 | } 98 | log.Printf("loading yara rule from %q", recursivePath) 99 | f, err := os.Open(recursivePath) 100 | if err != nil { 101 | return fmt.Errorf("error opening yara signature from %q: %v", recursivePath, err) 102 | } 103 | defer f.Close() 104 | err = compiler.AddFile(f, recursivePath) 105 | if err != nil { 106 | log.Printf("error compiling yara signature from %q: %v", recursivePath, err) 107 | } else { 108 | ruleCount++ 109 | } 110 | return nil 111 | }) 112 | if err != nil { 113 | log.Fatalf("could not initialize yara rules: %v", err) 114 | } 115 | // compile the rules 116 | r, err := compiler.GetRules() 117 | if err != nil { 118 | log.Fatalf("failed to compile yara rules: %s", err) 119 | } 120 | defer r.Destroy() 121 | if ruleCount == 0 { 122 | log.Fatalf("no rules to scan files with; place signatures in ./signatures/*.yar") 123 | } 124 | exitCode := 0 125 | dryRun := false 126 | // search for volumes 127 | if *volumeIdsFlag != "" { 128 | var volumes []volumeInfo 129 | var volumeIds []string 130 | if *volumeIdsFlag != "all" { 131 | volumeIds = strings.Split(*volumeIdsFlag, ",") 132 | } 133 | // connect to EC2 134 | client := ec2.NewFromConfig(cfg) 135 | var nextToken *string 136 | for { 137 | volumesOutput, err := client.DescribeVolumes(ctx, &ec2.DescribeVolumesInput{ 138 | DryRun: &dryRun, 139 | NextToken: nextToken, 140 | VolumeIds: volumeIds, 141 | }) 142 | if err != nil { 143 | log.Fatalf("describe volumes request failed: %v", err) 144 | } 145 | for _, volume := range volumesOutput.Volumes { 146 | info := volumeInfo{ 147 | VolumeId: *volume.VolumeId, 148 | } 149 | for _, attachment := range volume.Attachments { 150 | info.Attachments = append(info.Attachments, *attachment.InstanceId) 151 | } 152 | volumes = append(volumes, info) 153 | log.Printf("found volume %s", info.VolumeId) 154 | } 155 | if nextToken = volumesOutput.NextToken; nextToken == nil { 156 | break 157 | } 158 | } 159 | log.Printf("scanning the following volumes: %v", volumes) 160 | for _, volume := range volumes { 161 | if err = processVolume(ctx, client, az, instanceId, volume, r); err != nil { 162 | log.Printf("%v", err) 163 | exitCode = 1 164 | } 165 | } 166 | } else { 167 | log.Printf("skipping scanning volumes, none specified") 168 | } 169 | if *bucketIdsFlag != "" { 170 | var bucketIds []string 171 | client := s3.NewFromConfig(cfg) 172 | if *bucketIdsFlag != "all" { 173 | bucketIds = strings.Split(*bucketIdsFlag, ",") 174 | } else { 175 | // connect to S3 176 | bucketsOutput, err := client.ListBuckets(ctx, &s3.ListBucketsInput{}) 177 | if err != nil { 178 | log.Fatalf("list buckets request failed: %v", err) 179 | } 180 | for _, bucket := range bucketsOutput.Buckets { 181 | bucketIds = append(bucketIds, *bucket.Name) 182 | } 183 | } 184 | log.Printf("scanning the following buckets: %v", bucketIds) 185 | for _, bucket := range bucketIds { 186 | if err = processBucket(ctx, client, bucket, r); err != nil { 187 | log.Printf("%v", err) 188 | exitCode = 1 189 | } 190 | } 191 | } 192 | return exitCode 193 | } 194 | 195 | func processVolume(ctx context.Context, client *ec2.Client, az string, instanceId string, volumeInfo volumeInfo, rules *yara.Rules) error { 196 | // create a snapshot 197 | dryRun := false 198 | log.Printf("creating new snapshot for %v", volumeInfo) 199 | description := "Patrolaroid temporary snapshot of " + volumeInfo.VolumeId 200 | snapshot, err := client.CreateSnapshot(ctx, &ec2.CreateSnapshotInput{ 201 | VolumeId: &volumeInfo.VolumeId, 202 | Description: &description, 203 | DryRun: &dryRun, 204 | }) 205 | if err != nil { 206 | return fmt.Errorf("create snapshot request failed: %v", err) 207 | } 208 | snapshotId := *snapshot.SnapshotId 209 | log.Printf("created snapshot: %s", snapshotId) 210 | // create a volume for the snapshot 211 | snapshotIdKey := "snapshot-id" 212 | fiveSnapshots := int32(5) 213 | wait_for_snapshot_completion: 214 | for { 215 | log.Printf("describing snapshot %q", snapshotId) 216 | descriptions, err := client.DescribeSnapshots(ctx, &ec2.DescribeSnapshotsInput{ 217 | DryRun: &dryRun, 218 | Filters: []types.Filter{ 219 | types.Filter{ 220 | Name: &snapshotIdKey, 221 | Values: []string{snapshotId}, 222 | }, 223 | }, 224 | MaxResults: &fiveSnapshots, 225 | }) 226 | if err != nil { 227 | return fmt.Errorf("unable to query snapshots: %v", err) 228 | } 229 | for _, snapshot := range descriptions.Snapshots { 230 | switch snapshot.State { 231 | case types.SnapshotStateError: 232 | if snapshot.StateMessage != nil { 233 | return fmt.Errorf("creating snapshot failed: %s", *snapshot.StateMessage) 234 | } else { 235 | return fmt.Errorf("creating snapshot failed without message") 236 | } 237 | case types.SnapshotStateCompleted: 238 | log.Printf("snapshot completed") 239 | break wait_for_snapshot_completion 240 | case types.SnapshotStatePending: 241 | if snapshot.Progress != nil { 242 | log.Printf("snapshot progress: %s", *snapshot.Progress) 243 | } 244 | } 245 | } 246 | time.Sleep(10 * time.Second) 247 | } 248 | iops := int32(6000) 249 | createVolumeResponse, err := client.CreateVolume(ctx, &ec2.CreateVolumeInput{ 250 | AvailabilityZone: &az, 251 | SnapshotId: &snapshotId, 252 | Iops: &iops, 253 | VolumeType: types.VolumeTypeGp3, 254 | }) 255 | if err != nil { 256 | return fmt.Errorf("create volume request failed: %v", err) 257 | } 258 | snapshotVolumeId := *createVolumeResponse.VolumeId 259 | log.Printf("created snapshot volume: %s", snapshotVolumeId) 260 | // wait for the volume to become ready 261 | var attached bool 262 | wait_for_volume_completion: 263 | for { 264 | log.Printf("describing snapshot volume %q", snapshotVolumeId) 265 | fiveVolumes := int32(5) 266 | volumeIdKey := "volume-id" 267 | descriptions, err := client.DescribeVolumes(ctx, &ec2.DescribeVolumesInput{ 268 | DryRun: &dryRun, 269 | Filters: []types.Filter{ 270 | types.Filter{ 271 | Name: &volumeIdKey, 272 | Values: []string{snapshotVolumeId}, 273 | }, 274 | }, 275 | MaxResults: &fiveVolumes, 276 | }) 277 | if err != nil { 278 | return fmt.Errorf("unable to query volumes: %v", err) 279 | } 280 | if len(descriptions.Volumes) == 0 { 281 | return fmt.Errorf("invalid volume id: %v", volumeInfo) 282 | } 283 | for _, volume := range descriptions.Volumes { 284 | switch volume.State { 285 | case types.VolumeStateCreating: 286 | log.Printf("still creating volume") 287 | case types.VolumeStateAvailable: 288 | log.Printf("volume available") 289 | attached = false 290 | break wait_for_volume_completion 291 | case types.VolumeStateInUse: 292 | log.Printf("volume is in use, assuming it was just attached") 293 | attached = true 294 | break wait_for_volume_completion 295 | case types.VolumeStateDeleting: 296 | return fmt.Errorf("volume is being deleted") 297 | case types.VolumeStateDeleted: 298 | return fmt.Errorf("volume is deleted") 299 | case types.VolumeStateError: 300 | return fmt.Errorf("volume is in error state") 301 | } 302 | } 303 | time.Sleep(10 * time.Second) 304 | } 305 | // attach the volume 306 | device := "/dev/sda2" 307 | if !attached { 308 | _, err = client.AttachVolume(ctx, &ec2.AttachVolumeInput{ 309 | InstanceId: &instanceId, 310 | VolumeId: &snapshotVolumeId, 311 | Device: &device, 312 | }) 313 | if err != nil { 314 | return fmt.Errorf("attach volume request failed: %v", err) 315 | } 316 | wait_for_volume_attachment: 317 | for { 318 | log.Printf("describing volume %q", snapshotVolumeId) 319 | fiveVolumes := int32(5) 320 | volumeIdKey := "volume-id" 321 | descriptions, err := client.DescribeVolumes(ctx, &ec2.DescribeVolumesInput{ 322 | DryRun: &dryRun, 323 | Filters: []types.Filter{ 324 | types.Filter{ 325 | Name: &volumeIdKey, 326 | Values: []string{snapshotVolumeId}, 327 | }, 328 | }, 329 | MaxResults: &fiveVolumes, 330 | }) 331 | if err != nil { 332 | return fmt.Errorf("unable to query volumes: %v", err) 333 | } 334 | for _, volume := range descriptions.Volumes { 335 | for _, attachment := range volume.Attachments { 336 | if *attachment.InstanceId == instanceId { 337 | switch attachment.State { 338 | case types.VolumeAttachmentStateAttaching: 339 | log.Printf("volume is attaching") 340 | case types.VolumeAttachmentStateAttached: 341 | log.Printf("volume is attached") 342 | break wait_for_volume_attachment 343 | case types.VolumeAttachmentStateDetaching: 344 | log.Printf("volume is detaching") 345 | case types.VolumeAttachmentStateDetached: 346 | return fmt.Errorf("volume is detached, but expected it to be in another state") 347 | case types.VolumeAttachmentStateBusy: 348 | return fmt.Errorf("volume is busy, but expected it to be in another state") 349 | } 350 | } 351 | } 352 | } 353 | time.Sleep(5 * time.Second) 354 | } 355 | } 356 | // find the newest nvme devices 357 | files, err := ioutil.ReadDir("/dev") 358 | if err != nil { 359 | return fmt.Errorf("unable to read local devices: %v", err) 360 | } 361 | var newestDevice string 362 | for _, file := range files { 363 | if fileName := file.Name(); strings.HasPrefix(fileName, "nvme") { 364 | newestDevice = "/dev/" + fileName 365 | } 366 | } 367 | if newestDevice == "" { 368 | return fmt.Errorf("unable to find any nvme devices") 369 | } 370 | log.Printf("latest device is %s", newestDevice) 371 | // mount the device 372 | _ = os.Mkdir("./snapshot", 0644) 373 | err = syscall.Mount(newestDevice, "./snapshot", "ext4", syscall.MS_RDONLY|syscall.MS_NOEXEC, "") 374 | var errorToReturn error 375 | if err != nil { 376 | errorToReturn = fmt.Errorf("failed to mount device: %v", err) 377 | log.Printf("failed to mount, detaching") 378 | } else { 379 | log.Printf("mounted successfully, scanning") 380 | // set up the background scanners 381 | var wg sync.WaitGroup 382 | pathsToScan := make(chan string, 1024) 383 | for i := 0; i < 64; i++ { 384 | wg.Add(1) 385 | go func() { 386 | defer wg.Done() 387 | for recursivePath := range pathsToScan { 388 | // Actually scan the file 389 | var m yara.MatchRules 390 | if err := rules.ScanFile(recursivePath, 0, 0, &m); err != nil { 391 | errorText := err.Error() 392 | // Ignore bad symlinks and unlink race conditions. Have to 393 | // compare by string since go-yara doesn't use structured error 394 | // types :( 395 | if errorText != "could not open file" && errorText != "could not map file" { 396 | log.Printf("could not scan file in volume %v at path %q: %v", volumeInfo, strings.TrimPrefix(recursivePath, "snapshot"), err) 397 | } 398 | } else { 399 | // If we have matches, dispatch an alert 400 | if len(m) != 0 { 401 | for _, match := range m { 402 | log.Printf("file in volume %v at path %q violated rule %q from %q", volumeInfo, strings.TrimPrefix(recursivePath, "snapshot"), match.Rule, match.Namespace) 403 | } 404 | } 405 | } 406 | } 407 | }() 408 | } 409 | // search for files 410 | err = filepath.Walk("./snapshot", func(recursivePath string, info os.FileInfo, err error) error { 411 | if err != nil { 412 | return nil 413 | } 414 | // Precheck to make sure we're dealing with an actual file 415 | if info.IsDir() || info.Size() == 0 { 416 | return nil 417 | } 418 | if info.Mode()&(os.ModeDevice|os.ModeNamedPipe|os.ModeSocket|os.ModeCharDevice|os.ModeSymlink) != 0 { 419 | return nil 420 | } 421 | pathsToScan <- recursivePath 422 | return nil 423 | }) 424 | if err != nil { 425 | log.Printf("error scanning: %v", err) 426 | } 427 | close(pathsToScan) 428 | wg.Wait() 429 | log.Printf("finished scanning, unmounting") 430 | // unmount the volume 431 | syscall.Unmount("./snapshot", 0) 432 | time.Sleep(1 * time.Second) 433 | log.Printf("finished unmounting, detaching") 434 | } 435 | // detach the snapshot volume 436 | _, err = client.DetachVolume(ctx, &ec2.DetachVolumeInput{ 437 | InstanceId: &instanceId, 438 | VolumeId: &snapshotVolumeId, 439 | }) 440 | if err != nil { 441 | return fmt.Errorf("detach volume request failed: %v", err) 442 | } 443 | wait_for_volume_detachment: 444 | for { 445 | log.Printf("describing volume %q", snapshotVolumeId) 446 | fiveVolumes := int32(5) 447 | volumeIdKey := "volume-id" 448 | descriptions, err := client.DescribeVolumes(ctx, &ec2.DescribeVolumesInput{ 449 | DryRun: &dryRun, 450 | Filters: []types.Filter{ 451 | types.Filter{ 452 | Name: &volumeIdKey, 453 | Values: []string{snapshotVolumeId}, 454 | }, 455 | }, 456 | MaxResults: &fiveVolumes, 457 | }) 458 | if err != nil { 459 | return fmt.Errorf("unable to query volumes: %v", err) 460 | } 461 | for _, volume := range descriptions.Volumes { 462 | switch volume.State { 463 | case types.VolumeStateCreating: 464 | log.Printf("still creating volume") 465 | case types.VolumeStateAvailable: 466 | log.Printf("volume available") 467 | break wait_for_volume_detachment 468 | case types.VolumeStateInUse: 469 | log.Printf("volume is in use, waiting for detachment") 470 | case types.VolumeStateDeleting: 471 | log.Printf("volume is being deleted") 472 | case types.VolumeStateDeleted: 473 | return nil 474 | case types.VolumeStateError: 475 | return fmt.Errorf("volume is in error state") 476 | } 477 | } 478 | time.Sleep(10 * time.Second) 479 | } 480 | log.Printf("finished detaching, deleting volume") 481 | // delete the snapshot volume 482 | _, err = client.DeleteVolume(ctx, &ec2.DeleteVolumeInput{ 483 | VolumeId: &snapshotVolumeId, 484 | }) 485 | log.Printf("finished scanning %v", volumeInfo) 486 | if err != nil { 487 | return fmt.Errorf("delete volume request failed: %v", err) 488 | } 489 | return errorToReturn 490 | } 491 | 492 | type s3MemoryIterator struct { 493 | ctx context.Context 494 | client *s3.Client 495 | bucketId string 496 | key string 497 | size int64 498 | offset int64 499 | err error 500 | } 501 | 502 | func (i *s3MemoryIterator) First() *yara.MemoryBlock { 503 | i.offset = 0 504 | return i.Next() 505 | } 506 | 507 | func (i *s3MemoryIterator) Next() *yara.MemoryBlock { 508 | base := i.offset 509 | chunkSize := i.size - base 510 | if chunkSize == 0 { 511 | return nil 512 | } 513 | if chunkSize > 2*1024*1024 { 514 | chunkSize = 2 * 1024 * 1024 515 | } 516 | i.offset += chunkSize 517 | return &yara.MemoryBlock{ 518 | Base: uint64(base), 519 | Size: uint64(chunkSize), 520 | FetchData: func(buf []byte) { 521 | rangeString := fmt.Sprintf("bytes=%d-%d", base, base+chunkSize) 522 | output, err := i.client.GetObject(i.ctx, &s3.GetObjectInput{ 523 | Bucket: &i.bucketId, 524 | Key: &i.key, 525 | Range: &rangeString, 526 | }) 527 | if err != nil { 528 | i.err = err 529 | } else { 530 | body := output.Body 531 | defer body.Close() 532 | for len(buf) > 0 { 533 | var n int 534 | n, err = body.Read(buf) 535 | buf = buf[n:] 536 | if err != nil { 537 | if err != io.EOF { 538 | i.err = err 539 | } 540 | break 541 | } 542 | } 543 | } 544 | }, 545 | } 546 | } 547 | 548 | func processBucket(ctx context.Context, client *s3.Client, bucketId string, rules *yara.Rules) error { 549 | var wg sync.WaitGroup 550 | pathsToScan := make(chan *s3MemoryIterator, 1024) 551 | for i := 0; i < 64; i++ { 552 | wg.Add(1) 553 | go func() { 554 | defer wg.Done() 555 | for iterator := range pathsToScan { 556 | // Actually scan the file 557 | var m yara.MatchRules 558 | if err := rules.ScanMemBlocks(iterator, 0, 0, &m); err != nil { 559 | log.Printf("could not scan file in bucket %s at path %q: %v", bucketId, iterator.key, err) 560 | } else if iterator.err != nil { 561 | log.Printf("could not scan file in bucket %s at path %q: %v", bucketId, iterator.key, iterator.err) 562 | } else { 563 | // If we have matches, dispatch an alert 564 | if len(m) != 0 { 565 | for _, match := range m { 566 | log.Printf("file in bucket %s at path %q violated rule %q from %q", bucketId, iterator.key, match.Rule, match.Namespace) 567 | } 568 | } 569 | } 570 | } 571 | }() 572 | } 573 | log.Printf("scanning bucket %s", bucketId) 574 | var continuationToken *string 575 | for { 576 | listObjectsOutput, err := client.ListObjectsV2(ctx, &s3.ListObjectsV2Input{ 577 | Bucket: &bucketId, 578 | }) 579 | if err != nil { 580 | log.Fatalf("describe volumes request failed: %v", err) 581 | } 582 | for _, object := range listObjectsOutput.Contents { 583 | pathsToScan <- &s3MemoryIterator{ 584 | ctx: ctx, 585 | client: client, 586 | bucketId: bucketId, 587 | key: *object.Key, 588 | size: object.Size, 589 | } 590 | } 591 | if continuationToken = listObjectsOutput.NextContinuationToken; continuationToken == nil { 592 | break 593 | } 594 | } 595 | close(pathsToScan) 596 | wg.Wait() 597 | log.Printf("finished scanning %s", bucketId) 598 | return nil 599 | } 600 | 601 | func main() { 602 | os.Exit(run()) 603 | } 604 | -------------------------------------------------------------------------------- /rules/Equation_Group_Toolkit_2.yara: -------------------------------------------------------------------------------- 1 | /* Source: https://github.com/Yara-Rules/rules/blob/3872244500f584491cde7c633f12f1f043a61c13/malware/APT_Equation.yar */ 2 | 3 | /* 4 | This Yara ruleset is under the GNU-GPLv2 license (http://www.gnu.org/licenses/gpl-2.0.html) and open to any user or organization, as long as you use it under this license. 5 | */ 6 | 7 | import "pe" 8 | 9 | /* Equation APT ------------------------------------------------------------ */ 10 | 11 | rule apt_equation_exploitlib_mutexes 12 | { 13 | 14 | meta: 15 | copyright = "Kaspersky Lab" 16 | description = "Rule to detect Equation group's Exploitation library http://goo.gl/ivt8EW" 17 | version = "1.0" 18 | last_modified = "2015-02-16" 19 | reference = "http://securelist.com/blog/research/68750/equation-the-death-star-of-malware-galaxy/" 20 | 21 | strings: 22 | $mz="MZ" 23 | $a1="prkMtx" wide 24 | $a2="cnFormSyncExFBC" wide 25 | $a3="cnFormVoidFBC" wide 26 | $a4="cnFormSyncExFBC" 27 | $a5="cnFormVoidFBC" 28 | 29 | condition: 30 | (($mz at 0) and any of ($a*)) 31 | } 32 | 33 | rule apt_equation_doublefantasy_genericresource 34 | { 35 | 36 | meta: 37 | copyright = "Kaspersky Lab" 38 | description = "Rule to detect DoubleFantasy encoded config http://goo.gl/ivt8EW" 39 | version = "1.0" 40 | last_modified = "2015-02-16" 41 | reference = "http://securelist.com/blog/research/68750/equation-the-death-star-of-malware-galaxy/" 42 | 43 | strings: 44 | $mz="MZ" 45 | $a1={06 00 42 00 49 00 4E 00 52 00 45 00 53 00} 46 | $a2="yyyyyyyyyyyyyyyy" 47 | $a3="002" 48 | 49 | condition: 50 | (($mz at 0) and all of ($a*)) and filesize < 500000 51 | } 52 | 53 | rule apt_equation_equationlaser_runtimeclasses 54 | { 55 | 56 | meta: 57 | copyright = "Kaspersky Lab" 58 | description = "Rule to detect the EquationLaser malware" 59 | version = "1.0" 60 | last_modified = "2015-02-16" 61 | reference = "https://securelist.com/blog/" 62 | 63 | strings: 64 | $a1="?a73957838_2@@YAXXZ" 65 | $a2="?a84884@@YAXXZ" 66 | $a3="?b823838_9839@@YAXXZ" 67 | $a4="?e747383_94@@YAXXZ" 68 | $a5="?e83834@@YAXXZ" 69 | $a6="?e929348_827@@YAXXZ" 70 | 71 | condition: 72 | any of them 73 | } 74 | 75 | rule apt_equation_cryptotable 76 | { 77 | 78 | meta: 79 | copyright = "Kaspersky Lab" 80 | description = "Rule to detect the crypto library used in Equation group malware" 81 | version = "1.0" 82 | last_modified = "2015-02-16" 83 | reference = "https://securelist.com/blog/" 84 | 85 | strings: 86 | $a={37 DF E8 B6 C7 9C 0B AE 91 EF F0 3B 90 C6 80 85 5D 19 4B 45 44 12 3C E2 0D 5C 1C 7B C4 FF D6 05 17 14 4F 03 74 1E 41 DA 8F 7D DE 7E 99 F1 35 AC B8 46 93 CE 23 82 07 EB 2B D4 72 71 40 F3 B0 F7 78 D7 4C D1 55 1A 39 83 18 FA E1 9A 56 B1 96 AB A6 30 C5 5F BE 0C 50 C1} 87 | 88 | condition: 89 | $a 90 | } 91 | 92 | /* Equation Group - Kaspersky ---------------------------------------------- */ 93 | 94 | rule Equation_Kaspersky_TripleFantasy_1 95 | { 96 | 97 | meta: 98 | description = "Equation Group Malware - TripleFantasy http://goo.gl/ivt8EW" 99 | author = "Florian Roth" 100 | reference = "http://goo.gl/ivt8EW" 101 | date = "2015/02/16" 102 | hash = "b2b2cd9ca6f5864ef2ac6382b7b6374a9fb2cbe9" 103 | 104 | strings: 105 | $mz = { 4d 5a } 106 | $s0 = "%SystemRoot%\\system32\\hnetcfg.dll" fullword wide 107 | $s1 = "%WINDIR%\\System32\\ahlhcib.dll" fullword wide 108 | $s2 = "%WINDIR%\\sjyntmv.dat" fullword wide 109 | $s3 = "Global\\{8c38e4f3-591f-91cf-06a6-67b84d8a0102}" fullword wide 110 | $s4 = "%WINDIR%\\System32\\owrwbsdi" fullword wide 111 | $s5 = "Chrome" fullword wide 112 | $s6 = "StringIndex" fullword ascii 113 | $x1 = "itemagic.net@443" fullword wide 114 | $x2 = "team4heat.net@443" fullword wide 115 | $x5 = "62.216.152.69@443" fullword wide 116 | $x6 = "84.233.205.37@443" fullword wide 117 | $z1 = "www.microsoft.com@80" fullword wide 118 | $z2 = "www.google.com@80" fullword wide 119 | $z3 = "127.0.0.1:3128" fullword wide 120 | 121 | condition: 122 | ( $mz at 0 ) and filesize < 300000 and (( all of ($s*) and all of ($z*) ) or ( all of ($s*) and 1 of ($x*) )) 123 | } 124 | 125 | rule Equation_Kaspersky_DoubleFantasy_1 126 | { 127 | 128 | meta: 129 | description = "Equation Group Malware - DoubleFantasy" 130 | author = "Florian Roth" 131 | reference = "http://goo.gl/ivt8EW" 132 | date = "2015/02/16" 133 | hash = "d09b4b6d3244ac382049736ca98d7de0c6787fa2" 134 | 135 | strings: 136 | $mz = { 4d 5a } 137 | $z1 = "msvcp5%d.dll" fullword ascii 138 | $s0 = "actxprxy.GetProxyDllInfo" fullword ascii 139 | $s3 = "actxprxy.DllGetClassObject" fullword ascii 140 | $s5 = "actxprxy.DllRegisterServer" fullword ascii 141 | $s6 = "actxprxy.DllUnregisterServer" fullword ascii 142 | $x1 = "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy" ascii 143 | $x2 = "191H1a1" fullword ascii 144 | $x3 = "November " fullword ascii 145 | $x4 = "abababababab" fullword ascii 146 | $x5 = "January " fullword ascii 147 | $x6 = "October " fullword ascii 148 | $x7 = "September " fullword ascii 149 | 150 | condition: 151 | ( $mz at 0 ) and filesize < 350000 and (( $z1 ) or ( all of ($s*) and 6 of ($x*) )) 152 | } 153 | 154 | rule Equation_Kaspersky_GROK_Keylogger 155 | { 156 | 157 | meta: 158 | description = "Equation Group Malware - GROK keylogger" 159 | author = "Florian Roth" 160 | reference = "http://goo.gl/ivt8EW" 161 | date = "2015/02/16" 162 | hash = "50b8f125ed33233a545a1aac3c9d4bb6aa34b48f" 163 | 164 | strings: 165 | $mz = { 4d 5a } 166 | $s0 = "c:\\users\\rmgree5\\" ascii 167 | $s1 = "msrtdv.sys" fullword wide 168 | $x1 = "svrg.pdb" fullword ascii 169 | $x2 = "W32pServiceTable" fullword ascii 170 | $x3 = "In forma" fullword ascii 171 | $x4 = "ReleaseF" fullword ascii 172 | $x5 = "criptor" fullword ascii 173 | $x6 = "astMutex" fullword ascii 174 | $x7 = "ARASATAU" fullword ascii 175 | $x8 = "R0omp4ar" fullword ascii 176 | $z1 = "H.text" fullword ascii 177 | $z2 = "\\registry\\machine\\software\\Microsoft\\Windows NT\\CurrentVersion" fullword wide 178 | $z4 = "\\registry\\machine\\SYSTEM\\ControlSet001\\Control\\Session Manager\\Environment" wide fullword 179 | 180 | condition: 181 | ( $mz at 0 ) and filesize < 250000 and ($s0 or ( $s1 and 6 of ($x*) ) or ( 6 of ($x*) and all of ($z*) )) 182 | } 183 | 184 | rule Equation_Kaspersky_GreyFishInstaller 185 | { 186 | 187 | meta: 188 | description = "Equation Group Malware - Grey Fish" 189 | author = "Florian Roth" 190 | reference = "http://goo.gl/ivt8EW" 191 | date = "2015/02/16" 192 | hash = "58d15d1581f32f36542f3e9fb4b1fc84d2a6ba35" 193 | 194 | strings: 195 | $s0 = "DOGROUND.exe" fullword wide 196 | $s1 = "Windows Configuration Services" fullword wide 197 | $s2 = "GetMappedFilenameW" fullword ascii 198 | 199 | condition: 200 | all of them 201 | } 202 | 203 | rule Equation_Kaspersky_EquationDrugInstaller 204 | { 205 | 206 | meta: 207 | description = "Equation Group Malware - EquationDrug installer LUTEUSOBSTOS" 208 | author = "Florian Roth" 209 | reference = "http://goo.gl/ivt8EW" 210 | date = "2015/02/16" 211 | hash = "61fab1b8451275c7fd580895d9c68e152ff46417" 212 | 213 | strings: 214 | $mz = { 4d 5a } 215 | 216 | $s0 = "\\system32\\win32k.sys" fullword wide 217 | $s1 = "ALL_FIREWALLS" fullword ascii 218 | $x1 = "@prkMtx" fullword wide 219 | $x2 = "STATIC" fullword wide 220 | $x3 = "windir" fullword wide 221 | $x4 = "cnFormVoidFBC" fullword wide 222 | $x5 = "CcnFormSyncExFBC" fullword wide 223 | $x6 = "WinStaObj" fullword wide 224 | $x7 = "BINRES" fullword wide 225 | 226 | condition: 227 | ( $mz at 0 ) and filesize < 500000 and all of ($s*) and 5 of ($x*) 228 | } 229 | 230 | rule Equation_Kaspersky_EquationLaserInstaller 231 | { 232 | 233 | meta: 234 | description = "Equation Group Malware - EquationLaser Installer" 235 | author = "Florian Roth" 236 | reference = "http://goo.gl/ivt8EW" 237 | date = "2015/02/16" 238 | hash = "5e1f56c1e57fbff96d4999db1fd6dd0f7d8221df" 239 | 240 | strings: 241 | $mz = { 4d 5a } 242 | $s0 = "Failed to get Windows version" fullword ascii 243 | $s1 = "lsasrv32.dll and lsass.exe" fullword wide 244 | $s2 = "\\\\%s\\mailslot\\%s" fullword ascii 245 | $s3 = "%d-%d-%d %d:%d:%d Z" fullword ascii 246 | $s4 = "lsasrv32.dll" fullword ascii 247 | $s5 = "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" fullword ascii 248 | $s6 = "%s %02x %s" fullword ascii 249 | $s7 = "VIEWERS" fullword ascii 250 | $s8 = "5.2.3790.220 (srv03_gdr.040918-1552)" fullword wide 251 | 252 | condition: 253 | ( $mz at 0 ) and filesize < 250000 and 6 of ($s*) 254 | } 255 | 256 | rule Equation_Kaspersky_FannyWorm 257 | { 258 | 259 | meta: 260 | description = "Equation Group Malware - Fanny Worm" 261 | author = "Florian Roth" 262 | reference = "http://goo.gl/ivt8EW" 263 | date = "2015/02/16" 264 | hash = "1f0ae54ac3f10d533013f74f48849de4e65817a7" 265 | 266 | strings: 267 | $mz = { 4d 5a } 268 | $s1 = "x:\\fanny.bmp" fullword ascii 269 | $s2 = "32.exe" fullword ascii 270 | $s3 = "d:\\fanny.bmp" fullword ascii 271 | $x1 = "c:\\windows\\system32\\kernel32.dll" fullword ascii 272 | $x2 = "System\\CurrentControlSet\\Services\\USBSTOR\\Enum" fullword ascii 273 | $x3 = "System\\CurrentControlSet\\Services\\PartMgr\\Enum" fullword ascii 274 | $x4 = "\\system32\\win32k.sys" fullword wide 275 | $x5 = "\\AGENTCPD.DLL" fullword ascii 276 | $x6 = "agentcpd.dll" fullword ascii 277 | $x7 = "PADupdate.exe" fullword ascii 278 | $x8 = "dll_installer.dll" fullword ascii 279 | $x9 = "\\restore\\" fullword ascii 280 | $x10 = "Q:\\__?__.lnk" fullword ascii 281 | $x11 = "Software\\Microsoft\\MSNetMng" fullword ascii 282 | $x12 = "\\shelldoc.dll" fullword ascii 283 | $x13 = "file size = %d bytes" fullword ascii 284 | $x14 = "\\MSAgent" fullword ascii 285 | $x15 = "Global\\RPCMutex" fullword ascii 286 | $x16 = "Global\\DirectMarketing" fullword ascii 287 | 288 | condition: 289 | ( $mz at 0 ) and filesize < 300000 and (( 2 of ($s*) ) or ( 1 of ($s*) and 6 of ($x*) ) or ( 14 of ($x*))) 290 | } 291 | 292 | rule Equation_Kaspersky_HDD_reprogramming_module 293 | { 294 | 295 | meta: 296 | description = "Equation Group Malware - HDD reprogramming module" 297 | author = "Florian Roth" 298 | reference = "http://goo.gl/ivt8EW" 299 | date = "2015/02/16" 300 | hash = "ff2b50f371eb26f22eb8a2118e9ab0e015081500" 301 | 302 | strings: 303 | $mz = { 4d 5a } 304 | $s0 = "nls_933w.dll" fullword ascii 305 | $s1 = "BINARY" fullword wide 306 | $s2 = "KfAcquireSpinLock" fullword ascii 307 | $s3 = "HAL.dll" fullword ascii 308 | $s4 = "READ_REGISTER_UCHAR" fullword ascii 309 | condition: 310 | ( $mz at 0 ) and filesize < 300000 and all of ($s*) 311 | } 312 | 313 | rule Equation_Kaspersky_EOP_Package 314 | { 315 | 316 | meta: 317 | description = "Equation Group Malware - EoP package and malware launcher" 318 | author = "Florian Roth" 319 | reference = "http://goo.gl/ivt8EW" 320 | date = "2015/02/16" 321 | hash = "2bd1b1f5b4384ce802d5d32d8c8fd3d1dc04b962" 322 | 323 | strings: 324 | $mz = { 4d 5a } 325 | $s0 = "abababababab" fullword ascii 326 | $s1 = "abcdefghijklmnopq" fullword ascii 327 | $s2 = "@STATIC" fullword wide 328 | $s3 = "$aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" fullword ascii 329 | $s4 = "@prkMtx" fullword wide 330 | $s5 = "prkMtx" fullword wide 331 | $s6 = "cnFormVoidFBC" fullword wide 332 | 333 | condition: 334 | ( $mz at 0 ) and filesize < 100000 and all of ($s*) 335 | } 336 | 337 | rule Equation_Kaspersky_TripleFantasy_Loader 338 | { 339 | 340 | meta: 341 | description = "Equation Group Malware - TripleFantasy Loader" 342 | author = "Florian Roth" 343 | reference = "http://goo.gl/ivt8EW" 344 | date = "2015/02/16" 345 | hash = "4ce6e77a11b443cc7cbe439b71bf39a39d3d7fa3" 346 | 347 | strings: 348 | $mz = { 4d 5a } 349 | $x1 = "Original Innovations, LLC" fullword wide 350 | $x2 = "Moniter Resource Protocol" fullword wide 351 | $x3 = "ahlhcib.dll" fullword wide 352 | $s0 = "hnetcfg.HNetGetSharingServicesPage" fullword ascii 353 | $s1 = "hnetcfg.IcfGetOperationalMode" fullword ascii 354 | $s2 = "hnetcfg.IcfGetDynamicFwPorts" fullword ascii 355 | $s3 = "hnetcfg.HNetFreeFirewallLoggingSettings" fullword ascii 356 | $s4 = "hnetcfg.HNetGetShareAndBridgeSettings" fullword ascii 357 | $s5 = "hnetcfg.HNetGetFirewallSettingsPage" fullword ascii 358 | 359 | condition: 360 | ( $mz at 0 ) and filesize < 50000 and ( all of ($x*) and all of ($s*) ) 361 | } 362 | 363 | /* Rule generated from the mentioned keywords */ 364 | 365 | rule Equation_Kaspersky_SuspiciousString 366 | { 367 | 368 | meta: 369 | description = "Equation Group Malware - suspicious string found in sample" 370 | author = "Florian Roth" 371 | reference = "http://goo.gl/ivt8EW" 372 | date = "2015/02/17" 373 | score = 60 374 | 375 | strings: 376 | $mz = { 4d 5a } 377 | $s1 = "i386\\DesertWinterDriver.pdb" fullword 378 | $s2 = "Performing UR-specific post-install..." 379 | $s3 = "Timeout waiting for the \"canInstallNow\" event from the implant-specific EXE!" 380 | $s4 = "STRAITSHOOTER30.exe" 381 | $s5 = "standalonegrok_2.1.1.1" 382 | $s6 = "c:\\users\\rmgree5\\" 383 | 384 | condition: 385 | ( $mz at 0 ) and filesize < 500000 and all of ($s*) 386 | } 387 | 388 | /* EquationDrug Update 11.03.2015 - http://securelist.com/blog/research/69203/inside-the-equationdrug-espionage-platform/ */ 389 | 390 | rule EquationDrug_NetworkSniffer1 391 | { 392 | 393 | meta: 394 | description = "EquationDrug - Backdoor driven by network sniffer - mstcp32.sys, fat32.sys" 395 | author = "Florian Roth @4nc4p" 396 | reference = "http://securelist.com/blog/research/69203/inside-the-equationdrug-espionage-platform/" 397 | date = "2015/03/11" 398 | hash = "26e787997a338d8111d96c9a4c103cf8ff0201ce" 399 | 400 | strings: 401 | $s0 = "Microsoft(R) Windows (TM) Operating System" fullword wide 402 | $s1 = "\\Registry\\User\\CurrentUser\\" fullword wide 403 | $s3 = "sys\\mstcp32.dbg" fullword ascii 404 | $s7 = "mstcp32.sys" fullword wide 405 | $s8 = "p32.sys" fullword ascii 406 | $s9 = "\\Device\\%ws_%ws" fullword wide 407 | $s10 = "\\DosDevices\\%ws" fullword wide 408 | $s11 = "\\Device\\%ws" fullword wide 409 | 410 | condition: 411 | all of them 412 | } 413 | 414 | rule EquationDrug_CompatLayer_UnilayDLL 415 | { 416 | 417 | meta: 418 | description = "EquationDrug - Unilay.DLL" 419 | author = "Florian Roth @4nc4p" 420 | reference = "http://securelist.com/blog/research/69203/inside-the-equationdrug-espionage-platform/" 421 | date = "2015/03/11" 422 | hash = "a3a31937956f161beba8acac35b96cb74241cd0f" 423 | 424 | strings: 425 | $mz = { 4d 5a } 426 | $s0 = "unilay.dll" fullword ascii 427 | 428 | condition: 429 | ( $mz at 0 ) and $s0 430 | } 431 | 432 | rule EquationDrug_HDDSSD_Op 433 | { 434 | 435 | meta: 436 | description = "EquationDrug - HDD/SSD firmware operation - nls_933w.dll" 437 | author = "Florian Roth @4nc4p" 438 | reference = "http://securelist.com/blog/research/69203/inside-the-equationdrug-espionage-platform/" 439 | date = "2015/03/11" 440 | hash = "ff2b50f371eb26f22eb8a2118e9ab0e015081500" 441 | 442 | strings: 443 | $s0 = "nls_933w.dll" fullword ascii 444 | 445 | condition: 446 | all of them 447 | } 448 | 449 | rule EquationDrug_NetworkSniffer2 450 | { 451 | 452 | meta: 453 | description = "EquationDrug - Network Sniffer - tdip.sys" 454 | author = "Florian Roth @4nc4p" 455 | reference = "http://securelist.com/blog/research/69203/inside-the-equationdrug-espionage-platform/" 456 | date = "2015/03/11" 457 | hash = "7e3cd36875c0e5ccb076eb74855d627ae8d4627f" 458 | 459 | strings: 460 | $s0 = "Microsoft(R) Windows (TM) Operating System" fullword wide 461 | $s1 = "IP Transport Driver" fullword wide 462 | $s2 = "tdip.sys" fullword wide 463 | $s3 = "sys\\tdip.dbg" fullword ascii 464 | $s4 = "dip.sys" fullword ascii 465 | $s5 = "\\Device\\%ws_%ws" fullword wide 466 | $s6 = "\\DosDevices\\%ws" fullword wide 467 | $s7 = "\\Device\\%ws" fullword wide 468 | 469 | condition: 470 | all of them 471 | } 472 | 473 | rule EquationDrug_NetworkSniffer3 474 | { 475 | 476 | meta: 477 | description = "EquationDrug - Network Sniffer - tdip.sys" 478 | author = "Florian Roth @4nc4p" 479 | reference = "http://securelist.com/blog/research/69203/inside-the-equationdrug-espionage-platform/" 480 | date = "2015/03/11" 481 | hash = "14599516381a9646cd978cf962c4f92386371040" 482 | 483 | strings: 484 | $s0 = "Corporation. All rights reserved." fullword wide 485 | $s1 = "IP Transport Driver" fullword wide 486 | $s2 = "tdip.sys" fullword wide 487 | $s3 = "tdip.pdb" fullword ascii 488 | 489 | condition: 490 | all of them 491 | } 492 | 493 | rule EquationDrug_VolRec_Driver 494 | { 495 | 496 | meta: 497 | description = "EquationDrug - Collector plugin for Volrec - msrstd.sys" 498 | author = "Florian Roth @4nc4p" 499 | reference = "http://securelist.com/blog/research/69203/inside-the-equationdrug-espionage-platform/" 500 | date = "2015/03/11" 501 | hash = "ee2b504ad502dc3fed62d6483d93d9b1221cdd6c" 502 | 503 | strings: 504 | $s0 = "msrstd.sys" fullword wide 505 | $s1 = "msrstd.pdb" fullword ascii 506 | $s2 = "msrstd driver" fullword wide 507 | 508 | condition: 509 | all of them 510 | } 511 | 512 | rule EquationDrug_KernelRootkit 513 | { 514 | 515 | meta: 516 | description = "EquationDrug - Kernel mode stage 0 and rootkit (Windows 2000 and above) - msndsrv.sys" 517 | author = "Florian Roth @4nc4p" 518 | reference = "http://securelist.com/blog/research/69203/inside-the-equationdrug-espionage-platform/" 519 | date = "2015/03/11" 520 | hash = "597715224249e9fb77dc733b2e4d507f0cc41af6" 521 | 522 | strings: 523 | $s0 = "Microsoft(R) Windows (TM) Operating System" fullword wide 524 | $s1 = "Parmsndsrv.dbg" fullword ascii 525 | $s2 = "\\Registry\\User\\CurrentUser\\" fullword wide 526 | $s3 = "msndsrv.sys" fullword wide 527 | $s5 = "\\REGISTRY\\MACHINE\\System\\CurrentControlSet\\Control\\Windows" fullword wide 528 | $s6 = "\\Device\\%ws_%ws" fullword wide 529 | $s7 = "\\DosDevices\\%ws" fullword wide 530 | $s9 = "\\Device\\%ws" fullword wide 531 | 532 | condition: 533 | all of them 534 | } 535 | 536 | rule EquationDrug_Keylogger 537 | { 538 | 539 | meta: 540 | description = "EquationDrug - Key/clipboard logger driver - msrtvd.sys" 541 | author = "Florian Roth @4nc4p" 542 | reference = "http://securelist.com/blog/research/69203/inside-the-equationdrug-espionage-platform/" 543 | date = "2015/03/11" 544 | hash = "b93aa17b19575a6e4962d224c5801fb78e9a7bb5" 545 | 546 | strings: 547 | $s0 = "\\registry\\machine\\software\\Microsoft\\Windows NT\\CurrentVersion" fullword wide 548 | $s2 = "\\registry\\machine\\SYSTEM\\ControlSet001\\Control\\Session Manager\\En" wide 549 | $s3 = "\\DosDevices\\Gk" fullword wide 550 | $s5 = "\\Device\\Gk0" fullword wide 551 | 552 | condition: 553 | all of them 554 | } 555 | 556 | rule EquationDrug_NetworkSniffer4 557 | { 558 | 559 | meta: 560 | description = "EquationDrug - Network-sniffer/patcher - atmdkdrv.sys" 561 | author = "Florian Roth @4nc4p" 562 | reference = "http://securelist.com/blog/research/69203/inside-the-equationdrug-espionage-platform/" 563 | date = "2015/03/11" 564 | hash = "cace40965f8600a24a2457f7792efba3bd84d9ba" 565 | 566 | strings: 567 | $s0 = "Copyright 1999 RAVISENT Technologies Inc." fullword wide 568 | $s1 = "\\systemroot\\" fullword ascii 569 | $s2 = "RAVISENT Technologies Inc." fullword wide 570 | $s3 = "Created by VIONA Development" fullword wide 571 | $s4 = "\\Registry\\User\\CurrentUser\\" fullword wide 572 | $s5 = "\\device\\harddiskvolume" fullword wide 573 | $s7 = "ATMDKDRV.SYS" fullword wide 574 | $s8 = "\\Device\\%ws_%ws" fullword wide 575 | $s9 = "\\DosDevices\\%ws" fullword wide 576 | $s10 = "CineMaster C 1.1 WDM Main Driver" fullword wide 577 | $s11 = "\\Device\\%ws" fullword wide 578 | $s13 = "CineMaster C 1.1 WDM" fullword wide 579 | 580 | condition: 581 | all of them 582 | } 583 | 584 | rule EquationDrug_PlatformOrchestrator 585 | { 586 | 587 | meta: 588 | description = "EquationDrug - Platform orchestrator - mscfg32.dll, svchost32.dll" 589 | author = "Florian Roth @4nc4p" 590 | reference = "http://securelist.com/blog/research/69203/inside-the-equationdrug-espionage-platform/" 591 | date = "2015/03/11" 592 | hash = "febc4f30786db7804008dc9bc1cebdc26993e240" 593 | 594 | strings: 595 | $s0 = "SERVICES.EXE" fullword wide 596 | $s1 = "\\command.com" fullword wide 597 | $s2 = "Microsoft(R) Windows (TM) Operating System" fullword wide 598 | $s3 = "LSASS.EXE" fullword wide 599 | $s4 = "Windows Configuration Services" fullword wide 600 | $s8 = "unilay.dll" fullword ascii 601 | 602 | condition: 603 | all of them 604 | } 605 | 606 | rule EquationDrug_NetworkSniffer5 607 | { 608 | 609 | meta: 610 | description = "EquationDrug - Network-sniffer/patcher - atmdkdrv.sys" 611 | author = "Florian Roth @4nc4p" 612 | reference = "http://securelist.com/blog/research/69203/inside-the-equationdrug-espionage-platform/" 613 | date = "2015/03/11" 614 | hash = "09399b9bd600d4516db37307a457bc55eedcbd17" 615 | 616 | strings: 617 | $s0 = "Microsoft(R) Windows (TM) Operating System" fullword wide 618 | $s1 = "\\Registry\\User\\CurrentUser\\" fullword wide 619 | $s2 = "atmdkdrv.sys" fullword wide 620 | $s4 = "\\Device\\%ws_%ws" fullword wide 621 | $s5 = "\\DosDevices\\%ws" fullword wide 622 | $s6 = "\\Device\\%ws" fullword wide 623 | 624 | condition: 625 | all of them 626 | } 627 | 628 | rule EquationDrug_FileSystem_Filter 629 | { 630 | 631 | meta: 632 | description = "EquationDrug - Filesystem filter driver – volrec.sys, scsi2mgr.sys" 633 | author = "Florian Roth @4nc4p" 634 | reference = "http://securelist.com/blog/research/69203/inside-the-equationdrug-espionage-platform/" 635 | date = "2015/03/11" 636 | hash = "57fa4a1abbf39f4899ea76543ebd3688dcc11e13" 637 | 638 | strings: 639 | $s0 = "volrec.sys" fullword wide 640 | $s1 = "volrec.pdb" fullword ascii 641 | $s2 = "Volume recognizer driver" fullword wide 642 | 643 | condition: 644 | all of them 645 | } 646 | 647 | rule apt_equation_keyword 648 | { 649 | 650 | meta: 651 | description = "Rule to detect Equation group's keyword in executable file" 652 | author = "Florian Roth @4nc4p" 653 | last_modified = "2015-09-26" 654 | reference = "http://securelist.com/blog/research/68750/equation-the-death-star-of-malware-galaxy/" 655 | 656 | strings: 657 | $a1 = "Backsnarf_AB25" wide 658 | $a2 = "Backsnarf_AB25" ascii 659 | 660 | condition: 661 | uint16(0) == 0x5a4d and 1 of ($a*) 662 | } --------------------------------------------------------------------------------
TABLE EXECUTE FILES