
![]() | BINLEX - เฟรมเวิร์กลักษณะทางพันธุกรรมแบบไบนารี หาก Maldevs คิดว่าไบนารีของพวกเขาคือ FUD พวกเขากำลังจะมีวิกฤตที่มีอยู่ |
Binlex เป็นเครื่องมือสำหรับนักวิเคราะห์มัลแวร์และนักวิจัยที่แยก คำแนะนำ บล็อกพื้นฐาน และ ฟังก์ชั่น จากไฟล์ไบนารีและจัดระเบียบให้เป็นลำดับชั้นที่มีโครงสร้างของ จีโนม โครโมโซม คู่อัลลีล และ ยีน -
การแบ่งลำดับชั้นนี้ช่วยให้ Binlex สามารถวิเคราะห์และเปรียบเทียบไบนารีมัลแวร์โดยการรักษาโครงสร้างรหัสของพวกเขาเช่น "ลายนิ้วมือ DNA" ทำให้ง่ายต่อการตรวจจับรูปแบบความคล้ายคลึงกันและการเปลี่ยนแปลงในตัวอย่าง
ซึ่งแตกต่างจากเครื่องมือที่อาศัย Pure Python ซึ่งอาจช้าหรือไม่ Binlex ได้รับการออกแบบมาเพื่อความเร็วความเรียบง่ายและความยืดหยุ่น อินเทอร์เฟซบรรทัดคำสั่ง ช่วยให้นักวิเคราะห์ค้นหารูปแบบใน ตัวอย่างมัลแวร์หลายร้อยหรือหลายพันตัวอย่าง ประหยัด เวลา ⏳และ ทรัพยากร ?
สำหรับนักพัฒนา Binlex นำเสนอการผูก Rust API และ Python เพื่อสร้างเครื่องมือตรวจจับที่กำหนดเองพร้อมข้อ จำกัด การออกใบอนุญาตน้อยที่สุด -
เป็นส่วนหนึ่งของการต่อสู้กับมัลแวร์ Binlex มีอิสระที่จะใช้ - เพียง ดาวน์โหลดไบนารี จากหน้ารุ่น -
Binlex เวอร์ชันล่าสุดให้คุณสมบัติที่น่าทึ่งต่อไปนี้!
| คุณสมบัติ | คำอธิบาย |
|---|---|
| แพลตฟอร์ม | - Windows? - macos? - Linux? |
| รูปแบบ | - PE - ผู้ชาย - เอลฟ์ |
| สถาปัตยกรรม | - AMD64 - i386 - CIL |
| - มัลติเธรด | - การจัดคิวการแยกส่วนที่ปลอดภัยของด้าย - เครื่องมือหลายเธรดเพื่อประสิทธิภาพสูงสุด |
| ประสิทธิภาพที่ปรับแต่งได้ | สลับคุณสมบัติเปิด/ปิดเพื่อเพิ่มประสิทธิภาพสำหรับกรณีการใช้งานของคุณ |
| - การบีบอัดสตริง JSON | บันทึกหน่วยความจำด้วยการบีบอัด JSON |
| - การแฮชความคล้ายคลึงกัน | - Minhash - tlsh - Sha256 |
| - สัญลักษณ์ฟังก์ชัน | - สัญลักษณ์ฟังก์ชันผ่านไปยัง binlex เป็นอินพุตมาตรฐานโดยใช้ blpdb , blelfsym หรือ blmachosym หรือเครื่องมือของคุณเอง |
| ? ️ ติดแท็ก | Tagging for Easy Organization |
| การทำเวที | เหมาะสำหรับการสร้างกฎของ Yara และตอนนี้มีความละเอียดของ Nibbles! |
| API | - API สนิม -python API |
| - คุณสมบัติการเรียนรู้ของเครื่องจักร | - คุณสมบัติปกติเพื่อความสม่ำเสมอ - ฟีเจอร์ Scaler Utility - การกรองลักษณะ - การฝึกอบรมตัวอย่าง ONNX - การจำแนกตัวอย่าง |
| การถ่ายภาพเสมือนจริง | - แคชการแมปที่มีประสิทธิภาพสำหรับภาพเสมือนจริง -? ️เข้ากันได้กับ ZFS / BTRFS - เร่งงานและการกรองซ้ำ ๆ - ความเร็วในการลดน้ำหนัก⚡ |
ด้วยการแคชภาพเสมือนจริง Binlex สามารถทำงานได้ด้วยความเร็วที่ดีขึ้นทำให้การวิ่งซ้ำเร็วขึ้นและมีประสิทธิภาพมากขึ้น
ในการสร้าง Binlex คุณต้องมีสนิม
การติดตั้งตรงไปตรงมาบน Linux และ MacOS
cargo build --release cd src/bindings/python/
virtualenv -p python3 venv/
source venv/bin/activate
pip install maturin[patchelf]
maturin develop
python
>> import binlex ในการสร้างแพ็คเกจสำหรับแพลตฟอร์มต่าง ๆ ใช้ Makefile
make zst # Make Arch Linux Package
make deb # Make Debian Package
make wheel # Make Python Wheel แพ็คเกจที่ได้จะอยู่ใน target/ ไดเรกทอรี
การติดตั้งปลั๊กอิน IDA นั้นง่ายต่อการติดตั้งเพียงตรวจสอบให้แน่ใจว่าคุณติดตั้งการผูก Python ในสภาพแวดล้อม Python สำหรับ IDA
ตอนนี้คัดลอกไดเรกทอรีสำหรับปลั๊กอิน Binlex ไปยังไดเรกทอรีปลั๊กอินของคุณ
mkdir -p ~ /.idapro/plugins/
cp -r scripts/plugins/ida/binlex/ ~ /.idapro/plugins/เมื่อคุณเปิด IDA คุณควรได้รับการต้อนรับด้วยข้อความต้อนรับ Binlex

