
स्वचालित रूप से फॉल्ट इंजेक्शन हमलों को खोजें और निष्पादित करें
▄▖ ▜ ▗ ▄▖ ▘ ▗ ▘ ▄▖▘ ▌
▙▖▀▌▌▌▐ ▜▘ ▐ ▛▌ ▌█▌▛▘▜▘▌▛▌▛▌ ▙▖▌▛▌▛▌█▌▛▘
▌ █▌▙▌▐▖▐▖ ▟▖▌▌ ▌▙▖▙▖▐▖▌▙▌▌▌ ▌ ▌▌▌▙▌▙▖▌
▙▌
यह रिपॉज़िटरी हमारे फॉल्ट इंजेक्शन आक्रमण प्रोजेक्ट का सॉफ़्टवेयर पक्ष है। हार्डवेयर पक्ष के लिए, इस रिपॉज़िटरी को देखें।
इस परियोजना का लक्ष्य किसी प्रोग्राम के निष्पादन में ऐसे निर्देशों को खोजना है, जिन्हें छोड़ने/NOP करने पर सुरक्षा समस्याएँ उत्पन्न होती हैं।
targets/tooling.py स्क्रिप्ट और FPGA का उपयोग करके लक्ष्य पर निर्देशों का परीक्षण करें।इस परियोजना के लिए हमारी प्रस्तुति
हम निम्नलिखित में से एक या अधिक कार्य करके सुरक्षा समस्याओं की खोज करते हैं:
फॉल्ट इंजेक्ट करने के लिए, हमने क्रोबार ग्लिचिंग करने का विकल्प चुना। यह SI 2302 N-चैनल MOSFET वाले FGPA का उपयोग करके प्राप्त किया गया था। हमारे FPGA टूलिंग का लिंक यहाँ है। अधिक जानकारी targets में पाई जा सकती है।
ट्रिगर के लिए, हमने FPGA के लिए GPIO इनपुट का उपयोग करने का विकल्प चुना। टेस्ट कोड में, हम एक LED को टॉगल करते हैं, हालाँकि आप अपने ट्रिगर के लिए पावर विश्लेषण भी कर सकते हैं।
निर्भरताएँ requirements.txt में सूचीबद्ध हैं। इन्हें pip install -r requirements.txt से स्थापित करें।
usage: main.py [-h] [-s INDEX] [-i MAX_ITERATIONS] [-o EXPECTED_OUTPUT] [-e EXPECTED_EXIT] [-d DESIRED_PC] [-v] [-n] [-t TYPES] [-b BINARY_ADDR]
[-u OUTPUT_DIR] [-f BEGIN_ADDR] [-g END_ADDR]
binary_path input_path
Automatically finds hardware security vulnerabilities in binaries. Only support ARM.
positional arguments:
binary_path The binary to examine
input_path The path to the input to the program
options:
-h, --help show this help message and exit
-s, --simulate INDEX Runs a Unicorn simulation with the fault at an nth instruction issue. Ignores all other flags besides --max_iterations and
--verbose.
-i, --max-iterations MAX_ITERATIONS
The maximum number of instructions to run in the binary before ending early
-o, --expected-output EXPECTED_OUTPUT
The expected output of the program on a successful security incident
-e, --expected-exit EXPECTED_EXIT
The expected exit of the program on a successful security incident
-d, --desired-pc DESIRED_PC
The program counter we desire to achieve if possible. In hex or decimal. Keep in mind that this is the absolute address,
not relative to the binary.
-v, --verbose Verbosity: warning, info, debug
-n, --no-thumb Whether or not to run in thumb mode
-t, --types TYPES Which types of instructions to focus on. 0) Brute force: every issue. 1) Recommended defaults. 2) Only conditional
branches. 3) Only compare/tests. 4) Only returns. 5) Only branches, calls, returns, and compares
-b, --binary-addr BINARY_ADDR
The address to flash the binary to. Defaults to 0x1000000. Can be in hex or decimal.
-u, --output-dir OUTPUT_DIR
The directory to store faults that were found.
-f, --begin-addr BEGIN_ADDR
The starting address of the instructions that should be considered for skipping. (inclusive.) If set, -g must also be set.
-g, --end-addr END_ADDR
The ending address of the instructions that should be considered for skipping. (inclusive.) If set, -f must also be set.
python3 main.py ./binaries/sha256.bin ./inputs/sha256.bin -o ./expecteds/sha256.bin -v
यह जाँचता है कि क्या हमने अपने आक्रमण लक्ष्य प्राप्त कर लिए हैं।
python3 main.py ./binaries/aes_ecb.bin ./inputs/aes_ecb.bin -d 0x100045c -v -u outputs/aes_ecb
aes_ecb बाइनरी का परीक्षण करता है ताकि एक कस्टम "अगम्य" फ़ंक्शन पर कूद सके और इनपुट्स को एक निर्देशिका में संग्रहीत कर सके।
python3 main.py ./binaries/aes_ecb.bin ./outputs/aes_ecb/solved_pc_188.bin -s 188
इस विशिष्ट ग्लिच चक्र और इनपुट के लिए Unicorn सिमुलेशन चलाएँ। इस मामले में, आउटपुट प्रोग्राम काउंटर नियंत्रण से प्राप्त होता है।
binaries/sources में शामिल कोड केवल परीक्षण के लिए है। यह किसी वास्तविक हार्डवेयर को लक्षित नहीं करता है और पूरी तरह से टूल के परीक्षण के लिए है।
किसी डिवाइस को लक्षित करने वाली विशिष्ट बाइनरी को चलाने के लिए, आपको बाइनरी के प्रासंगिक भाग को इस तरह निकालना होगा जिससे साधारण IO के बाहर किसी भी परिधीय को कॉल न की जाए। उदाहरण के लिए, यदि आपकी बाइनरी UART का उपयोग करती है, तो आप UART की कॉल्स को binaries/stubs में मौजूद _read और _write स्टब्स की कॉल्स से बदलकर बाइनरी को पैच कर सकते हैं। इसके अतिरिक्त, यदि चाहें तो GPIO को _trigger की कॉल्स से बदला जा सकता है। अपने कोड को टूल के माध्यम से चलाने के लिए, आप एक main सिंबल बनाएँगे जिसमें आपकी पैच की गई बाइनरी होगी, और फिर इसे binaries/startup.s कोड के साथ लिंक करें। इस तरह, टूल आपकी बाइनरी को प्रारंभ करके चलाने में सक्षम होगा।
एक विशिष्ट उदाहरण के लिए, targets निर्देशिका देखें जहाँ हम यह प्रक्रिया TIMSPM0L2228 पर दिखाते हैं।
लक्ष्य पर चल रही बाइनरी को प्रतिबिंबित करने वाली बाइनरी बनाने के लिए आपके पास समान संस्करण का कंपाइलर और समान संकलन फ़्लैग/चरण होने चाहिए। यदि आप अपने स्वयं के प्रोग्राम बना रहे हैं और उनका परीक्षण कर रहे हैं, तो यह ठीक है। लेकिन यदि आपके पास केवल उस लक्ष्य का स्रोत कोड है जिस पर आप आक्रमण कर रहे हैं, तो संभावना नहीं है कि आप वास्तव में चल रही सटीक बाइनरी तक संकलित कर पाएँगे। इसलिए जब भी संभव हो, आपके लक्ष्य पर चल रही सटीक बाइनरी का उपयोग करने की अनुशंसा की जाती है।