
एक बहुत बुद्धिमान फ़ज़र नहीं: C/C++ कोड में कमज़ोरियाँ खोजने के लिए डिज़ाइन किया गया एक उन्नत फ़ज़िंग फ्रेमवर्क।
एक बहुत ही बुद्धिमान फ़ज़र नहीं
Marshall Whittaker
oxagast
जैसे-जैसे सिस्टम की जटिलता बढ़ती है, वैसे-वैसे उस सिस्टम के भीतर समस्याओं की संभावना भी बढ़ती है।
--व्हिटेकर का नियम
संकलन निर्भरताएँ:
automake autoconf-archive zlib1g-dev g++ gcc (and libgtk2.0-dev if you want GTK support)
संकलन:
Linux:
$ aclocal && autoconf && automake -a && ./configure && make && make check
या, यदि आप syscall फ़ज़र के साथ खेलना चाहते हैं:
$ aclocal && autoconf && automake -a && ./configure --enable-syscalls && make && make check
यदि आप GTK फ्रंटएंड को अक्षम करना चाहते हैं तो आप ऐसा कर सकते हैं:
$ aclocal && autoconf && automake -a && ./configure --disable-gtk && make && make check
FreeBSD
मान लें कि आपने पोर्ट्स से g++ स्थापित किया है (जैसा कि आपको C++11 के लिए चाहिए होगा):
$ aclocal && autoconf && automake -a && ./configure && make && make check
OpenBSD:
मान लें कि आपने पोर्ट्स से g++ स्थापित किया है (जैसा कि आपको C++11 के लिए चाहिए होगा):
$ CXX=$(find / -name 'eg++' 2>/dev/null | grep ports | head -n 1) AUTOCONF_VERSION=2.69 AUTOMAKE_VERSION=1.15 autoreconf -fmi
Windows:
विंडोज़ बाइनरीज़ को अब MinGW-W64 के साथ संकलित करने के लिए डिज़ाइन किया गया है (चूंकि हम थ्रेडिंग का उपयोग करते हैं, seh के साथ MinGW-W64 g++ का एक संस्करण डाउनलोड करें)। आप MinGW-W64 g++ को seh के साथ (केवल) स्थापित करने के बाद शामिल make_win.bat स्क्रिप्ट पर क्लिक करके संकलन का प्रयास कर सकते हैं। यदि वह विफल होता है, तो यह संभवतः पर्यावरण के कारण है, तो नीचे दिए गए को आज़माएँ।
(जहाँ आपने MinGW-W64 स्थापित किया है वहाँ जाएँ और mingw-64.bat पर क्लिक करें)
windres metadata.rc -O coff -o metadata.res
g++.exe src/common.cpp src/bin2hex.cpp src/popen2.cpp src/main.cpp src/help.cpp src/match_fault.cpp src/sys_string.cpp src/man_read.cpp src/randomizer.cpp src/trash.cpp src/log.cpp metadata.res src/version.h -I./ -I./include -std=c++11 -lstdc++ -lpthread -O2 -o ansvif.exe -static -static-libgcc -static-libstdc++
gcc src/win/printf.c -o printf.exe
नोट: cygwin .dll बाहरी फ़ाइलों की अब आवश्यकता नहीं है क्योंकि अब हम MinGW से g++ के साथ संकलन करते हैं। विंडोज़ 7 में Powershell v2 डिफ़ॉल्ट रूप से स्थापित है, हालाँकि, इस प्रोग्राम को कम से कम Powershell v5 की आवश्यकता है। विंडोज़ 10 में powershell v5 शामिल है। आप माइक्रोसॉफ्ट की साइट पर जाकर विंडोज़ मैनेजमेंट फ्रेमवर्क (जिसमें Powershell के नए संस्करण शामिल हैं) डाउनलोड कर सकते हैं:
परीक्षण:
यदि आप उदाहरण कोड आज़माना चाहते हैं, तो आप faulty.c को इस प्रकार संकलित कर सकते हैं:
$ gcc faulty.c -o faulty
आप बस make check भी चला सकते हैं।
उपयोग:
महत्वपूर्ण नोट: विंडोज़ उपयोगकर्ताओं को ansvif.exe को Powershell से चलाना होगा!
$ ./find_suid /usr/bin/ /bin/ /sbin/
$ ./ansvif -[tm] [template/manpage] -c /path/to/executable -b buffersize
उदाहरण:
Linux/BSD:
$ ulimit -c unlimited
$ ./ansvif -m mount -c /bin/mount -e examples/mount_e.txt -x examples/mount_o.txt\
-f 8 -b 2048
$ ./ansvif -t examples/blank.txt -F tmp/tmphtml -x examples/htmltags.txt -c /usr/bin/iceweasel -b\
128 -A "file:///home/username/src/ansvif/tmp/tmphtml" -f 2 -n -R "sleep 3 && killall\
iceweasel" -S ">"
$ cat examples/linux_syscalls_implemented.list | xargs -P \
`cat examples/linux_syscalls_implemented.list | wc -l` -I {calls} ./ansvif -t examples/space.txt \
-B "{calls} " -c ./syscalls -o syscall_crash -f 1 -z -d -b 16
Windows:
PS C:\ansvif\bin\ansvif_win> .\ansvif -t ..\..\examples\space -F ..\..\tmp\tmphtml -x `
..\..\examples\htmltags -c `
'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe' `
-b 128 -A "file:///C:\\Users\marsh\OneDrive\Documents\Code\ansvif\tmp\tmphtml" `
-f 2 -n -S ">" -R "sleep 2 ; Stop-Process -Name chrome"
विकल्प:
ansvif
-t This file should hold line by line command arguments as shown in the example file.
-e This file should hold line by line environment variables as shown in the example
file. You can usually get these by doing something like:
$ strings /bin/mount | perl -ne 'print if /[A-Z]=$/' > mount_envs
-c Specifies the command path.
-p Specifies the manpage location (as an integer, usually 1 or 8)
-m Specifies the commands manpage.
-D Dumps whats found in the manpage.
-f Number of threads to use. Default is 2.
-b Specifies the buffer size to fuzz with. 256-2048 Is usually sufficient.
-r Uses only random garbage data.
-o Writes output to log file.
-z Randomize the buffer size from 1 to what is specified by -b.
-x Other junk to put in. Usernames and such can go here.
-S Seperator between options.
-s Omitted character specification. Defaults are <>\\n |&\[]\()\{}:;\ and newline is mandatory.
-T Timeout for threads.
-W Timeout for threads.
-L Unpriviledged user to run as if root.
-A Always put whats after this after command to run.
-B Always put whats after this before the command to run.
-F File to feed into the program that -x along with normal fuzzing data will be put in.
-n Never use random data in the fuzz.
-R Run this command after each fuzz.
-C A Non standard error code to detect.
-V Use Valgrind if installed.
-1 Try to make it fault once, if it doesn't happen, throw error code 64. Useful for scripting.
-P Use % to represent binary in fuzz.
-M Max arguments to use in the fuzz.
-y Short for -b 0 and usually only useful with -A or -B.
-K Keep fuzzing after a crash in the target.
-E A command to be run before the fuzzed program.
-0 No NULL characters in the fuzz.
-N Shorthand for -R "pkill prog".
-v Verbose.
-d Debug data.
-h Shows the help page.
-i Prints version information.
ansvif_gtk
-l Shortcut for -p ./ansvif
-p The location of the ansvif binary
सिफारिशें: यह अनुशंसित है कि यदि आप लंबी फज़िंग या फ़ाइल फज़िंग कर रहे हैं, तो संभव हो तो फ़ाइलों (जिसमें आप जिस बाइनरी को फज़ कर रहे हैं, यदि संभव हो) को मेमोरी में रखें। इसका मतलब है, उन्हें /var/run/shm जैसी किसी जगह पर रखें जहाँ डिस्क थ्रैश न्यूनतम होगा, और फज़िंग थोड़ी तेज़ होगी, विशेष रूप से यदि बड़ी फ़ाइलें संभाली जा रही हैं। हालाँकि, सावधान रहें: यदि आपकी फ़ज़ की गई फ़ाइलें shm में हैं और आप कंप्यूटर को रीबूट करते हैं तो वे खो जाएंगी!
इस कोड को उत्पादन वातावरण में न चलाएँ! यदि आप faulty.c के आउटपुट को suid(0) पर सेट करने का प्रयास करते हैं तो कृपया इसे वर्चुअल मशीन में करें, या कम से कम ऐसी मशीन पर जिसकी आपको परवाह नहीं है। इसके अलावा, बस खेलें और मज़े करें!
नोट्स:
विंडोज़ उपयोगकर्ताओं के पास Powershell से ansvif चल रहा होना चाहिए। लिनक्स और विंडोज़ कोड अपेक्षाकृत स्थिर होना चाहिए। लिनक्स के तहत syscall फज़िंग भारी विकास के अधीन है।
धन्यवाद
syscall फज़िंग विचारों के लिए dll999 का धन्यवाद। विकी लेखन पर कुछ सिफारिशों के लिए 2600net पर #2600 से moo का धन्यवाद। IRC और StackOverflow पर अनगिनत लोगों का धन्यवाद। Makefile में एक बग को ठीक करने के लिए DarkSt0rm का धन्यवाद।