การใช้ปลั๊กอิน IDA คุณมีคุณสมบัติต่าง ๆ ที่มีให้เพื่อช่วยคุณในการเขียนกฎของ Yara และการวิเคราะห์ความคล้ายคลึงกัน
เมนูหลัก:
เมนูบริบทของการถอดชิ้นส่วน:
รูปแบบการคัดลอกและคุณลักษณะการคัดลอก Hex มีวัตถุประสงค์เพื่อช่วยในกฎของ Yara และการคัดลอกแฮชที่คล้ายคลึงกันและการสแกนสำหรับการล่าสัตว์สำหรับข้อมูลที่คล้ายกัน
ในการเปรียบเทียบฐานข้อมูลหนึ่งกับอีกฐานข้อมูลให้ใช้คุณสมบัติการส่งออกเพื่อส่งออกไฟล์ JSON จากนั้นคลิก Compare Functions ซึ่งจะเติมตารางเมื่อเสร็จสิ้น
cargo docคุณยังสามารถเปิดเอกสารได้
cargo doc --openใน Binlex ลำดับชั้นของคำที่ได้รับแรงบันดาลใจทางพันธุกรรมใช้เพื่ออธิบายและเป็นสัญลักษณ์ของโครงสร้างและลักษณะของรหัสไบนารี คำศัพท์นี้สะท้อนถึงความสัมพันธ์ระหว่างนามธรรมที่แตกต่างกันและการเปรียบเทียบทางพันธุกรรมของพวกเขา:
จีโนม : แสดงถึงวัตถุแต่ละชิ้นที่ถูกวิเคราะห์เช่นฟังก์ชั่นหรือบล็อก มันห่อหุ้มข้อมูลทั้งหมดรวมถึงข้อมูลเมตาโครโมโซมและคุณลักษณะอื่น ๆ
โครโมโซม : แสดงถึงรูปแบบหลักหรือลำดับที่สกัดจากบล็อกหรือฟังก์ชั่น โครโมโซมทำหน้าที่เป็นพิมพ์เขียวสำหรับการระบุลักษณะสำคัญของไบนารีโดยไม่ต้องใช้หน่วยความจำตามที่ระบุไว้โดยไวลด์การ์ดเช่น ? ที่ซึ่งตัวแทนเสิร์ทการ์ดแสดงถึงยีนเดี่ยว
Allelelepair : หน่วยภายในโครโมโซมประกอบด้วย สองยีน คู่อัลลีลเป็นหน่วยการสร้างของโครโมโซมรวมยีนเป็นคู่ที่มีความหมาย
ยีน : หน่วยข้อมูลทางพันธุกรรมที่เล็กที่สุดซึ่งเป็นตัวแทนของข้อมูลเดียว (ครึ่งไบต์)
ความสัมพันธ์ระหว่างนามธรรมเหล่านี้สามารถมองเห็นได้ดังนี้:
Genome (function / block)
└── Chromosome (pattern / sequence)
└── AllelePair (two genes / single byte / two nibbles)
└── Gene (single nibble)
{
"type" : " block " ,
"architecture" : " amd64 " ,
"address" : 6442934577 ,
"next" : null ,
"to" : [],
"edges" : 0 ,
"prologue" : false ,
"conditional" : false ,
"chromosome" : {
"pattern" : " 4c8b47??498bc0 " ,
"feature" : [ 4 , 12 , 8 , 11 , 4 , 7 , 4 , 9 , 8 , 11 , 12 , 0 ],
"entropy" : 2.2516291673878226 ,
"sha256" : " 1f227bf409b0d9fbc576e747de70139a48e42edec60a18fe1e6efdacb598f551 " ,
"minhash" : " 09b8b1ad1142924519f601854444c6c904a3063942cda4da445721dd0703f290208f3e32451bf5d52741e381a13f12f9142b5de21828a00b2cf90cf77948aac4138443c60bf77ec31199247042694ebb2e4e14a41369eddc7d9f84351be34bcf61458425383a03a55f80cbad420bb6e638550c15876fd0c6208da7b50816847e62d72b2c13a896f4849aa6a36188be1d4a5333865eab570e3939fab1359cbd16758f36fa290164d0259f83c07333df535b2e38f148298db255ac05612cae04d60bb0dd810a91b80a7df9615381e9dc242969dd052691d044287ac2992f9092fa0a75d970100d48362f62b58f7f1d9ec594babdf52f58180c30f4cfca142e76bf " ,
"tlsh" : null
},
"size" : 7 ,
"bytes" : " 4c8b4708498bc0 " ,
"functions" : {},
"number_of_instructions" : 3 ,
"entropy" : 2.5216406363433186 ,
"sha256" : " 84d4485bfd833565fdf41be46c1a499c859f0a5f04c8c99ea9c34404729fd999 " ,
"minhash" : " 20c995de6a15c8a524fa7e325a6e42b217b636ab03b00812732f877f4739eeee41d7dde92ceac73525e541f9091d8dc928f6425b84a6f44b3f01d17912ec6e8c6f913a760229f685088d2528447e40c768c06d680afe63cb219a1b77a097f679122804dd5a1b9d990aa2579e75f8ef201eeb20d5650da5660efa3a281983a37f28004f9f2a57af8f81728c7d1b02949609c7ad5a30125ff836d8cc3106f2531f306e679a11cabf992556802a3cb2a75a7fe3773e37e3d5ab107a23bf22754aee15a5f41056859b06120f86cb5d39071425855ec90628687741aa0402030d73e04bc60adb0bd2430560442c4309ae258517fc1605438c95485ac4c8621026a1bb " ,
"tlsh" : null ,
"contiguous" : true ,
"attributes" : [
{
"type" : " tag " ,
"value" : " corpus:malware "
},
{
"type" : " tag " ,
"value" : " malware:lummastealer "
},
{
"entropy" : 6.55061550644311 ,
"sha256" : " ec1426109420445df8e9799ac21a4c13364dc12229fb16197e428803bece1140 " ,
"size" : 725696 ,
"tlsh" : " T17AF48C12AF990595E9BBC23DD1974637FAB2B445232047CF426489BD0E1BBE4B73E381 " ,
"type" : " file "
}
]
}จากตัวอย่างจีโนม JSON นี้
"4c8b47??498bc0""4c" หรือ "8b""4" หรือ "c"การใช้ Binlex API เป็นไปได้ที่จะกลายพันธุ์โครโมโซมเหล่านี้คู่อัลลีลและยีนของพวกเขาเพื่ออำนวยความสะดวกในการเขียนโปรแกรมทางพันธุกรรม
การเขียนโปรแกรมทางพันธุกรรมในบริบทนี้อาจมีหลายชนิดรวมถึง แต่ไม่ จำกัด เพียง:
วิธีที่ง่ายที่สุดในการเริ่มต้นคือกับบรรทัดคำสั่งใช้ประโยชน์จากเครื่องมือกรอง JSON เช่น jq
คำสั่งต่อไปนี้แยก sample.dll ด้วย 16 เธรดลักษณะที่เกี่ยวข้องคือวัตถุ JSON หนึ่งต่อบรรทัดและถูกส่งเข้าไปใน jq สำหรับการกรองและการตกแต่ง
หากต้องการดูว่ามีตัวเลือกใดบ้างเมื่อใช้การใช้บรรทัดคำสั่ง binlex -h หรือ --help
A Binary Pattern Lexer
Version: 2.0.0
Usage: binlex [OPTIONS] --input < INPUT >
Options:
-i, --input < INPUT >
-o, --output < OUTPUT >
-a, --architecture < ARCHITECTURE > [amd64, i386, cil]
-c, --config < CONFIG >
-t, --threads < THREADS >
--tags < TAGS >
--minimal
-d, --debug
--enable-instructions
--enable-block-instructions
--disable-hashing
--disable-disassembler-sweep
--disable-heuristics
--enable-mmap-cache
--mmap-directory < MMAP_DIRECTORY >
-h, --help Print help
-V, --version Print version
Author: @c3rb3ru5d3d53cตัวอย่างง่ายๆของการใช้บรรทัดคำสั่งมีให้ด้านล่าง
binlex -i sample.dll --threads 16 | jq โปรดทราบว่า Binlex จะตรวจจับรูปแบบไฟล์ป้อมคุณและปัจจุบันรองรับรูปแบบ PE , ELF และ MACHO Binary
เมื่อดำเนินการครั้งแรกของ Binlex มันจะจัดเก็บไฟล์การกำหนดค่าในไดเรกทอรีการกำหนดค่าของคุณใน binlex/binlex.toml
Binlex นี้ค้นหาไดเรกทอรีการกำหนดค่าเริ่มต้นตามระบบปฏิบัติการของคุณตามที่ระบุไว้ในตารางด้านล่างสำหรับการกำหนดค่า
| ระบบปฏิบัติการ | ตัวแปรสภาพแวดล้อม | ตัวอย่างเส้นทางการกำหนดค่า binlex |
|---|---|---|
| ลินเวกซ์ | $XDG_CONFIG_HOME หรือ $HOME/.config | /home/alice/.config/binlex/binlex.toml |
| แม็กอส | $HOME/Library/Application Support | /Users/Alice/Library/Application Support/binlex/binlex.toml |
| หน้าต่าง | {FOLDERID_RoamingAppData} | C:UsersAliceAppDataRoamingbinlexbinlex.toml |
ชื่อการกำหนดค่าเริ่มต้น binlex.toml สำหรับ binlex มีให้ด้านล่าง
[ general ]
threads = 16
minimal = false
debug = false
[ formats . file . hashing . sha256 ]
enabled = true
[ formats . file . hashing . tlsh ]
enabled = true
minimum_byte_size = 50
threshold = 200
[ formats . file . hashing . minhash ]
enabled = true
number_of_hashes = 64
shingle_size = 4
maximum_byte_size_enabled = false
maximum_byte_size = 50
seed = 0
threshold = 0.75
[ formats . file . heuristics . features ]
enabled = true
[ formats . file . heuristics . entropy ]
enabled = true
[ instructions ]
enabled = false
[ instructions . hashing . sha256 ]
enabled = true
[ instructions . hashing . tlsh ]
enabled = true
minimum_byte_size = 50
threshold = 200
[ instructions . hashing . minhash ]
enabled = true
number_of_hashes = 64
shingle_size = 4
maximum_byte_size_enabled = false
maximum_byte_size = 50
seed = 0
threshold = 0.75
[ instructions . heuristics . features ]
enabled = true
[ instructions . heuristics . entropy ]
enabled = true
[ blocks ]
enabled = true
[ blocks . instructions ]
enabled = false
[ blocks . hashing . sha256 ]
enabled = true
[ blocks . hashing . tlsh ]
enabled = true
minimum_byte_size = 50
threshold = 200
[ blocks . hashing . minhash ]
enabled = true
number_of_hashes = 64
shingle_size = 4
maximum_byte_size_enabled = false
maximum_byte_size = 50
seed = 0
threshold = 0.75
[ blocks . heuristics . features ]
enabled = true
[ blocks . heuristics . entropy ]
enabled = true
[ functions ]
enabled = true
[ functions . blocks ]
enabled = true
[ functions . hashing . sha256 ]
enabled = true
[ functions . hashing . tlsh ]
enabled = true
minimum_byte_size = 50
threshold = 200
[ functions . hashing . minhash ]
enabled = true
number_of_hashes = 64
shingle_size = 4
maximum_byte_size_enabled = false
maximum_byte_size = 50
seed = 0
threshold = 0.75
[ functions . heuristics . features ]
enabled = true
[ functions . heuristics . entropy ]
enabled = true
[ chromosomes . hashing . sha256 ]
enabled = true
[ chromosomes . hashing . tlsh ]
enabled = true
minimum_byte_size = 50
threshold = 200
[ chromosomes . hashing . minhash ]
enabled = true
number_of_hashes = 64
shingle_size = 4
maximum_byte_size_enabled = false
maximum_byte_size = 50
seed = 0
threshold = 0.75
[ chromosomes . heuristics . features ]
enabled = true
[ chromosomes . heuristics . entropy ]
enabled = true
[ chromosomes . homologues ]
enabled = true
maximum = 4
[ mmap ]
directory = " /tmp/binlex "
[ mmap . cache ]
enabled = false
[ disassembler . sweep ]
enabled = trueหากตัวเลือกบรรทัดคำสั่งไม่เพียงพอไฟล์การกำหนดค่าจะให้การควบคุมที่ละเอียดที่สุดของตัวเลือกทั้งหมด
หากคุณต้องการแทนที่ไฟล์การกำหนดค่าเริ่มต้นและระบุไฟล์การกำหนดค่าอื่นใช้พารามิเตอร์บรรทัดคำสั่ง
binlex -c config.toml -i sample.dllเมื่อคุณเรียกใช้ binlex จะใช้ไฟล์การกำหนดค่าและแทนที่การตั้งค่าใด ๆ เมื่อใช้พารามิเตอร์บรรทัดคำสั่งที่เกี่ยวข้อง
นี่คือเวิร์กโฟลว์ทั่วไปที่เริ่มต้นด้วยการทำกฎของ Yara ซึ่งเราได้รับ 10 สาย Yara Hex ที่ไม่เหมือนใครจากตัวอย่างที่กำหนด
binlex -i sample.dll --threads 16 | jq -r ' select(.size >= 16 and .size <= 32 and .chromosome.pattern != null) | .chromosome.pattern ' | sort | uniq | head -10
016b ?? 8b4b ?? 8bc74c6bd858433b4c0b2c0f83c5 ??????
01835404 ???? c6836a0400 ???? 837e04 ??
03c04c8d05 ???????? 4863c8420fb60401460fb64401018942 ?? 85c074 ??
03c38bf0488d140033c9ff15 ???????? 488bd84885c075 ??
03c6488d55 ?? 41ffc58945a ? 41b804000000418bcce8b8fd01 ?? eb ??
03c6488d55 ?? 41ffc58945a ? 41b804000000418bcce8e3fb01 ?? eb ??
03f7488d05 ???????? 4883c310483bd87c ??
03fb4c8bc6498bd7498bcc448d0c7d04000000e89409 ???? 8bd84885f6
03fe448bc6488bd3418bcee8d8e501 ?? 85ed
03fe897c24 ?? 397c24 ?? 0f867301 ???? ในการก้าวไปอีกขั้นตอนนี้คุณสามารถเรียกใช้ผ่านเครื่องมือ blyara เพื่อสร้างลายเซ็น Yara อย่างรวดเร็ว
binlex -i sample.dll --threads 16 | jq -r ' select(.size >= 16 and .size <= 32 and .chromosome.pattern != null) | .chromosome.pattern ' | sort | uniq | head -10 | blyara -n example
rule example {
strings:
$trait_0 = {016b ?? 8b4b ?? 8bc74c6bd858433b4c0b2c0f83c5 ?????? }
$trait_1 = {01835404 ???? c6836a0400 ???? 837e04 ?? }
$trait_2 = {03c04c8d05 ???????? 4863c8420fb60401460fb64401018942 ?? 85c074 ?? }
$trait_3 = {03c38bf0488d140033c9ff15 ???????? 488bd84885c075 ?? }
$trait_4 = {03c6488d55 ?? 41ffc58945a ? 41b804000000418bcce8b8fd01 ?? eb ?? }
$trait_5 = {03c6488d55 ?? 41ffc58945a ? 41b804000000418bcce8e3fb01 ?? eb ?? }
$trait_6 = {03f7488d05 ???????? 4883c310483bd87c ?? }
$trait_7 = {03fb4c8bc6498bd7498bcc448d0c7d04000000e89409 ???? 8bd84885f6}
$trait_8 = {03fe448bc6488bd3418bcee8d8e501 ?? 85ed}
$trait_9 = {03fe897c24 ?? 397c24 ?? 0f867301 ???? }
condition:
1 of them เพื่อผลลัพธ์ที่ดียิ่งขึ้นหากคุณส่งออก จีโนม โดยใช้ปลั๊กอิน Binlex IDA หรือโดยวิธีอื่นคุณสามารถกรองสำหรับฟังก์ชั่นคำนำหน้าเช่น mw:: สำหรับ malware ซึ่งเป็นเรื่องธรรมดา
cat dump.json | jq -r ' select(.type == "function" and .size > 32 and (.attributes[] | .type == "symbol" and (.name | startswith("mw::")))) | .blocks[] | select(.size > 32) | .chromosome.pattern ' | blyara -n example หากต้องการใช้ binlex กับ ghidra ให้ใช้สคริปต์ blghidra/blghidra.py ในไดเรกทอรีสคริปต์
ในการใช้ประโยชน์จากชื่อฟังก์ชั่นและที่อยู่เสมือนจริงจากโครงการ Ghidra ของคุณและให้พวกเขาไปยัง Binlex ใช้สคริปต์ analyzeHeadless ในไดเรกทอรีการติดตั้ง Ghidra ของคุณ
./analyzeHeadless
< project-directory >
< project-name >
-process sample.dll
-noanalysis
-postscript blghidra.py 2> /dev/null | grep -P " ^{ " type " | binlex -i sample.dll โปรดทราบว่า analyzeHeadless ข้อความบันทึกการพิมพ์แบบไม่มีการพิมพ์ไปยัง stdout และเอาต์พุตบันทึกอื่น ๆ ไปยัง stderr ที่ไม่มีการใช้งานการทำงานร่วมกันกับยูทิลิตี้บรรทัดคำสั่งอื่น ๆ
ดังนั้นเพื่อรวบรวมผลลัพธ์ของสคริปต์จึงต้องกรองด้วย 2>/dev/null | grep -P "^{"type"
หากต้องการใช้ประโยชน์จากพลังของการตรวจจับฟังก์ชั่น Rizin และการตั้งชื่อฟังก์ชั่นใน Binlex ให้เรียกใช้ rizin ในโครงการของคุณโดยใช้ aflj เพื่อแสดงรายการฟังก์ชั่นในรูปแบบ JSON
จากนั้นส่งเอาท์พุทนี้ไปยัง blrizin ซึ่งแยกวิเคราะห์ rizin json ไปยังรูปแบบ binlex undestands
นอกจากนี้คุณสามารถรวมสิ่งนี้เข้ากับเครื่องมืออื่น ๆ เช่น blpdb เพื่อแยกวิเคราะห์สัญลักษณ์ PDB เพื่อรับที่อยู่และชื่อของฟังก์ชั่น
จากนั้นคุณสามารถทำการแยกวิเคราะห์ใด ๆ ตามที่คุณใช้ jq ในตัวอย่างนี้เรานับฟังก์ชั่นที่ประมวลผลโดย Binlex เพื่อดูว่าเรากำลังตรวจจับพวกเขามากขึ้นหรือไม่
rizin -c ' aaa;aflj; ' -q sample.dll |
blrizin |
blpdb -i sample.pdb |
binlex -i sample.dll |
jq ' select(.type == "function") | .address ' | wc -l หมายเหตุ : ในเวลานี้ blrizin ยังสามารถใช้งานได้กับเอาต์พุตจาก radare2 โดยใช้ blrizin
หากคุณต้องการทำการเรียนรู้ของเครื่องจักรคุณสามารถรับคุณสมบัติที่แสดงถึง nibbles โดยไม่ต้องใช้ที่อยู่หน่วยความจำจาก Binlex เช่นนี้
binlex -i sample.dll --threads 16 | jq -r -c ' select(.size >= 16 and .size <= 32 and .signature.feature != null)| .signature.feature ' | head -10
[4,9,8,11,12,0,4,1,11,9,0,3,0,0,1,15,0,0,4,5,3,3,12,0,8,5,13,2,4,8,8,11,13,0,4,1,0,15,9,5,12,0,4,8,15,15,2,5]
[4,4,8,11,5,1,4,5,3,3,12,0,3,3,12,0,4,8,8,3,12,1,3,0,4,1,0,15,10,3,12,2]
[4,8,8,3,14,12,4,12,8,11,12,10,4,4,8,9,4,4,2,4,11,2,0,1,4,4,0,15,11,7,12,1,8,10,12,10,14,8,5,11,4,8,8,3,12,4,12,3]
[4,8,8,3,14,12,4,4,8,9,4,4,2,4,4,12,8,11,12,10,4,4,0,15,11,7,12,1,11,2,0,1,3,3,12,9,14,8,0,11,4,8,8,3,12,4,12,3]
[4,0,5,3,4,8,8,3,14,12,15,15,1,5,8,11,12,8,8,11,13,8,15,15,1,5,8,11,12,3,4,8,8,3,12,4,5,11,12,3]
[11,9,2,0,0,3,15,14,7,15,4,8,8,11,8,11,0,4,2,5,4,8,0,15,10,15,12,1,4,8,12,1,14,8,1,8,12,3]
[8,11,0,12,2,5,11,8,2,0,0,3,15,14,7,15,4,8,12,1,14,1,2,0,4,8,8,11,4,8,12,1,14,0,0,8,4,8,15,7,14,1,4,8,8,11,12,2,12,3]
[4,8,8,11,0,5,4,8,8,5,12,0,7,5,12,3,4,8,15,15,2,5]
[4,8,8,11,0,13,3,3,12,0,3,8,8,1,11,0,0,8,0,15,9,5,12,0,12,3]
[4,8,8,11,0,5,4,8,8,5,12,0,7,5,12,3,4,8,15,15,2,5] หากคุณต้องการปรับแต่งสิ่งนี้สำหรับรูปแบบการเรียนรู้ของเครื่องของคุณโดยการทำให้เป็นมาตรฐานระหว่าง 0 ถึง 1 ค่าลอยตัว Binlex คุณครอบคลุมด้วยเครื่องมือ blscaler
binlex -i sample.dll --threads 16 | jq -r -c ' select(.size >= 16 and .size <= 32 and .signature.feature != null) ' | blscaler --threads 16 | jq -c -r ' .signature.feature ' | head -1
[0.26666666666666666,0.6,0.5333333333333333,0.7333333333333333,0.8,0.0,0.26666666666666666,0.06666666666666667,0.7333333333333333,0.6,0.0,0.2,0.0,0.0,0.06666666666666667,1.0,0.0,0.0,0.26666666666666666,0.3333333333333333,0.2,0.2,0.8,0.0,0.5333333333333333,0.3333333333333333,0.8666666666666667,0.13333333333333333,0.26666666666666666,0.5333333333333333,0.5333333333333333,0.7333333333333333,0.8666666666666667,0.0,0.26666666666666666,0.06666666666666667,0.0,1.0,0.6,0.3333333333333333,0.8,0.0,0.26666666666666666,0.5333333333333333,1.0,1.0,0.13333333333333333,0.3333333333333333]เพื่อใช้ประโยชน์จากคุณสมบัติที่ทรงพลังของการใช้งานเพื่อลดการใช้หน่วยความจำ แต่ยังคงเป็นประโยชน์จากภาพเสมือนจริง
# Install BTRFS
sudo pacman -S btrfs-progs compsize
# Enable the Kernel Module on Boot
echo " btrfs " | sudo tee /etc/modules-load.d/btrfs.conf
# Reboot
reboot
# Create Virtual Image Cache Storage Pool
dd if=/dev/zero of=btrfs.img bs=1M count=2048
# Make it BTRFS
mkfs.btrfs btrfs.img
# Make a Cache Directory in /tmp/
mkdir -p /tmp/binlex/
# Mount the Cache (Multiple Compression Options Available)
sudo mount -o compress=lzo btrfs.img /tmp/binlex/
# Run Binlex
binlex -i sample.dll --threads 16 --enable-file-mapping --file-mapping-directory /tmp/binlex/ --enable-file-mapping-cache
sudo compsize ec1426109420445df8e9799ac21a4c13364dc12229fb16197e428803bece1140
# Virtual Image 6GB vs Stored Size of 192MB
# Processed 1 file, 49156 regular extents (49156 refs), 0 inline.
# Type Perc Disk Usage Uncompressed Referenced
# TOTAL 3% 192M 6.0G 6.0G
# none 100% 384K 384K 384K
# lzo 3% 192M 6.0G 6.0G สิ่งนี้สามารถตั้งค่านี้ให้อยู่ในดิสก์หรือ IF /tmp/ ไดเรกทอรีถูกแมปกับ RAM
เมื่อแมปกับ RAM เรากำลังใช้ประโยชน์จากการถอดประกอบภาพเสมือนจริง แต่ไม่มีการลงโทษ RAM เพิ่มเติมที่งานซ้ำ ๆ เกือบสองเท่าในการประมวลผลความเร็ว
เนื่องจาก btrfs เป็นบทสรุปการเข้าถึงไฟล์ที่แมปในเคอร์เนลเราจึงสามารถเข้าถึงได้เช่นเดียวกับที่เราต้องการไฟล์ใด ๆ แต่ด้วยประโยชน์ของการบีบอัด
หากต้องการประหยัดเวลาด้วยตัวเองหากคุณเลือกตัวเลือกนี้ให้การติดตั้งพูล btrfs เกิดขึ้นในการบู๊ตและตั้งค่าไฟล์การกำหนดค่า Binlex ของคุณให้เลือกการแคชภาพเสมือนจริงในไดเรกทอรีพูลที่ติดตั้ง วิธีการนี้ทำให้มั่นใจได้ว่าคุณไม่จำเป็นต้องพึ่งพาพารามิเตอร์บรรทัดคำสั่งในแต่ละครั้ง
Philophsy of the Binlex Project มุ่งเน้นไปที่ความปลอดภัยความเรียบง่ายความเร็วและความยืดหยุ่น
ส่วนหนึ่งของสิ่งนี้คือการให้ API สำหรับนักพัฒนาเพื่อเขียนการตรวจจับและการล่าตรรกะของตนเอง
ในเวลานี้ Binlex ให้ทั้งการผูกสนิมและ Python
Rust, API Make เป็นเรื่องง่ายที่จะเริ่มต้น
use std :: process ;
use binlex :: Config ;
use binlex :: formats :: PE ;
use binlex :: disassemblers :: capstone :: Disassembler ;
use binlex :: controlflow :: Graph ;
// Get Default Configuration
let mut config = Config ( ) ;
// Use 16 Threads for Multi-Threaded Operations
config . general . threads = 16 ;
// Read PE File
let pe = PE . new ( "./sample.dll" , config )
. unwrap_or_else ( |error| {
eprintln ! ( "{}" , error ) ;
process :: exit ( 1 ) ;
} ) ;
// To check if DotNet PE use pe.is_dotnet()
// Get Memory Mapped File
let mapped_file = pe . image ( )
. unwrap_or_else ( |error| {
eprintln ! ( "{}" , error ) ;
process :: exit ( 1 )
} ) ;
// Get Mapped File Virtual Image
let image = mapped_file
. mmap ( )
. unwrap_or_else ( |error| {
eprintln ! ( "{}" , error ) ;
process :: exit ( 1 ) ;
} ) ;
// Create Disassembler
let disassembler = Disassembler ( pe . architecture ( ) , & image , pe . executable_virtual_address_ranges ( ) , config )
. unwrap_or_else ( |error| {
eprintln ! ( "{}" , error ) ;
process :: exit ( 1 ) ;
} ) ;
// Create Control Flow Graph
let cfg = Graph ( pe . architecture ( ) , config ) ;
// Disassemble Control Flow
disassembler . disassemble_controlflow ( pe . entrypoint_virtual_addresses ( ) , & mut cfg ) ; use std :: process ;
use binlex :: Config ;
use binlex :: formats :: PE ;
use binlex :: disassemblers :: custom :: cil :: Disassembler ;
use binlex :: controlflow :: Graph ;
// Get Default Configuration
let mut config = Config ( ) ;
// Use 16 Threads for Multi-Threaded Operations
config . general . threads = 16 ;
// Read PE File
let pe = PE . new ( "./sample.exe" , config )
. unwrap_or_else ( |error| {
eprintln ! ( "{}" , error ) ;
process :: exit ( 1 ) ;
} ) ;
// To check if DotNet PE use pe.is_dotnet()
// Get Memory Mapped File
let mapped_file = pe . image ( )
. unwrap_or_else ( |error| {
eprintln ! ( "{}" , error ) ;
process :: exit ( 1 )
} ) ;
// Get Mapped File Virtual Image
let image = mapped_file
. mmap ( )
. unwrap_or_else ( |error| {
eprintln ! ( "{}" , error ) ;
process :: exit ( 1 ) ;
} ) ;
// Create Disassembler
let disassembler = Disassembler ( pe . architecture ( ) , & image , pe . dotnet_metadata_token_virtual_addresses ( ) , pe . dotnet_executable_virtual_address_ranges ( ) , config )
. unwrap_or_else ( |error| {
eprintln ! ( "{}" , error ) ;
process :: exit ( 1 ) ;
} ) ;
// Create Control Flow Graph
let cfg = Graph ( pe . architecture ( ) , config ) ;
// Disassemble Control Flow
disassembler . disassemble_controlflow ( pe . dotnet_entrypoint_virtual_addresses ( ) , & mut cfg ) ; use std :: process ;
use binlex :: Config ;
use binlex :: formats :: ELF ;
use binlex :: disassemblers :: custom :: cil :: Disassembler ;
use binlex :: controlflow :: Graph ;
// Get Default Configuration
let mut config = Config ( ) ;
// Use 16 Threads for Multi-Threaded Operations
config . general . threads = 16 ;
// Read PE File
let elf = ELF . new ( "./sample.exe" , config )
. unwrap_or_else ( |error| {
eprintln ! ( "{}" , error ) ;
process :: exit ( 1 ) ;
} ) ;
// Get Memory Mapped File
let mapped_file = elf . image ( )
. unwrap_or_else ( |error| {
eprintln ! ( "{}" , error ) ;
process :: exit ( 1 )
} ) ;
// Get Mapped File Virtual Image
let image = mapped_file
. mmap ( )
. unwrap_or_else ( |error| {
eprintln ! ( "{}" , error ) ;
process :: exit ( 1 ) ;
} ) ;
// Create Disassembler
let disassembler = Disassembler ( elf . architecture ( ) , & image , elf . executable_virtual_address_ranges ( ) , config )
. unwrap_or_else ( |error| {
eprintln ! ( "{}" , error ) ;
process :: exit ( 1 ) ;
} ) ;
// Create Control Flow Graph
let cfg = Graph ( elf . architecture ( ) , config ) ;
// Disassemble Control Flow
disassembler . disassemble_controlflow ( elf . entrypoint_virtual_addresses ( ) , & mut cfg ) ; use std :: process ;
use binlex :: Config ;
use binlex :: formats :: MACHO ;
use binlex :: disassemblers :: custom :: cil :: Disassembler ;
use binlex :: controlflow :: Graph ;
// Get Default Configuration
let mut config = Config ( ) ;
// Use 16 Threads for Multi-Threaded Operations
config . general . threads = 16 ;
// Read PE File
let macho = MACHO . new ( "./sample.app" , config )
. unwrap_or_else ( |error| {
eprintln ! ( "{}" , error ) ;
process :: exit ( 1 ) ;
} ) ;
// Iterate the MACHO Fat Binary Slices
for index in macho . number_of_slices ( ) {
// Get Memory Mapped File
let mapped_file = macho . image ( index )
. unwrap_or_else ( |error| {
eprintln ! ( "{}" , error ) ;
process :: exit ( 1 )
} ) ;
// Get Mapped File Virtual Image
let image = mapped_file
. mmap ( )
. unwrap_or_else ( |error| {
eprintln ! ( "{}" , error ) ;
process :: exit ( 1 ) ;
} ) ;
// Create Disassembler
let disassembler = Disassembler ( macho . architecture ( index ) , & image , macho . executable_virtual_address_ranges ( index ) , config )
. unwrap_or_else ( |error| {
eprintln ! ( "{}" , error ) ;
process :: exit ( 1 ) ;
} ) ;
// Create Control Flow Graph
let cfg = Graph ( macho . architecture ( index ) , config ) ;
// Disassemble Control Flow
disassembler . disassemble_controlflow ( macho . entrypoints ( index ) , & mut cfg ) ;
} use binlex :: controlflow :: Instruction ;
use binlex :: controlflow :: Block ;
use binlex :: controlflow :: Function ;
for address in cfg . instructions . valid_addresses ( ) {
// Read Instruction from Control Flow
instruction = Instruction ( address , & cfg ) ;
// Print Instruction from Control Flow
instruction . print ( ) ;
}
for address in cfg . blocks . valid_addresses ( ) {
// Read Block from Control Flow
block = Block ( address , & cfg ) ;
// Print Block from Control Flow
block . print ( ) ;
}
for address in cfg . functions . valid_addresses ( ) {
// Read Function from Control Flow
function = Function ( address , & cfg ) ;
// Print Function from Control Flow
function . print ( ) ;
}ตอนนี้ Binlex Python API ได้รับการออกแบบมาเพื่อนามธรรม Disassembler และกราฟ Controlflow
ในการถอดประกอบภาพที่แมปหน่วยความจำ PE ให้ใช้ตัวอย่างต่อไปนี้
มีตัวอย่างเพิ่มเติมใน examples/python/ Directory
from binlex . formats import PE
from binlex . disassemblers . capstone import Disassembler
from binlex . controlflow import Graph
from binlex import Config
# Get Default Configuration
config = Config ()
# Use 16 Threads for Multi-Threaded Operations
config . general . threads = 16
# Open the PE File
pe = PE ( './sample.exe' , config )
# To check if a DotNet PE use ps.is_dotnet()
# Get the Memory Mapped File
mapped_file = pe . image ()
# Get the Memory Map
image = mapped_file . as_memoryview ()
# Create Disassembler on Mapped PE Image and PE Architecture
disassembler = Disassembler ( pe . architecture (), image , pe . executable_virtual_address_ranges (), config )
# Create the Controlflow Graph
cfg = Graph ( pe . architecture (), config )
# Disassemble the PE Image Entrypoints Recursively
disassembler . disassemble_controlflow ( pe . entrypoint_virtual_addresses (), cfg ) from binlex . formats import PE
from binlex . disassemblers . custom . cil import Disassembler
from binlex . controlflow import Graph
from binlex import Config
# Get Default Configuration
config = Config ()
# Use 16 Threads for Multi-Threaded Operations
config . general . threads = 16
# Open the PE File
pe = PE ( './sample.exe' , config )
# To check if a DotNet PE use ps.is_dotnet()
# Get the Memory Mapped File
mapped_file = pe . image ()
# Get the Memory Map
image = mapped_file . as_memoryview ()
# Create Disassembler on Mapped PE Image and PE Architecture
disassembler = Disassembler ( pe . architecture (), image , pe . dotnet_metadata_token_virtual_addresses (), pe . dotnet_executable_virtual_address_ranges (), config )
# Create the Controlflow Graph
cfg = Graph ( pe . architecture (), config )
# Disassemble the PE Image Entrypoints Recursively
disassembler . disassemble_controlflow ( pe . dotnet_entrypoint_virtual_addresses (), cfg ) from binlex . formats import ELF
from binlex . disassemblers . capstone import Disassembler
from binlex . controlflow import Graph
from binlex import Config
# Get Default Configuration
config = Config ()
# Use 16 Threads for Multi-Threaded Operations
config . general . threads = 16
# Open the ELF File
elf = ELF ( './sample.so' , config )
# Get the Memory Mapped File
mapped_file = pe . image ()
# Get the Memory Map
image = mapped_file . as_memoryview ()
# Create Disassembler on Mapped ELF Image and ELF Architecture
disassembler = Disassembler ( elf . architecture (), image , elf . executable_virtual_address_ranges (), config )
# Create the Controlflow Graph
cfg = Graph ( elf . architecture (), config )
# Disassemble the PE Image Entrypoints Recursively
disassembler . disassemble_controlflow ( elf . entrypoint_virtual_addresses (), cfg ) from binlex . formats import MACHO
from binlex . disassemblers . capstone import Disassembler
from binlex . controlflow import Graph
from binlex import Config
# Get Default Configuration
config = Config ()
# Use 16 Threads for Multi-Threaded Operations
config . general . threads = 16
# Open the ELF File
macho = MACHO ( './sample.app' , config )
# MachO Fat Binary Can Support Multiple Architectures
for index in macho . number_of_slices ():
# Get the Memory Mapped File
mapped_file = macho . image ( index )
# Get the Memory Map
image = mapped_file . as_memoryview ()
# Create Disassembler on Mapped MACHO Image and MACHO Architecture
disassembler = Disassembler ( macho . architecture ( index ), image , macho . executable_virtual_address_ranges ( index ), config )
# Create the Controlflow Graph
cfg = Graph ( macho . architecture ( index ), config )
# Disassemble the MACHO Image Entrypoints Recursively
disassembler . disassemble_controlflow ( macho . entrypoints ( index ), cfg )บางครั้งอาจเป็น nessassary ที่จะแยกวิเคราะห์กราฟควบคุมที่สร้างขึ้น
ในกรณีนี้คุณสามารถใช้เทคนิคต่อไปนี้
from binlex . controlflow import Instruction
from binlex . controlflow import Block
from binlex . controlflow import Function
# Iterate Valid Instructions
for address in cfg . instructions . valid_addresses ():
# Read Instruction from Control Flow
instruction = Instruction ( address , cfg )
# Print Instruction from Control Flow
instruction . print ()
# Iterate Valid Blocks
for address in cfg . blocks . valid_addresses ():
# Read Block from Control Flow
block = Block ( address , cfg )
# Print Block from Control Flow
block . print ()
# Iterate Valid Functions
for address in cfg . functions . valid_addresses ():
# Read Function from Control Flow
function = Function ( address , cfg )
# Print Function from Control Flow
function . print ()แทนที่จะแยกวิเคราะห์คุณสามารถเข้าถึงคำแนะนำบล็อกและฟังก์ชั่นได้โดยตรง
for instruction in cfg . instructions ():
instruction . print ()
for block in cfg . blocks ():
block . print ()
for function in cfg . functions ():
function . print ()นอกจากนี้ยังเป็นไปได้ที่จะวนซ้ำจากฟังก์ชั่นไปยังบล็อกไปยังคำแนะนำคู่อัลลีลไปยังยีน
สิ่งนี้แสดงให้เห็นถึงการไปจากนามธรรมระดับสูงสุดไปจนถึงนามธรรมต่ำสุด
for function in cfg . functions ():
for block in function . blocks ():
for instruction in block . instructions ():
for allelepair in instruction . chromosome (). allelepairs ():
for gene in allelepair . genes ():
print ( gene )หนึ่งในเครื่องมือที่ทรงพลังที่สุดที่คุณสามารถใช้ใน Binlex คือการเปรียบเทียบฟังก์ชั่นบล็อกและคำแนะนำโดยใช้การแฮชความคล้ายคลึงกัน
การทำการเปรียบเทียบเหล่านี้นั้นง่ายพอ ๆ กับการเรียกใช้วิธี compare
for lhs in lhs_cfg . functions ():
for rhs in rhs_cfg . functions ():
similarity = lhs . compare ( rhs )
similarity . print ()
for lhs in lhs_cfg . blocks ():
for rhs in rhs_cfg . blocks ():
similarity = lhs . compare ( rhs )
similarity . print ()
for lhs in lhs_cfg . instructions ():
for rhs in rhs_cfg . instructions ():
similarity = lhs . compare ( rhs )
similarity . print ()อัลกอริทึมการแฮชที่คล้ายคลึงกันที่รองรับจะถูกคำนวณหากเปิดใช้งานกับการกำหนดค่าของคุณ
แม้ว่ามันจะเป็นเรื่องที่ท้าทาย Binlex สนับสนุนการวิเคราะห์ความคล้ายคลึงกันในฟังก์ชั่นที่ไม่ต่อเนื่องโดยใช้อัลกอริทึมของตัวเองเพื่อค้นหาการจับคู่ที่คล้ายคลึงกันที่ดีที่สุด
อย่างน้อย 75% หรือมากกว่าของฟังก์ชั่นที่ไม่ต่อเนื่องของฟังก์ชั่นจะต้องได้รับการแฮชเพื่อให้ได้แฮชที่คล้ายคลึงกัน
แต่ละคำสั่งบล็อกและฟังก์ชั่นหรือ จีโนม มีโครโมโซมที่เกี่ยวข้องซึ่งสามารถเข้าถึงได้ผ่าน API
คุณสามารถติดตาม abstractions เหล่านี้ลงไปที่คู่อัลลีลและยีนที่เกี่ยวข้อง
# Iterate Block Chromosome
chromosome = block . chromosome ()
for allelepair in chromosome . allelepairs ():
for gene in allelepair . genes ()
gene . print ()
# Iterate Block Chromosome
chromosome = function . chromosome ()
for allelepair in chromosome . allelepairs ():
for gene in allelepair . genes ()
gene . print ()
# Iterate Block Chromosome
chromosome = function . chromosome ()
for allelepair in chromosome . allelepairs ():
for gene in allelepair . genes ()
gene . print ()หากคุณกำลังมองหางานการเขียนโปรแกรมทางพันธุกรรมคุณยังสามารถกลายพันธุ์โครโมโซมอัลลีพีเซอร์และยีนและพวกเขาติดตามจำนวนการกลายพันธุ์ของตัวเอง
chromosome = block . chromosome ()
chromosome . mutate ( 'deadbe?f' )
chromosome . number_of_mutations ()
chromosome . print ()
for allelepair in chromosome . allelepairs ():
allelepair . mutate ( 'dead' )
allelepair . number_of_mutations ()
allelepair . print ()
for gene in allelepair . genes ():
gene . mutate ( 'd' )
gene . number_of_mutations ()
gene . print ()สิ่งนี้อำนวยความสะดวกในการกลายพันธุ์ด้วยอัลกอริทึมทางพันธุกรรมที่คุณอาจใช้สำหรับการใช้งานของคุณ
หากคุณใช้ Binlex ในวารสารสิ่งพิมพ์หรือโมเดล AI โอเพนซอร์ซใช้การอ้างอิงต่อไปนี้
@misc { binlex ,
author = { c3rb3ru5d3d53c } ,
title = { binlex: A Binary Genetic Trait Lexer Framework } ,
year = { 2024 } ,
note = { Available at url{https://github.com/c3rb3ru5d3d53c/binlex-rs} }
}หากการใช้ Binlex นั้นมีวัตถุประสงค์ส่วนตัวหรือเพื่อสร้างผลลัพธ์ที่ไม่ใช่โมเดล AI โอเพนซอร์ซไม่จำเป็นต้องมีการอ้างอิง
ตัวอย่างเช่นหากคุณใช้ Binlex เพื่อสร้างกฎของ Yara ไม่จำเป็นต้องมีการอ้างอิง
สิ่งนี้ทำให้มั่นใจได้ว่า Binlex ยังคงมีความเกี่ยวข้อง แต่ยังช่วยให้มั่นใจได้ว่าการใช้งานขององค์กรและการใช้งานส่วนตัว