pax_global_header00006660000000000000000000000064136131214110014503gustar00rootroot0000000000000052 comment=8908600f7a2d804be609cfee82dc3f12a7ecac60 aircrack-ng-1.6/000077500000000000000000000000001361312141100135325ustar00rootroot00000000000000aircrack-ng-1.6/.clang-format000066400000000000000000000017421361312141100161110ustar00rootroot00000000000000--- AlignAfterOpenBracket: Align AlignConsecutiveAssignments: 'false' AlignConsecutiveDeclarations: 'false' AlignOperands: 'true' AlignTrailingComments: 'false' AllowShortCaseLabelsOnASingleLine: 'false' AllowShortFunctionsOnASingleLine: All AllowShortIfStatementsOnASingleLine: 'true' AllowShortLoopsOnASingleLine: 'true' AlwaysBreakBeforeMultilineStrings: 'false' BinPackArguments: 'false' BinPackParameters: 'false' BreakBeforeBinaryOperators: 'All' BreakBeforeBraces: Allman BreakBeforeTernaryOperators: 'true' ColumnLimit: 80 ContinuationIndentWidth: '4' IndentCaseLabels: 'true' IndentWidth: '4' MaxEmptyLinesToKeep: 1 NamespaceIndentation: 'None' PointerAlignment: 'Middle' ReflowComments: 'false' SortIncludes: 'false' SpaceAfterCStyleCast: 'true' SpaceBeforeAssignmentOperators: 'true' SpaceBeforeParens: ControlStatements SpaceInEmptyParentheses: 'false' SpacesInAngles: 'false' SpacesInParentheses: 'false' SpacesInSquareBrackets: 'false' Standard: Cpp11 TabWidth: '4' UseTab: Alwaysaircrack-ng-1.6/.editorconfig000066400000000000000000000007441361312141100162140ustar00rootroot00000000000000[*] charset=utf-8 end_of_line=lf insert_final_newline=false indent_style=tab indent_size=4 [{*.c,*.cp,*.cc,*.hpp,*.cpp,*.tcc,*.hp,*.cxx,*.icc,*.mm,*.hxx,*.ii,*.hh,*.m,*.i,*.h,*.h++,*.c++,*.pch,*.inl}] indent_style=tab indent_size=4 insert_final_newline=false [{CMakeLists.txt,*.cmake}] indent_style=space indent_size=2 [{Makefile.*,Makefile,GNUmakefile,makefile,*.mk}] indent_style=tab tab_width=2 [{*.yml,*.yaml}] indent_style=space indent_size=2 [appveyor.yml] end_of_line=crlfaircrack-ng-1.6/.github/000077500000000000000000000000001361312141100150725ustar00rootroot00000000000000aircrack-ng-1.6/.github/ISSUE_TEMPLATE/000077500000000000000000000000001361312141100172555ustar00rootroot00000000000000aircrack-ng-1.6/.github/ISSUE_TEMPLATE/bug_report.md000066400000000000000000000046361361312141100217600ustar00rootroot00000000000000--- name: Bug report about: Used to report a defect in the source code, scripts, etc... Post questions about usage in the Aircrack-ng forum at https://forum.aircrack-ng.org --- Please read the following: - **exploits MUST be sent to security@aircrack-ng.org.** - Always test with current git master before opening a bug - Use the search function to see if the bug you're about to post isn't a duplicate. If an existing bug is open and you have new information, update it. If a bug exists and is closed but still experience the issue with git master, reopen it and add useful information to it - Unless linked, one bug per ticket. - Don't worry about any of the items on the right panel (Assignee, Labels or Milestone), we will take care of them The following must be taken to the forum first: - Not receiving any packets with airodump-ng or any other tool - Can't crack a network - Wireless card doesn't work - Channel -1. It is most likely a technique issue or possibly a misunderstanding, refer to the documentation and if still an issue, take it to the forum **REMOVE ALL OF THE ABOVE TEXT** # Issue type **REMOVE THOSE WHICH DO NOT APPLY** - Defect - Compilation or `make check` issue - Attach `config.log` and provide relevant system information such as `lscpu` - Make sure dependencies are installed - Defect - Crash - Defect - Incorrect value displayed/received/stored - Defect - Unexpected behavior (obvious or confirmed in the forum) # System information - OS: - CPU: - Wireless card and chipset (if relevant): # Aircrack-ng version - Version: - Commit Revision hash: # Defect ## How to reproduce the issue A clear and concise list of steps describing the issue, relevant commands and errors/outputs. Such as: What command(s) did you run? What was displayed/happened? What did you expect to happen or be displayed? Do not use pastebin-type links and avoid images whenever possible. If the content (output or error) is text and can be copy/pasted, enclose it with backticks. If it is large, put it in a file and attach it to the ticket. GitHub markdown guide: https://guides.github.com/features/mastering-markdown/ If you aren't familiar with bug reporting, [this](https://www.chiark.greenend.org.uk/~sgtatham/bugs.html) is an excellent read to help you describe bugs accurately ## Related issues Link to any related issue from within the project or outside (GitHub or any other bug tracker or relevant forum post, etc...). aircrack-ng-1.6/.github/ISSUE_TEMPLATE/feature_request.md000066400000000000000000000015761361312141100230130ustar00rootroot00000000000000--- name: Feature request about: Suggest an idea for this project --- Please read the following: - Always test with current git master before opening a feature request - Use the search function to see if the feature you're about to request isn't a duplicate. If an existing issue is open and you have new information, update it - One feature/topic request per ticket - Don't worry about any of the items on the right panel (Assignee, Labels or Milestone), we will take care of them **REMOVE ALL OF THE ABOVE TEXT** # Description Describe the feature/topic. Even though the following is more geared toward bug reporting, it is an excellent read to provide useful details: https://www.chiark.greenend.org.uk/~sgtatham/bugs.html If output/file content is relevant, add an example enclosed in backticks. GitHub markdown guide: https://guides.github.com/features/mastering-markdown/ aircrack-ng-1.6/.gitignore000066400000000000000000000027011361312141100155220ustar00rootroot00000000000000/*-ng /besside-ng-crawler /ivstools /kstats /wpaclean src/osdep/.os.Linux src/osdep/libosdep.a src/tags tags *.a *.so *.dll *.o *.exe *.log *.trs *.zip *.tar.* common.cfg Makefile.in aclocal.m4 autom4te.cache/ compile /config.h /config.h.in config.guess config.log config.status config.sub configure install-sh libtool ltmain.sh missing reautogen.sh src/Makefile.in *.lo .deps .libs .dirstamp /depcomp /aminclude_static.am /stamp-h1 *.la *.gcda *.gcno *.orig /test-driver /**/*-coverage.info /**/*-coverage /**/*.log /**/*.trs /scripts/airdrop-ng/build /scripts/airgraph-ng/build /test-calc-4pmk /test-calc-mic /test-calc-pmk /test-calc-ptk /test-decrypt-ccmp /test-encrypt-ccmp /test-encrypt-wep /test-hex_string_to_array /build/m4/stubs/* !/build/m4/stubs/.gitkeep /test/test-env.sh /.idea /.vscode /.clang_complete CMakeLists.txt /cmake-build-* *.gcda *.gcno Makefile !/contrib/commview/Makefile !/contrib/airpcap/Makefile !/contrib/peek/Makefile !/scripts/airgraph-ng/lib/Makefile /scripts/airmon-ng /benchmark.csv /.cccc /cccc.opt /.scannerwork /.bash_history /.cproject /.lesshst /.project /.rpmdb /.settings benchmark*.csv /bw-output compile_commands.json coverage*.info /test/cryptounittest/default.profraw /test-calc-one-pmk /test-string-has-suffix /test-wpapsk /test-wpapsk-cmac /test-circular-buffer /test-circular-queue /GPATH /GRTAGS /GSYMS /GTAGS /VERSION /aminclude_static.am /config.h /config.h.in /include/aircrack-ng/version.h /manpages/*.1 /manpages/*.8 aircrack-ng-1.6/.travis.yml000066400000000000000000000020631361312141100156440ustar00rootroot00000000000000os: - linux - osx language: c sudo: true before_install: - if [ "$TRAVIS_OS_NAME" == "osx" ]; then (brew update && brew install cmocka openssl libgcrypt sqlite3 libpcap pcre || echo -e "\e[1;31m Skipping Homebrew... \e[0m"); fi - if [ "$TRAVIS_OS_NAME" == "osx" ]; then echo -e "\e[1;31m Skipping Code Coverage... \e[0m"; else pip install --user cpp-coveralls; fi addons: apt: packages: - libnl-3-dev - libgcrypt11-dev - zlib1g-dev - libsqlite3-dev - libpcap-dev - libssl-dev - libnl-genl-3-dev - libpcre3-dev - lcov - libcmocka0 - libcmocka-dev - libhwloc-dev compiler: - gcc - clang script: - ./build/travis-format.sh Style "Checking source code style..." ./build/travis-formatting.sh - ./build/travis-format.sh GCrypt "Building with GCrypt..." ./build/gcrypt.sh - ./build/travis-format.sh OpenSSL "Building with OpenSSL..." ./build/openssl.sh - ./build/travis-format.sh Dist "Creating a dist tarball and then building from it..." ./build/dist_check.sh aircrack-ng-1.6/AUTHORS000066400000000000000000000103451361312141100146050ustar00rootroot00000000000000Original Author =============== Thomas d'Otreppe Contributors ============ * Zero Chaos - Airmon-ng maintainer - Occational driver patch fixer - Driver tester * Joseph Benden - Instituted the project's coding style & formatting guidelines - Performed conversion from Subversion and Trac to GitHub - Continuous Integration: Buildbot system as well as AppVeyor setup and tuning TravisCI - Converted project from Makefiles to an Autotools-based build - Forged the WPA cracking engine; capable of linearly scaling up to at least 96 cores - Dynamically utilize the best SIMD instructions, at run-time, instead of build-time - Improved compilation on non-x86 platforms - Fixed many issues relating to SIMD on non-x86 architectures * Levert - Initial Subversion, trac and buildbot set-up * Andrea Bittau - osdep: OS-dependant capture/injection layer conditionally (OS) compiled * hirte (Martin Beck) - Aircrack-ng: implementation of PTW, KoreK attack speedup - Aireplay-ng: Fragmentation attack, Shared Key Authentication attack, injection test, hirte attack, Caffe Latte, Client Fragmentation, using two wireless interfaces in aireplay-ng (one for capture, one for injection) - Airodump-ng: Screen formatting and layout improvements - ieee80211 and mac80211 driver patches and driver-related changes/fixes in the tools - osdep improvements (mac80211 among other things) and fixes - New tools: airtun-ng, tkiptun-ng, airserv-ng, airdriver-ng, airbase-ng - IVS file format - airmon-ng improvements - Partial handshake cracking and detection * Carlos Lopez - Added support for gcrypt instead of openssl - Crypto unit tests and tests for other tools - Manpage reorganization and improvements - Makefile fixes and improvements - Travis CI set-up - Airodump-ng: --manufacturer, --wps options * DarkAudax - Wiki: Documentation and tutorials - Added unit tests * ASPj (Pedro Larbig) - Driver-related fixes - New tools: Airtun-ng - ieee80211 driver patches (ipw3945, rt73, rt2570, prism2) - MDK3 - WDS support in different tools - besside-ng-crawler * Leandro Meiners and Diego Sor - WPA Migration mode attack and documentation * nathanh2011 - Revamped GPS logging functionality and added logcsv format * XayOn - Airoscript-ng - Airgraph-ng and airdrop-ng improvements * Daouid - Airoscript * Chris Lundquist - Aircrack-ng: Crack HCCAPx files - Aircrack-ng: Improve loading speed of large capture files - Aircrack-ng: Improve processing speed of large capture files * kimocoder (Christian B.) - rtl8812au driver * dzk|kuro - Initial capture/injection on BSD * Erik Tews - Author of PTW attack * Loris Degioanni - Airpcap support * NetRoller3D - mac80211 driver patches and related fixes/improvements in osdep - Airmon-ng fixes - Radiotap support (and PPI detection) in various tools - Airdriver-ng improvements * Moshe Kaplan - Coverity Scan set-up - Memory leak and other fixes - AppArmor profiles * TheX1le (Ben Smith) - airgraph-ng - versuck-ng - airdrop-ng * nx5 (Alvaro Salmador) - Aircrack-ng: WPA SSE2 implementation * Len White - Aircrack-ng: WPA AVX/AVX2 code porting from JTR * Tim de Waal - Airventriloquist-ng Thanks to ========= Alon Bar-Lev Almantsas Jano yh0- Darko Sancanin Fabrice Fontaine Julian Tyler LatinSud aka SuD layoyo Marohiver Michael Buesch myst404 Ryan Schmidt neheb (Rosen Penev) San Foxman Samuel Henrique tjt263 ZhaoChunsheng Kyle Fuller SemiSkimmedSteve mnt XBM5 Raúl Calvo Laorden Lars Engels darkfires Marks Mathy Vanhoef Wojciech Waga Gustavo Zacarias steev rmh Arnaud Fontaine beini yadox Ramiro Polla matrix.use.linux m4tr1x dan Christoph J. Thompson stsp Edgan Wiz Wouter van Kesteren buzzsaw slyfox Sergei Trofimovich mrpisto Paul Fertser impulse32 jeroenimo iceblox Ludovic Drolez Christian Mock Weedy ... and to anybody else who contributed, who, sometimes wishes to remain anonymous.aircrack-ng-1.6/ChangeLog000066400000000000000000002016431361312141100153120ustar00rootroot00000000000000Version 1.6 (changes from aircrack-ng 1.5.2) - Released XX Jan 2020: * Aircrack-ng: Added support for MidnightBSD * Aircrack-ng: Fixed ARM processors display with -u * Aircrack-ng: Fixed AVX-512F support * Aircrack-ng: Fixed cracking speed calculation * Aircrack-ng: Fixed cracking WEP beyond 10k IVS * Aircrack-ng: Fixed creating new session and added test case * Aircrack-ng: Fixed encryption display in some cases when prompting for network to crack * Aircrack-ng: Fixed exiting Aircrack-ng in some cases * Aircrack-ng: Fixed logical and physical processor count detection * Aircrack-ng: Fixed PMKID length check * Aircrack-ng: Various fixes and improvements to WPA cracking engine and its performance * Airdecap-ng: Decrypt both directions when WDS is in use * Airdecap-ng: Fixed decrypting WPA PCAP when BSSID changes * Airgraph-ng: Added support for WPA3 * Airgraph-ng: Switch to argparse * Airmon-ng: Added detection for wicd, Intel Wireless Daemon (iwd), net_applet * Airmon-ng: Handle case when avahi keeps getting restarted * Airmon-ng: Indicates when interface doesn't exist * Airodump-ng: Added autocolorization interactive key * Airodump-ng: Added option to read PCAP in realtime (-T) * Airodump-ng: Added PMKID detection * Airodump-ng: Added support for GMAC * Airodump-ng: Added support for WPA3 and OWE (Enhanced Open) * Airodump-ng: Basic UTF-8 support * Airodump-ng: Checked management frames are complete before processing IE to avoid switch from WEP to WPA * Airodump-ng: Display signal when reading from PCAP * Airodump-ng: Fixed netxml output with hidden SSID * Airodump-ng: Improved rates calculation for 802.11n/ac * Airtun-ng: Fixed using -p with -e * Autoconf: Fixed order of ssl and crypto libraries * dcrack: Fixed client reporting benchmark * dcrack: Now handles chunked encoding when communicating (default in Python3) * Freeradius-WPE: Updated patch for v3.0.20 * General: Added NetBSD endianness support * General: Added python3 support to scripts * General: Added script to update autotools on CentOS 7 * General: Added security policy to report security issues * General: Reorganizing filesystem layout (See PR 2032), and switch to automake 1.14+ * General: Convert to non-recursive make (part of PR 2032) * General: Deduplicating functions and code cleanups * General: Fixed packaging on cygwin due to openssl library name change * General: Fixed SPARC build on Solaris 11 * General: Removed coveralls.io * General: Updated dependencies in README.md/INSTALLING * General: Use upstream radiotap libary, as a sub-tree * General: various fixes and improvements (code, CI, integration tests, coverity) * HostAPd-WPE: Updated for v2.9 * Manpages: Fixes and improvements * Tests: Added Integration tests for aireplay-ng, airodump-ng, aircrack-ng, airbase-ng, and others * Tests: Added tests for airdecap-ng, aircrack-ng Version 1.5.2 (changes from aircrack-ng 1.4) - Released 09 Dec 2018: * Airodump-ng: Fixed AP selection slip in interactive mode * Airodump-ng: Revamped GPS logging functionality and added new logging format (logcsv) * Aircrack-ng: Only load the maximum supported and available crypto engine * Aircrack-ng: Reworked wordlist producer/consumer queue * Airserv-ng: Fixed communication between platforms with different size int * Airmon-ng: Improved detection of Raspberry Pis * General: Signed and unsigned comparison fixes * Package: Added package for Ubuntu 18.10 (Cosmic) * General: Code cleanups * General: Added more tests * General: Compilation improvements/fixes in autotools * General: Big endian fixes * General: Fixed building on FreeBSD and OpenBSD * General: Added instructions to compile on DragonflyBSD and OpenBSD * General: Fixed spelling errors Version 1.4 (changes from aircrack-ng 1.3) - Released 29 Sep 2018: * Aircrack-ng: Added PMKID cracking * Aircrack-ng: Serious speed up and memory usage decrease when loading large files (multiple Gb) using AVL trees * Aircrack-ng: Added hwloc (Hardware Locality) to improve performance * Aircrack-ng: Support cracking PCAP with Protected Management Frames (802.11w) * Aircrack-ng: Merged check_thread() and read_thread() * Aircrack-ng: Allow static linking with chosen SIMD * Aircrack-ng: Display AVX512F when present * Airodump-ng: Added clients GPS coordinates in NetXML file * Airdecap-ng: Improve decrypting/parsing speed * Airmon-ng: Updated/fixed using with nexmon * Airmon-ng: Better check for lspci requirement on systems that don't have PCI/PCIe devices * Airmon-ng: Added support for rtl8812au/8814au/rtl88xxau driver * Build: Fixed building with a few different architectures * Build: Switch to new CI/CD tool, PyDeployer * Build: Improved building on Windows (and building/testing with AppVeyor) * Build: Improved and tweaked CI systems (buildbots, Travis, AppVeyor) * Build: Support for statically linking libraries/binaries * Build: Automatic development packages build for multiple Linux distro and upload to PackageCloud.io * Tests: Added new tests for Aircrack-ng * Tests: Added new capture files * Freeradius-WPE: Fixed opening log file twice * General: Fixed loading PCAP on system with a different endianness * General: Fixed memory leaks and issues reported by static analysis tools * General: Fixed "error while loading shared libraries" * General: Various other small improvements in the tools, build system, tests and documentation * General: Update FSF address * General: Code formatting Version 1.3 (changes from aircrack-ng 1.2) - Released 10 Jul 2018: * Aircrack-ng: Allow using Hashcat HCCAPX files as input files. * Aircrack-ng: Fixed floating point exception due to division by 0 when displaying stats. * Aircrack-ng: Updated manpage regarding hex wordlist usage. * Aircrack-ng: Added save/restore session when cracking using wordlists (-N and -R). * Aircrack-ng: Moved crypto to its own library, aircrack-crypto/ (aka crypto engine). * Aircrack-ng: Now back to a single binary thanks to crypto-engine. * Aircrack-ng: Performance improvements of the crypto engine across various CPU architectures. * Aircrack-ng: Added support for AVX512 in the crypto-engine (and build). * Aircrack-ng: Improved building crypto-engine across CPU architectures and compilers (gcc, clang and ICC). * Aircrack-ng: Allow to list available SIMD optimizations. * Aircrack-ng: Improved benchmark tool for unusual CPU/cores count. * Airodump-ng: Fixed running in the background. * Airodump-ng: Don't show WPA handshake capture notice for out-of-scope ESSIDs. * Airodump-ng: Add --background 0/1 to force disable/enable background settings and override autodetection of background. * Airodump-ng: Added support for GCMP, GCMP-256 and CCMP-256. * Airolib-ng: Fixed importing data when interrupting process using Ctrl-C. * dcrack: Check if dictionary and capture file exists before uploading them. * dcrack: Clean up dictionary before uploading it to the server. * dcrack: Gracefully stop and display errors instead of printing stacktrace whenever possible. * dcrack: Move temporary user files to /tmp and cleanup when done. * dcrack: Fixed displaying status when no clients are connected to the server. * dcrack: Validate uploaded PCAP and display success/failure. * dcrack: Improved removing BSSID. * WPAClean: Fixed crash with invalid prism2 header PCAP and added tests. * WPAClean: Don't create output file if no handshake are present or if input file is bad. * WPAClean: Fixed memory leak. * Airmon-ng: Fixed display of interface name if name is too long. * OSdep: Fixed memory leak and null pointer dereference. * OSdep: Fixed byteorder macros and other tools crashing. * OSdep: Added support to build as a shared library. * FreeRADIUS-WPE: Updated instructions for v3.0.17. * HostAPd-wpe: Added Response-Identity logging and displaying NETNTLM hash in hashcat format. * Airgraph-ng: Renamed dump-join to airodump-join. * General: Added coveralls.io badge. * General: Added --without-opt to disable stack protector when using GCC >= 4.9 * General: Various improvements and fixes, some from Coverity Scan and Valgrind. * General: Fixed typos reported by codespell. * General: Extracted console functions and moved to aircrack-util/. * General: Renamed osdep/ to aircrack-osdep/. * General: Fixed and added functions prototypes and commented out unused functions. * General: Reformat source code using clang-format and added .clang-format file for IDE. * General: Improvements to AppVeyor and TravisCI builds * Building: Added NEON intrinsic support. * Building: Support paths containing spaces, during autoreconf. * Building: Fix compilation without getauxval in the trampoline binary. * Building: Fixed compiler warnings on Windows, FreeBSD. * Building: Fixes and documentation for OSX. * Building: Added support for tcmalloc and jemalloc. * Building: Added instruction to build Windows binaries with Airpcap. * Unit test: Using CMocka for some tests * Documentation: Updated explanations regarding building some experimental tools. Version 1.2 (changes from aircrack-ng 1.2-rc5) - Released 15 Apr 2018: * General: Fixed compiling Windows binaries and updated README.md/INSTALLING. * General: Fixed commands to install dependencies on Debian/Ubuntu and FreeBSD. * General: Added command to install dependencies on Fedora/CentOS/RHEL. * General: Removed packages/ directory. * General: Added Alpine Linux and Kali Linux buildbots. * General: Fixed configure with --with-libpcap-include=/somewhere/include and --with-libpcap-lib=/somewhere/lib. * General: Fixed search for ethtool when running as a non-root user. * General: Various fixes. * Airmon-ng: Fixed mktemp on Alpine Linux. Version 1.2-rc5 (changes from aircrack-ng 1.2-rc4) - Released 03 Apr 2018: * General: Switching to autotools which allows compiling on more plateforms. * General: Updated README.md and INSTALLING files. * General: Fixed compilation on a lot of platforms. * General: Fixed compilation warnings across platforms and compilers. * General: Fixed typos in the tools and in manpages. * General: Replace %d/ld with %u/lu for unsigned printf parameters. * General: Added option to disable stack protector. * General: Improved makefile to get reproducible builds. * General: Fixed compilation with OpenSSL 1.1.0. * General: Updated radiotap parsing code. * General: Updated all URLs to use HTTPS. * General: Fixed compilation with libreSSL. * General: Added WPS 2.0 test PCAP. * General: Do not use stackguard on Windows. * General: Fixed warnings on GCC7. * General: Improved code quality using Coverity Scan. * General: Added badges for Coverity scan and Intel compiler buildbot * Aircrack-ng: Use trampoline binary to automatically select fastest executable depending on the CPU * Aircrack-ng: Fixed missing include for linecount. * Aircrack-ng: Fixed concurrency issues when reading multiple WEP PCAP. * Aircrack-ng: Added support for creating HCCAPx file format. * Airodump-ng: Get the channel from HT information. * Airodump-ng: Detect WPS 2.x. * Airodump-ng: Also check current directory for OUI file. * Airodump-ng: Fixed writing ESSID to CSV, Kismet CSV and Kismet NetXML files when ESSID gets decloaked and cloaked length was 1. * Aireplay-ng: Added deauthentication reason code option. * Aireplay-ng: Increase amount of AP to test when running injection test. * Airodump-ng: Fixed 802.11a channel hopping list. * Airodump-ng: Fix creation of .xor files. * Airodump-ng: Added support for HT channels (HT20/HT40-/HT40+). * Airodump-ng: Now displaying correct rate for 802.11n or 802.11ac AP. * Airmon-ng: Fixed checking for processes. * Airmon-ng: Fixed display of "cannot access '/sys/class/ieee80211/': No such file or directory". * Airmon-ng: Fixed bashisms. * Airmon-ng: Fixed display of specific drivers. * Airmon-ng: Fixed display of cards on the sdio bus. * Airmon-ng: Now supports nexmon driver on RPi 3 (and 0 Wireless) using Kali Linux. * Airmon-ng: Added identification for another realtek chipset and generic Ralink/MT. * Airmon-ng: Handle 2 types of rfkill commands and updated unblock text. * Airmon-ng: more portable modinfo usage. * Airmon-ng: remove grep -P references upon request. * Airmon-ng: Do not replace driver name by ?????? when driver is valid. * Airgraph-ng: Removed irrelevant comment in README. * Airgraph-ng: Handle SSID with double quotes. * Airgraph-ng: Fixed parsing OUI file. * Airdrop-ng: Updated lorcon2 installation instructions. * Besside-ng: Fixed 'wi_read(): No child processes' error. * Airdecloak-ng: Fixed segfault due to NULL pointer dereference. * osdep: Remove wi_set_channel(1) on open wifi interface (cygwin). * osdep: Fixed RAW socket resource leak. * Patches: Created WPE patches and documentation for current HostAPd and Freeradius versions. * Airodump-ng: Fix incorrect if conditions which always are false. * Airodump-ng: Remove useless not NULL check. * Airventriloquist: New tool from https://github.com/Caesurus/airventriloquist/ * dcrack: Fixed indentation. * TravisCI: Fixed compilation on OSX. * AppVeyor: Added support for AppVeyor, CI for cygwin builds. Version 1.2-rc4 (changes from aircrack-ng 1.2-rc3) - Released 14 Feb 2016: * Airodump-ng: Increase console window size. * Aircrack-ng: Added time remaining and percentage done when doing WPA cracking with a dictionary (file). * Aircrack-ng: Make benchmark last 15 seconds for a more accurate value. * Aircrack-ng: Fixed compilation on Cygwin 64 and drastically improve cracking speed for all CPUs (up to +175% performance). * Airmon-ng: Improved chipset detection on FreeBSD. * Airmon-ng: Display chipset for some Broadcom SDIO. * Airbase-ng: Fixed broadcasting 'default'. * General: Updated and cleanup TravisCI file to test compilation and testing on OSX. * General: Fixed reading large files on Cygwin. * General: Fixed a bunch of compilation warnings with gcc and clang. * General: Fixed compilation on Solaris, OpenBSD, DragonFlyBSD 4.4, NetBSD, OSX. * General: Fixed compilation on ARM and MIPS. * General: Improved compatibility on FreeBSD and Cygwin (RAM and CPU detection). * General: Fixed gcc segfault on cygwin. * General: Memory cleanups, fixed memory leaks and fix other issues reported by Valgrind. * Testing: Fixes on various OSes. * INSTALLING: Updated installation instructions for different OS. * TravisCI: Improved file. Version 1.2-rc3 (changes from aircrack-ng 1.2-rc2) - Released 21 Nov 2015: * Airodump-ng: Prevent sending signal to init which caused the system to reboot/shutdown. * Airbase-ng: Allow to use a user-specified ANonce instead of a randomized one when doing the 4-way handshake * Aircrack-ng: Fixed compilation warnings. * Aircrack-ng: Removed redundant NULL check and fixed typo in another one. * Aircrack-ng: Workaround for segfault when compiling aircrack-ng with clang and gcrypt and running a check. * Airmon-ng: Created version for FreeBSD. * Airmon-ng: Prevent passing invalid values as channel. * Airmon-ng: Handle udev renaming interfaces. * Airmon-ng: Better handling of rfkill. * Airmon-ng: Updated OUI URL. * Airmon-ng: Fix VM detection. * Airmon-ng: Make lsusb optional if there doesn't seem to be a usb bus. Improve pci detection slightly. * Airmon-ng: Various cleanup and fixes (including wording and typos). * Airmon-ng: Display iw errors. * Airmon-ng: Improved handling of non-monitor interfaces. * Airmon-ng: Fixed error when running 'check kill'. * Airdrop-ng: Display error instead of stack trace. * Airmon-ng: Fixed bashism. * Airdecap-ng: Allow specifying output file names. * Airtun-ng: Added missing parameter to help screen. * Besside-ng-crawler: Removed reference to darkircop.org (non-existent subdomain). * Airgraph-ng: Display error when no graph type is specified. * Airgraph-ng: Fixed make install. * Manpages: Fixed, updated and improved airodump-ng, airmon-ng, aircrack-ng, airbase-ng and aireplay-ng manpages. * Aircrack-ng GUI: Fixes issues with wordlists selection. * OSdep: Add missing RADIOTAP_SUPPORT_OVERRIDES check. * OSdep: Fix possible infinite loop. * OSdep: Use a default MTU of 1500 (Linux only). * OSdep: Fixed compilation on OSX. * AppArmor: Improved and added profiles. * General: Fixed warnings reported by clang. * General: Updated TravisCI configuration file * General: Fixed typos in various tools. * General: Fixed clang warning about 'gcry_thread_cbs()' being deprecated with gcrypt > 1.6.0. * General: Fixed compilation on cygwin due to undefined reference to GUID_DEVCLASS_NET * General: Fixed compilation with musl libc. * General: Improved testing and added test cases (make check). * General: Improved mutexes handling in various tools. * General: Fixed memory leaks, use after free, null termination and return values in various tools and OSdep. * General: Fixed compilation on FreeBSD. * General: Various fixes and improvements to README (wording, compilation, etc). * General: Updated copyrights in help screen. Version 1.2-rc2 (changes from aircrack-ng 1.2-rc1) - Released 10 April 2015: * Airtun-ng: Adds WPA CCMP and TKIP decryption and CCMP encryption * Compilation: Added support for DUMA. * Makefile: Renamed 'unstable' to 'experimental'. * Airodump-ng: Fixed XML sanitizing. * Airmon-ng: Airmon-zc is now stable enough to replace airmon-ng. * Manpages: Removed airdriver-ng manpage and references to it (forgot to do it before the previous release). * Manpages: Updated 'see also' references in all manpages. * PCRE: Added it in various places and docs. * WZCook: Fixed processing values stored in register. * Updated a few headers files (if_llc, ieee80211, ethernet and if_arp). * Travis CI: updated make parameter and add testing with pcre. * Compilation: de-hardcode -lpcap to allow specifying pcap libraries. * Makefile: Fixed installing/uninstalling Airdrop-ng documentation files. * Makefile: Fixed uninstalling ext_scripts. * Airodump-ng: Added new paths (and removed one) for OUI files and simplified logic to find the OUI file. * Aircrack-ng: Fixed ignoring -p when specified after -S. * Airmon-ng: fixes for openwrt busybox ps/grep issues which do not seem present in other versions of busybox * Airmon-ng: fix vm detection. * Airserv-ng: Fixed channel setting (and assert call). * Airodump-ng: Fixes to NetXML (unassociated clients missing and various other small bugs) and update the code to match current NetXML output. * Airodump-ng: Removed requirement for 2 packets before AP is written to output (text) files. * Airodump-ng: Fixed formatting of ESSID and display of WPA/WPA2 (as well as a bunch of other small fixes) in CSV file. * Airodump-ng: Fixed GPSd. * Airodump-ng: Allow to specify write interval for CSV, kismet CSV and NetXML files. * Airserv-ng: Fixed wrong station data displayed in Airodump-ng. * General: Fixed 64 bit promotion issues. * General: Fixed a bunch of uninitialized values and non-zeroed structures (upon allocating them). * General: Added Stack protection. * Various other small fixes and improvements. Version 1.2-rc1 (changes from aircrack-ng 1.2-beta3) - Released 31 October 2014: * Airodump-ng should be able to parse the canonical oui file. * Airodump-ng: Fixed GPS stack overflow. * Airodump-ng: Fixed stopping cleanly with Ctrl-C. * Airmon-zc: better handling for when modules are not available (incomplete). * Airmon-zc: users can now start the monitor interface again to change channels. * Airmon-zc: update to use ip instead of ifconfig if available. * Airmon-zc: better handling of devices without pci bus. * Aireplay-ng: Fixed tcp_test stack overflow. * OSdep: Fixed libnl detection. Also avoid detection on non Linux systems. * OSdep: Fixed segmentation fault that happens with a malicious server. * Besside-ng: Add regular expression matching for the SSID. * Buddy-ng: Fixed segmentation fault. * Makefile: Fixed 'commands commence before first target' error when building Aircrack-ng. * Fixed segfault when changing the optimization when compiling with gcc thanks to Ramiro Polla. * Removed airdriver-ng (outdated and not meant for today's kernels). * Added gitignore file. * Fixed build issues on other compilers by using stdint.h types. * Fixed CVE-2014-8321, CVE-2014-8322, CVE-2014-8323 and CVE-2014-8324 across multiple tools. * Updating installation file and added pkg-config as a requirement. * Various small fixes and improvements. Version 1.2-beta3 (changes from aircrack-ng 1.2-beta2) - Released 31 March 2014: * Finally properly fixed the buffer overflow. * Fixed channel parsing (eg 108, 125) and updated radiotap parser. * Various other small fixes. Version 1.2-beta2 (changes from aircrack-ng 1.2-beta1) - Released 30 November 2013: * Airbase-ng: Fixed order of IE when creating soft Access Point. * Airbase-ng: Fixed Caffe Latte Attack not working for all clients. * Aircrack-ng: Improved PTW speed thanks to Ramiro Polla. * Airmon-zc: Fixed improper use of the interface. * Airdecap-ng: Fixed decoding captures with WMM enabled. * Various: Fixed memory leaks in Aircrack-ng, Aireplay-ng, OSdep. * Added support for static analysis using Coverity Scan. * Fixed compilation due to PIC unfriendly assembly on Gentoo hardened. * Fixed running tests using 'make check'. * Fixed building aircrack-ng with recent version of gcc and also on cygwin. * Various other small fixes. Version 1.2-beta1 (changes from aircrack-ng 1.1) - Released 25 May 2013: * Airmon-ng: Added chipset information for ar9170usb, wl, rt2800usb, ar9271, wl12xx, RT3070STA, ath9k_htc, r871x_usb_drv, ath5k, carl9170 and various Intel drivers. * Airmon-ng: Fixed chipset information ipw2200. * Airmon-ng: Fixed output for r8187 driver. * Airmon-ng: Improved chipset information for a few drivers. * Airmon-ng: Support for displaying information about ath9k. * Airmon-ng: Added 'check kill' to automatically kill services that could interfere. * Airmon-ng: Fixed issues with Intel chipsets detection. * Airmon-ng: Updated iw download link. * Airmon-ng: Better mac80211 handling. * Airmon-ng: Added detection for WiLink TI driver, rtl819xU, iwlwifi. * Airmon-zc: Improved version of Airmon-ng with more detailed information. * Airdecap-ng: Fixed decoding QoS frames (Closes: #667 and #858). * Airgraph-ng: Use Aircrack-ng Makefile instead of its own. * Airbase-ng: Fixed bug using clients list. * Airbase-ng: Fixed issue with QoS (ticket #760). * Airbase-ng: Fixed sending beacons with null SSID. * Airbase-ng: Allow non ASCII ESSID. * Airodump-ng: Fixed buffer overflow (ticket #728). * Airodump-ng: Fixed channel parsing. * Airodump-ng: Fixed FreeBSD battery reading. * Airodump-ng: Renamed "Packets" column to "Frames" ("Packets" was not correct). * Airodump-ng: Fixed XML bugs when outputting NetXML: ESSID containing '&' or chinese characters, when multiple encryption are used. * Airodump-ng: Add alternative paths for Airodump-ng OUI file. * Airodump-ng: Added GPSd 2.92+ support (JSON). * Airodump-ng: Add option --manufacturer to display manufacturer column on airodump-ng. * Airodump-ng: Add feature to show APs uptime (--uptime) based on the timestamp. * Airodump-ng-OUI-update: Fixed OUI URL and allow CURL redirect (ticket #829). * Airdrop-ng: removed .py from file names. * Airdrop-ng: Fixed bug in installer. * Airdrop-ng: Fixed OUI lookup. * Airdrop-ng: Fixed bug when several BSSID have the same ESSID. * Airdrop-ng: Doesn't constantly parse anymore, wait 5 seconds each time it parses. * Airdrop-ng: Fixed crash when failing to get channel or when rules file didn't exist. * Airdrop-ng: Fixed to use lorcon.py/lorcon2 libs. * Airdrop-ng: Updated README. * Airdrop-ng: Fixed error preventing update to work. * Versuck-ng: New script to do the same thing as the kismet autowep plugin from the CLI. * Aircrack-ng: Fixed counter display error when cracking WPA. * Aircrack-ng: Added output of the WPA handshake to EWSA project file. * Aircrack-ng: Added output of the WPA handshake to oclhashcat+ project file. * Aircrack-ng: Added benchmark option, -S. * Aircrack-ng: Fixed -u option. * Aircrack-ng: PIC fix for hardened systems from Francisco Blas Izquierdo Riera (klondike) * Aircrack-ng: Allow dictionaries larger than 2Gb. * Aircrack-ng: Give a better message when there's an error with the dictionary. * Aircrack-ng: Prevent a buffer overflow from happening (Wojciech Waga). * Aireplay-ng: Added migration mode attack from Leandro Meiners and Diego Sor from Core Security (BlackHat Las Vegas 2010) * Aireplay-ng, Airodump-ng: Added option to ignore issue with -1 channel. * Airserv-ng: Fixed crash when clients disconnect. * Besside-ng-crawler: Added EAPOL Crawler. * Airdecloak-ng: Fixed bug when using pcap files with PPI headers. * dcrack: Distributed cracking server/client. * wifi-detect.sh: reference script for testing wifi card detection using iwconfig vs ls /sys/class/net * WPA Clean: Tool to merge and clean WPA capture files. * Wireless Panda: C# Library to parse Airodump-ng output files (and added example project). * OSdep (Linux): Setting fixed bitrates on mac80211 2.6.31 and up. * OSdep (Linux): Added support for nl80211 thanks to impulse32. Use 'make libnl=true' to add netlink support (Ticket #1004). * Manpages: Improvement and fixes for Airgraph-ng, Airodump-ng, packetforge-ng, Aircrack-ng * Manpages: Fixed various spelling issues and single quote issues. * Makefiles: Added tests for the different tools. * Makefiles: Various fixes and improvements. * Makefiles: Added support for libgrypt instead of OpenSSL via parameter. * Patches: Added a few patches. * Removed useless script: patchchk. * Finally fixed licensing issues. * Fixed endianness issues in most of the tools. * Fixed cppcheck errors (Ticket #957). * Fixed various compilation issues on Linux and Cygwin, GNU/Hurd, Darwin (OSX) and Sparc. * Fixed compilation on recent gcc versions on Linux, Cygwin. * Added instructions for Travis CI: Free Hosted Continuous Integration Platform for the Open Source Community. * Added Readme.Md for GitHub. Aircrack-ng subversion repository is synced on GitHub: http://github.com/aircrack-ng/aircrack-ng * Various other small bug fixes. Version 1.1 (changes from aircrack-ng 1.0) - Released 24 April 2010: * airdrop-ng: New tool by TheX1le. * airodump-ng, aircrack-ng, airdecap-ng, airbase-ng: Fixed buffer overflow in airodump-ng due to forged eapol frame. * aircrack-ng: Fixed multicast detection (WPA handshake detection). * airodump-ng: Added interaction (see wiki for the commands). * airodump-ng: Fixed client time in netxml file. * airtun-ng: Add WDS and bridge support. * airbase-ng: automatically set privacy bit to 1 if WPA or WPA2 is used (-Z or -z option). * airmon-ng: Updated iw URL for v0.9.19. * airdriver-ng: Fixed link for madwifi-ng. * aireplay-ng: Chopchop enhancement to not stop but wait on deauth packets. * tkiptun-ng: Fixed segfault. * wesside-ng: Fixed compilation bug with recent version of gcc. * cygwin: Compiling sqlite isn't necessary anymore, libsqlite3-devel package can be used. * osdep: Strict aliasing and x86_64 fix. * osdep: Add tap support for Darwin/OS X. Still require tuntaposx from sourceforge to work. * All: Fixed compilation on cygwin 1.7. * All: Fixed compilation on recent version of OSX. * manpages: Fixed aireplay-ng manpage for attack 0: not disassociation packets, deauth packets. * manpages: Added the keys for interaction in airodump-ng. * patches: Added regulatory domains override patches for atheros drivers (ath5k, ath9k and ar9170). * patches: Added 2.6.32 patch for r8187 driver (ieee80211). * Makefiles: Fixed make uninstall. Version 1.0 (changes from aircrack-ng 1.0-rc4) - Released 08 September 2009: * airserv-ng: Now works fine between 32 and 64bit OSes. * wesside-ng: Fixed some endianness bugs * airodump-ng-oui-update: Make sure the user is root when updating the file. * airmon-ng: Updated iw download link (0.9.17). * All: Fixed compilation with some gcc. * patches: Added missing patches from patches.aircrack-ng.org: mac80211_2.6.28-rc4-wl_frag+ack_v3.patch * manpage: Updated aireplay-ng manpage. * INSTALLING: Removed (now) useless requirement for OSX installation. * GUI (windows): Fixed 2nd selection of a capture file. Version 1.0-rc4 (changes from aircrack-ng 1.0-rc3) - Released 27 July 2009: * airodump-ng: Decreased time before writing text files to 5 sec (instead of 20). * airodump-ng: New option --output-format option (to replace --nocap): specify output files. * airodump-ng: Fixed encryption tag value in kismet netxml files. * airodump-ng: Sanitize essid before writing it into kismet netxml files. * airodump-ng: Log manufacturer into kismet netxml files. * aireplay-ng: Fake auth: reduce the number of ACKs to 2 per packet. * aireplay-ng: Added possibility to stop sending fake auth requests after n retry failures. * aircrack-ng: Fixed compilation on FreeBSD. * aircrack-ng: Fixed aircrack-ng --help on OSX. * airmon-ng: Updated iw download link (0.9.15). * airmon-ng: Fix chipset detection for iwlagn (show "Intel 4965/5xxx" instead of "Unknown"). * airmon-ng: Display a message when udev rename madwifi-ng VAPs. * airmon-ng: sleep 1s instead of 0.1 (0.1 is not supported by all distro). * airolib-ng: Fixed locked database counter. * airdriver-ng: Updated to rt2570 k2wrlz v1.6.3 * airdriver-ng: Updated r8187 patch. * aircrack-ng, airdecap-ng, ivstools, airodump-ng, airbase-ng, aireplay-ng, airtun-ng, packetforge-ng, tkiptun-ng: Added support for PPI captures support (Thanks to dragorn). * airdecap-ng: Fixed segfault on some capture files. * wesside-ng, easside-ng: "ERROR: Packet length changed while transmitting (XX instead of YY)" should finally be fixed. * All: Added compatibility file for functions like cpu_to_le32. That should fix compilation on a lot of OSes. * All: Temporary fix to allow compilation with recent gcc (Error message: "dereferencing type-punned pointer will break strict-aliasing rules"). I hope it doesn't break anything. A cleaner fix will be applied later. * INSTALLING: OSX patch for Intel CPU isn't required anymore * INSTALLING: Updated instructions to compile sqlite on cygwin for 3.6.16. * patches: Updated sqlite (v3.6.13) patch for cygwin. * patches: Updated wlanng patch for 2.6.28. * patches: Updated madwifi-ng patch to r4073 * packages: Fixed spec (RPM) file. * GUI (windows): Use last used directory when selecting another file to crack. * GUI (windows): Allow .pcap files too (next to .cap, ...). Version 1.0-rc3 (changes from aircrack-ng 1.0-rc2) - Released 26 March 2009: * airodump-ng: Added Active Scanning Simulation. * airodump-ng: Added support for kismet-newcore netxml files (DTD v3.1.0) * airodump-ng: Changed file extensions for CSV (.csv instead of .txt) and for kismet CSV (.kismet.csv instead of .csv). * airodump-ng: Fixed WPA tag parsing and added QoS detection based on direction. * airodump-ng: Added option to only disable capture file; all other files (CSV, kismet CSV, kismet netxml, GPS) will be created. * aircrack-ng: Fixed -w with WEP. * aircrack-ng: Fixed useless memory allocation. * aircrack-ng: Fixed compilation with gcc 2.95. * aircrack-ng: Fixed compilation on 64 bit (SHA-SSE2). * aircrack-ng: Fixed errors when compiling on OS X 10.5.6 PPC. * aircrack-ng: Added an option to write the key to a file. * airolib-ng: Fixed a bug where database is created even if parameters are not correct. * airmon-ng: Added wifibox to the list of network managers. * airmon-ng: Updated iw download link (0.9.11). * airmon-ng and airdriver-ng: Move them in script/ directory. * airmon-ng: Bypass interface checks when ps command returns an error. Needed for BusyBox limited ps command. * airdriver-ng: Update legacy RT73 driver to use rt73-k2wrlz v3.0.2 * tkiptun-ng: Allow padded arp packets to the client. * airserv-ng & osdep: Fixed compilation on FreeBSD 7.1 * easside-ng & wesside-ng: Fixing again "Error Wrote 39 out of 30" error message. * manpages: Fixed manpages titles. * Makefile: Only compile and install wesside-ng, easside-ng, buddy-ng and tkiptun-ng with "make unstable=true". * patches: Updated sqlite (v3.6.11) patch for cygwin. * patches: Added patch for aircrack-ng on MacOSX * scripts: Added a script to automatically patch and install SQLite in cygwin. Version 1.0-rc2 (changes from aircrack-ng 1.0-rc1) - Released 22 Jan 2009: * aircrack-ng: Added SSE2 supports (WPA cracking speed is improved a lot) thanks to nx5. * aircrack-ng: Fixed detection of the number of CPU (especially with recent CPUs). * aircrack-ng: Fixed long lasting WPA bugs: cannot find the key with SMP computers, wasn't exiting correctly, ... * aircrack-ng: Fixed usage of a dictionary with WEP. * aircrack-ng: Now only display ASCII WEP keys when 100% of the hex key can be converted to ASCII. * aircrack-ng: You can now specify the number of threads for cracking even if you have a non-SMP computer. * aircrack-ng: Now output an error message if using -r and it wasn't compiled with sqlite support. It was a problem on some ubuntu. * airdecloak-ng: New tool to remove wep cloaked frames from a pcap file. For more details see https://www.aircrack-ng.org/doku.php?id=airdecloak-ng * airodump-ng: Added kismet csv output support. * airodump-ng: Fixed power value display (for ath interface with a high number, more than 99). * airodump-ng: Can work on the new frequencies (allowed by frequency Chaos patch). * airodump-ng: Now display if the network has QoS enabled. * aireplay-ng: Fixed crash with too short packets (seen with zd1211). * aireplay-ng: Fixed STP usage in fragmentation attack. * aireplay-ng: Fixed bug with deauth attack. * airtun-ng: Fixed STP conversion. * airolib-ng: Added sample database in test/ directory. * tkip-tun: New tool to inject on WPA1 with QoS enabled networks. Full description: decrypt packets coming from the AP in a TKIP network, which uses QoS (ieee802.11e). It also breaks the MIC Key for sending packets towards the Client correctly encrypted and signed. Stores plaintext packet and keystream in separate files. * airbase-ng: Several improvements ( See https://github.com/aircrack-ng/aircrack-ng/issues/466 ). * airbase-ng: Added compatibility with some clients. added random source IPs and MACs for cfrag attack (-N) to evade simple flood protection. * airmon-ng: Fixed some 'unary operator expected' errors. * airmon-ng: Fixed channel number setting with mac80211 drivers. * airmon-ng: Recognition of 4 new chipsets: acx1xx, at76_usb, adm8211 and AR9001U (otus). * airmon-ng: Fixed some chipset naming inconsistencies between ieee80211 and mac80211 drivers. * airmon-ng: Fixed display of "airmon-ng check". * airmon-ng: Improved mac80211 driver handling. * airdriver-ng: Fixed madwifi-ng driver download URL. * airdriver-ng: Updated openSuse information. * wesside-ng: Fixed open() with O_CREAT that needs 3 arguments. * osdep: Added TAP/TUN MTU getter. * manpages: Fixed misspelled airserv-ng manpage filename. * manpages: Added Airbase-ng, Tkiptun-ng manpages. * manpages: Updated description of all manpages. * Makefile: Fixed errors when compiling on OSX 10.5. * Makefile: Now ensure that make 3.81 or higher (mandatory) is used when compiling on OSX 10.4. * Makefile: Only install airolib-ng manpage if airolib-ng is installed. * Makefile: Added 'make check' that tests key cracking against files given in test/ directory. * general: Fixed 'evalrev' on Solaris. * general: Fixed compilation on Sun SPARC. * general: Fixed compilation on some distribution (with a recent version of gcc) due to warnings (because of not getting the return value of some functions). * general: Several compilation fixes. * patches: Updated ath5k patches * patches: Added rt2570 patch (kernel 2.6.24). * patches: Updated madwifi-ng patch for r3745. * patches: Updated mac80211 patches. * patches: Added zd1211rw patch for 2.6.26, b43/b43legacy for 2.6.26-wl. * patches: rt73, r8187 patches for fedora kernels (should work on 2.6.27). * patches: Added Defcon 16 patch (more frequencies than the usuals) for ath5k called frequency Chaos. * patches: Added injection patch for rtl8187 (mac80211). * patches: Added a universal mac80211 fragmentation and injection speed patch. * GUI (windows): Fixed: Windows GUI gives "please specify dictionary". Version 1.0-rc1 (changes from aircrack-ng 1.0-beta2) - Released 09 Jun 2008: * airbase-ng: Multi-purpose tool aimed at attacking clients as opposed to the AP. * airbase-ng: Added replay tool for external packet processing feature. * aircrack-ng: Fixed: Displaying twice the wep key at the end and "Warning: Previous crack is still running". * aircrack-ng: Fixed detection of WPA handshake (was not working correctly in previous release). * aircrack-ng: Fixed PTW attack against QoS and WDS packets. * aircrack-ng: Added oneshot option to try PTW only once. * airodump-ng: Fixed channel numbers (Fixed "fixed channel" messages). * airodump-ng: Added frequency selection (-C). * aireplay-ng: Fixed injection on OpenBSD. * aireplay-ng: Fixed a rtc bug which freezed aireplay-ng in case /dev/rtc0 is not available. * aireplay-ng: Fixed chopchop attack against QoS packets. * aireplay-ng: Added Caffe-Latte attack. * aireplay-ng: Added CFrag attack: Turns every IP and ARP packet into an ARP request against the client. * airtun-ng: Added support for fragmented packets. * airdriver-ng: Updated drivers. * airserv-ng: Various fixes. * airmon-ng: Added nl80211 usage. * airmon-ng: Use 'iw' when it is found. * airmon-ng: Fixed error with madwifi-ng when creating new VAP. * wesside-ng: Added option to ignore ACKs. * OSdep: Fixed endieanness bugs. * OSdep: Orinoco: attempt to bring interface down before switching to monitor mode. * All: Added copyright and GPL in missing files. * All: Fixed compilation on Mac OSX 10.5.2 (PPC). * GUI: Fixed "Choose" button (airdecap-ng). * Makefile: Fixed usage of iCC versions other than 9.0. * patches: Updated rtl8187 patch. * patches: Updated madwifi-ng patch. * patches: Updated sqlite patch (cygwin). * patches: Added mac80211 frag patch. * patches: Added b43 and updated bcm43xx patches. Version 1.0-beta2 (changes from aircrack-ng 1.0-beta1) - Released 01 Feb 2008: * aircrack-ng: Cracking WPA now does only require 2 packets (instead of 4). * airodump-ng: Fixed (WEP) open system and shared key system detection. * airodump-ng (win): Battery status is now displayed. * airdriver-ng: Fixed module detection. * airdriver-ng: Updated drivers. * airdriver-ng: Added firmware support. * airdriver-ng: Added softmac installation. * airdecap-ng: Save packets with ICV error in a separate file. * airolib-ng: Automatically create a database if it does not exist. "init" option is not necessary anymore. * airolib-ng: Now uses getopts for options. * airdriver-ng: Updated some drivers download locations. * airdriver-ng: Fixed softmac installation * airmon-ng: Added detection of ipwraw-ng driver. * airmon-ng: When stopping an interface, it is in managed mode * Makefile: supports DESTDIR or destdir parameter. * Makefile: renamed ROOT (used by gentoo for other stuff) variable by AC_ROOT. * manpages: Fixes for whatis * patches: updated cygwin sqlite patch * patches: updated rtl8187 patch * Added instructions to compile airolib-ng and using '-r' option in aircrack-ng for cygwin. * Fixed compilation of aircrack-ng with some gcc versions Version 1.0-beta1 (changes from aircrack-ng 0.9.2) - Released 01 October 2007: * airodump-ng: Added --berlin option (see code for more information). * airodump-ng: Fixed 100% cpu utilization while channelhopping on rtap interface * airodump-ng: Fixed frame length < 10bytes bug * airodump-ng: Added out-of-monitor-mode, channel hop and interface down detection * airodump-ng: Fixed debian bug #417388: airodump-ng doesn't restore terminal after error * airodump-ng: Fixed opening the same interface more than once * airodump-ng: Fixed PWR values for some drivers * airodump-ng: Fixed airodump sanity check (resulted in showing WPA networks without CIPHER & AUTH) * airodump-ng: Added "-f" to set the time in ms between hopping channels * airodump-ng: Added partial 40bit WEP detection * airodump-ng: Added "--showack" to print statistics about ack/cts and rts frames * airodump-ng: Added "-h" to hide the known stations in ack statistics * airodump-ng: Added "-r" to read packets from a pcap file * aircrack-ng: Added BSSID merge option * aircrack-ng: Added passive ptw attack (using also IP packets for cracking) * aircrack-ng: Made ptw attack default, for korek attack use -K * aircrack-ng: Fixed huge memory usage with ptw attack on hundreds of APs * aircrack-ng: Added -M paramteter for specifying maximum number of IVs to be read * aircrack-ng: Changed ptw testpackets from first to random (fixes invalidation of found keys) * aircrack-ng: Added --wep-decloak mode * aircrack-ng: Added --ptw-debug to allow klein or ptw disabling * aircrack-ng: PTW: Starts a new process group * aircrack-ng: Increased PTW key checking speed by 20% * aircrack-ng: Try 1000 40bit keys before starting 104bit cracking, to get the key "instantly" without waiting for 104 bit to fail * aircrack-ng: Fixed not shown ascii keys, when found key was shorter than expected * aircrack-ng: Added visual inspection of the different keybytes (--visual-inspection). * airdecap-ng: Fixed bug in calc_pmk() function causes wrong PMK to be computed * aireplay-ng: Added usage of RTS/CTS, auth and ACK to --test (more stable and faster) * aireplay-ng: Added TCP connection test to --test * aireplay-ng: Changed injection rate to be more stable * aireplay-ng: Made essid argument optional - sniffs the essid if its broadcasted * aireplay-ng: Made src mac argument (-h) optional - uses default interface mac * aireplay-ng: Added bitrate test to --test (-B) * aireplay-ng: Fixed 100% cpu utilization in --test * aireplay-ng: Added --fast switch to use first available packet without interaction * aireplay-ng: chopchop now tries header recreation workaround if icv check failed * aireplay-ng: Fixed seq field for fragment attack * aireplay-ng: Now works with rtc_cmos * aireplay-ng: Added automatic channel changing in --test to AP channel * aireplay-ng: Added channel synchronization for --test between cards * aireplay-ng: Added possibility to limit injection test to one AP "-a" or "-e" * aireplay-ng: Added BSSID/ESSID detection, so it can be enough to specify one option * makeivs-ng: Added parameters to set length, number and first IV of generated IVs * makeivs-ng: Added possibility to generate IVs sequentially or randomly * makeivs-ng: Added parameters to set percentage of false and dupe frames * makeivs-ng: Added 256bit wep support * packetforge-ng: Added support for generating more than on packet * patches: updated rtl8187 patch for 2.6.22 * patches: updated zd1211rw patch for 2.6.22 * New IVS format for storing all relevant data * Auto-creation of rtap interface if it doesn't exist (ipw2200) * Better acx, rtl8180, orinoco and madwifi-ng detection * Using OpenSSL instead of build-in crypto * Added library rx/tx support * Added airpcap rx/tx support * Added airdriver-ng script for installing and managing patched drivers * Added wesside-ng as an all in one tool for recovering the wep-key * Added easside-ng for realtime decryption (instant rx/tx) of wep frames * Added buddy-ng as loopback server for easside-ng * Added airserv-ng - server for rx/tx on another system * Added airolib-ng for using hash tables to crack wpa/wpa2 psk (supports cowpatty rainbow tables) * Fixed compilation of optimized binaries with icc * Fixed compilation on FreeBSD, NetBSD, OpenBSD and MacOSX * Better WDS handling and display * Added detection and removal of trailing fcs checksum * Fixed several memory leaks * Fixed being root when connecting to airserv-ng * Added OpenBSD sniffing support Version 0.9.3 (changes from aircrack-ng 0.9.2) - Released 24 February 2008: * Fix endianness issues in airodump-ng, aireplay-ng. * Several small bug fixes. * Updated rtl8187 patch. Version 0.9.2 (changes from aircrack-ng 0.9.1) - Released 05 February 2008: * aireplay-ng: Now works with rtc_cmos * aireplay-ng: Fixed compilation on Fedora Rawhide * airodump-ng: Fixed: Wrong information printed in CSV file (PSK for WEP with Shared key instead of SKA). * airodump-ng (airpcap): added support for 5Ghz channels. * airdecap-ng: Fixed bug in calc_pmk() function causes wrong PMK to be computed * airmon-ng: Fixed detection of N770 wireless interface * airmon-ng: Fixed Ralink rt73 detection * airmon-ng: Added driver detection through sysfs * airmon-ng: Added mac80211 support * airmon-ng: Added networkmanager detection - airmon-ng check * airmon-ng: Added detection of ipwraw-ng driver * GUI (win): Fixed file dialog for airdecap-ng * manpages: updated airodump-ng manpage * manpages: Fixes for whatis * Makefiles: Fixed OpenBSD makefile. Version 0.9.1 (changes from aircrack-ng 0.9) - Released 25 June 2007: * airodump-ng: wlan-ng driver now works again. * airodump-ng: Fixed IP address when writing to CSV file * airodump-ng: Fixed debian bug #417388: it doesn't restore terminal after error * aircrack-ng: Fixed WPA cracking on SMP computers * aircrack-ng: Fixed bug in calc_pmk() function causes wrong PMK to be computed * airmon-ng: Fixed madwifi-ng wifiX detection (due to translation in ifconfig) * patches: Added ACX injection patch * patches: Updated rtl8187 patch for 2.6.21 * GUI (win): Added PTW option to aircrack-ng tab. * GUI (win): Fixed a bug when cracking with a wordlist. Version 0.9 (changes from aircrack-ng 0.8) - Released 13 May 2007: * aireplay-ng: Added new 'attack': injection test (--test) * aireplay-ng: disallow injection with wlanng & kernel > 2.6.11 * airtun-ng: Fixed: an option wasn't shown in usage screen. * airodump-ng (win): Fixed version numbering. * airodump-ng (win): Changed first time messagebox * aircrack-ng: Fixed: --help make aircrack-ng crash * aircrack-ng: Added PTW attack (option: -z). It require full capture. * airdecap-ng: now decrypt IEEE802.11 header with 802.11e header * airmon-ng: Fixed orinoco card detection * patches: updated zd1211rw patch for kernel 2.6.21 * patches: Added bcm43xx injection patch for kernel 2.6.20 * patches: updated rtl8187 patch (for new driver version). * wzcook (win): now can work in silent mode (option: --silent) * Makefile: added make zip (cygwin only) * Makefile: fixed direct call to 'make install' or 'make strip' instead of 'make' * GUI (win): Updated aircrack-ng tab and added an about tab. Version 0.8 (changes from aircrack-ng 0.7) - Released 25 April 2007: * aireplay-ng: Works on FreeBSD-CURRENT * aircrack-ng: Fixed stdin dictionary usage * aircrack-ng: Hardcode CPUs number to 1 in case detection fails * aircrack-ng: Fixed too low trashvalue * aireplay-ng: Fixed 384 bytes keystream output * aireplay-ng: Fixed IV index bug * aireplay-ng: Better error messages for -0 and -1 * airtun-ng: Works on FreeBSD * airtun-ng: Fix compilation under FC6 (missing "linux/if.h" include). * airodump-ng: Works on FreeBSD. * airodump-ng: Added encryption filtering * airodump-ng: Fixed a SIGSEGV * airodump-ng: Added WPA handshake detection * airodump-ng: Added non associated stations filter * airodump-ng: Added support for zd1211rw * airodump-ng: Fixed 100% cpu utilisation * airmon-ng: Added support for zd1211rw driver * airmon-ng: Added support for at76c503a, rt61 and rt73 * airmon-ng: Updated some device detection * airmon-ng: Added Nokia 770 and PrismGT softmac * airmon-ng: Fixed ACX driver monitor mode startup * airmon-ng: Fixed syntax error * airtun-ng: Works on FreeBSD * airtun-ng: Added pcap support to replay saved wlan sessions * airtun-ng: Added repeater mode, bssid and netmask filter * packetforge-ng: Added null packet support * packetforge-ng: Added packet selection for -9 * Patches: Added hostap kernel 2.6.18 patch * Patches: Updated rtl8187 patch. * Patches: Updated madwifi-ng patch. * Patches: Added injection patch for zd1211 (does not work for all devices). * Added airoscript (from daouid) * Makefiles: Fixed: make uninstall did not remove all files * Updated spec file by David Bolt to be able to build RPM packages on FC, Mandriva and Suse distro * Added WEP authentication example capture * Fixed gcc 2.95 compilation * Fixed compilation on MacIntel Version 0.7 (changes from aircrack-ng 0.6.2) - Released 20 January 2007: * Makefiles: Improved + added makefiles for other OS * Makefiles: Fixed make install on Windows and MacOS * airtun-ng: Creates a tuntap interface, through which ordinary IP frames can be injected * aireplay-ng: Added fragmentation attack * aireplay-ng: Added shared key authentication * airmon-ng: Now detect the shell when installing * airmon-ng: Added support for rtl8187 * aircrack-ng: Added WEP dictionary attack * aircrack-ng: Works with 802.11e QoS packets * airodump-ng: Added MAC filtering * airodump-ng: Now use the flaw in shared-key authentication to generate a xor file containing the prga recovered from a shared-key authentication * airodump-ng: More information about encryption on the AP * airodump-ng: Receive quality indicator * airodump-ng: The way ESSID is given in the CSV file is more clear * packetforge-ng: Set the TTL value in the ip header * packetforge-ng: Close open file handles * Special handling of spanning tree packets * Added rtl8187 patch for injection * Other bug fixes Version 0.6.2 (changes from aircrack-ng 0.6.1) - Released 1 October 2006: * aireplay-ng: Applied patch to inject packets with an ipw2200 * aircrack-ng: Fixed: show_wpa_stats() 1 byte array overflow * aircrack-ng: Fixed a warning when compiling on 64bit inner_bruteforcer_thread() * aircrack-ng: Changed -d option. It's now a mask (use XX for unknown bytes). * arpforge-ng: removed. It's replaced by packetforge-ng * packetforge-ng: New tool to forge packets (by Martin Beck) + manpage written * aircrack-ng, aireplay-ng, packetforge-ng: new MAC decoding function * airmon-ng: Fixed a bug when using it with madwifi-ng * airmon-ng: Added ipw3945 detection * airodump-ng (windows): now automatically download peek.dll and peek5.sys if needed * airodump-ng: LLC null packets are skipped * makeivs: added manpage * Makefile: Fixed: make aircrack-ng-opt-prof_gen fails * updated madwifi-ng patch Version 0.6.1 (changes from aircrack-ng 0.6) - Released 27 August 2006: * aircrack-ng: Fixed missing '-s' option * aircrack-ng: Fixed: Show a different ASCII key for a same hex key * airodump-ng: Using --band option instead of --bg, --abg, --ab, ... * airodump-ng: Fixed: fails to put wlanng in monitor mode * airodump-ng: using rtap0 as interface should now work * airodump-ng and aireplay-ng: "Can't find wireless tools, exiting." should be fixed if they exist * airodump-ng and airmon-ng: rt2570 now uses prismheader (use at least beta 2 driver) * airmon-ng: Fixed: discards ipw2200 v1.1.x * airmon-ng: Fixed: show newly created madwifi-ng VAP * airmon-ng: Should now works with 'ash' shell (Zaurus, OpenWRT, ...) * INSTALL: Added a note about warnings when compiling sources * INSTALL: Added more information about installing aircrack-ng on windows * updated spec file * some other bugfixes * cygwin1.dll and msvcr70.dll are now included in windows package Version 0.6 (changes from aircrack-ng 0.5) - Released 23 June 2006: * aircrack-ng: Multithreaded keybytes bruteforcer * aircrack-ng: Now bruteforce only last keybyte by default (faster than last 2KB) * aircrack-ng: Added option to show ASCII version of the key * aircrack-ng: Fixed: bug with -d option. It adds a leading "0x00" to the key * aireplay-ng: fixed compilaton issues on some distro * aireplay-ng: fixed a bug when using 'ash' * aireplay-ng: You can change ring buffer size (-g option) * airodump-ng: Log by default only one beacon (added option to log all beacons) * airodump-ng: Dump prefix isn't mandatory anymore, not giving it won't store any data * airmon-ng: Ralink devices needs be put in ad-hoc prior to inject packets * manpages: Added kstat manpage * manpages: fixed airodump-ng manpage (hyphen used as minus sign) * Makefile: You can now compile aircrack-ng with Intel C Compiler (really faster) * Updated madwifi-ng patch to r1545 (and up; can be applied on madwifi v0.9.0 and v0.9.1) * Added instructions to compile on different plateforms/OS * Added a WPA2 capture file in test directory * Some other fixes Version 0.5 (changes from aircrack-ng 0.4.4) - Released 04 May 2006: * airodump-ng: Hop on 2.4Ghz channels by default * airodump-ng: Added support for OpenWrt devices (use prism0 as capture interface) * aircrack-ng and aireplay-ng: korek chopchop optimisation (Thanks to ASPj) * airodump-ng: Fixed: when starting, it captured data on channel 10 * aircrack-ng: Fixed: Not using all CPU on SMP systems Version 0.4.4 (changes from aircrack-ng 0.4.3) - Released 24 april 2006: * aircrack-ng: fixed a stupid bug that prevent cracking * sha1-mmx.S: GNU_STACK ELF marking * updated patch for madwifi-ng r1526 and upper Version 0.4.3 (changes from aircrack-ng 0.4.2) - Released 24 april 2006: * airmon-ng: fixed madwifi-ng (VAP creation-destruction and a cosmetic fix) * aircrack-ng: fixed compilation under OSX * airodump-ng: added elapsed time * Makefile : added a MacOSX makefile (Makefile.osx) * updated patch for madwifi-ng r1520 and upper Version 0.4.2 (changes from aircrack-ng 0.4.1) - Released 20 april 2006: * airodump-ng: Fixed: dumpfile prefix took the name of the second argument * airodump-ng: Fixed: .gps file creation if GPSd isn't used * version.c removed (the content was moved to common.c) Version 0.4.1 (changes from aircrack-ng 0.4) - Released 19 april 2006: * airodump-ng: use of parameters like aircrack-ng, aireplay-ng, ... * airodump-ng: more sanity checks * airodump-ng & aireplay-ng: forbid the use of ndiswrapper * airodump-ng & aireplay-ng: check of iwpriv existence * manpages: updated and fixed typos * Makefile: fixed "make doc" * airmon-ng: fixed and improved madwifi detection Version 0.4 (changes from aircrack-ng 0.3) - Released 16 april 2006: * Typos fixed and cosmetic changes in sources and in manpages * manpages: updated airodump-ng screenshot * manpages and aireplay-ng: renamed attack names * airodump-ng: fixed some compile warnings * airodump-ng: hopping also on .11a channels if available * airodump-ng: fixed: GPS coordinates were never shown * airmon-ng: fixed ipw2100 (Thx to OverThere) and madwifi-ng detection * aircrack-ng: speed optimizations * aircrack-ng: -x option disable last 2 keybytes bruteforce (WEP cracking is faster) * aircrack-ng: with -a option, you can use "wep" or "wpa" instead of numbers * ivstools: --merge option fixed * Makefiles: improvements * Lots of little changes * added aircrack-ng.spec for building RPM * added slack-desc for building slackware packages Version 0.3 (changes from aircrack-ng 0.2.1) - Released 30 march 2006: * aireplay-ng: typo fixed * aireplay-ng: Madwifi-ng is now supported * airodump-ng: disabled GPS coordinates if connection to gpsd fail * airodump-ng: Battery information fixed (hacked kismet code) * airodump-ng: Madwifi-ng is now supported * aircrack-ng: corrected title (when cracking a key) * aircrack-ng: uses by default all CPU for cracking (Debian bug report #352877) * manpages: Fixed some errors (Debian bug report #356551) * manpages: created ivstools manpage * Makefiles: cleaning and improvement * fixed pcap2ivs bug (it wasn't using the good MAC for bssid) * Merged mergeivs and pcap2ivs into ivstools * airmon.sh: Fixed (hopefully) detection of ipw2100 and ipw2200 (Debian bug report #340057) * airmon.sh: renamed to airmon-ng * Updated madwifi-ng patch to r1486 Version 0.2.1 (changes from aircrack-ng 0.2) - Released 20 march 2006: * corrected 2 bugs in airmon.sh and changed another little thing * one word missing for option -j in aireplay * updated madwifi-old patch to SVN r1475 * makefile cleaning * typo corrected in pcap2ivs Version 0.2 (changes from aircrack-ng 0.1) - Released 19 march 2006: * updated version number and program name * updated airmon.sh added detection of acx, madwifi-ng and bcm43xx * added manpages (Thanks to Adam Cecile) * added madwifi-ng patches * re-added missing drivers patches * added uninstall rule in makefile * added Sharp Zaurus binaries (Thanks to Rick Farina aka Zero_Chaos) * added a cygwin makefile Version 0.1 (changes from aircrack 2.41) * updated windows binaries * compiled some files for windows * Separated in multiple packages ---------------------------------------------------------------------------------------------- Older Changelog: Version 2.41 released on 2005-11-22. Changes from version 2.4: * airodump: show probing clients as "not associated" * airodump: don't substract the noise level unless madwifi * airodump: fixed channel hopping with old orinoco * airmon.sh: added detection of the zd1211 driver Version 2.4 released on 2005-11-12. Changes from version 2.3: * airodump: display ESSIDs from Probe Requests * airodump: don't overwrite existing capture files * airodump: create a logfile of the gps coordinates * airodump: every 20s, sort the detected APs by power * airodump: display the remaining battery capacity * airodump: use ioctl() instead of calling iwconfig * airodump: added support for radiotap headers * aireplay: added option -j (FromDS packet injection) * aireplay: added prismheader support for rt2500 / rt2570 * aireplay: fixed attack -0 when injecting on ralink usb * aireplay: fixed attack -3 (ring buffer / deauth problem) * aircrack: don't bruteforce the last 2 keybytes by default * aircrack: changed the fudge factor type to float * aircrack: added option -t (restrict keyspace to BCD) * aircrack: fixed the check_wep_key false positive bug * aircrack: fixed overflow of the number of tested keys * aircrack: lower number of required IVs if -d is used * mergeivs and pcap2ivs: initial release Version 2.3 released on 2005-08-28. Changes from version 2.23: * aireplay: added patch for injection on Ralink USB * aireplay: improved deauthentication attack (-c flag) * aireplay: don't enable the prism header on athXraw * airodump: fixed rare hanging problem in dump_write_csv * airodump: workaround for ipw2200 wep data corruption bug * airodump: tweaked dump_print to make more space for ESSID * aircrack: added support for 152-bit WEP cracking * updated the documentation and merged versioning patch Version 2.23 released on 2005-08-17. Changes from version 2.22: * aireplay: updated the madwifi patch, fixes WEP/WPA support * airodump: fixed a few buffer overflows, code cleanup for gcc4 * aircrack: also printf the WEP key if >= 75% ASCII caracters Version 2.22 released on 2005-08-14. Changes from version 2.21: * aireplay: now compatible with madwifi CVS 2005-08-14 * airodump: fixed the output power with newer madwifi Version 2.21 released on 2005-08-09. Changes from version 2.2: * airodump: forcefully exit when user presses Ctrl-C * airodump: bugfixed (yet again) ESSID uncloacking * airodump: re-create the ivs file if no header present * aircrack: changed the default fudge factor back to 2 * airdecap: fixed the incorrect output pcap header length Version 2.2 released on 2005-08-03. Changes from version 2.2-beta12: * aireplay: (attack 1) added G rates in the association request * fixed the Makefile for compilation on FreeBSD / Mac OS X Version 2.2-beta12 released on 2005-07-30. Changes from version 2.2-beta11: * aireplay: bugfixed the madwifi patch, switched to 20050707 * aireplay: avoid triggering "protocol XX00 is buggy" messages * airodump: don't reset the card when hopping between channels * airodump: ipw2200 didn't like calling "iwpriv ethX monitor 1" * airodump: added support for airodump on WRT54G / OpenWRT * airodump: commit the .txt statistics file every 20 seconds * aircrack: increased the default fudge factor (3 for WEP-104) Version 2.2-beta11 released on 2005-07-27. Changes from version 2.2-beta10: * aireplay: updated the madwifi patch to inject in b/g mode * aireplay: fixed attack 2 (it wrongly swapped the smac & dmac) * aircrack: (cygwin) added O_BINARY flag to force binary mode Version 2.2-beta10 released on 2005-07-23. Changes from version 2.2-beta9: * aireplay: fixed the status line not showing in attack -3 * aireplay: updated the madwifi and hostap injection patches * aireplay: added patches for injection on rt2500 and rtl8180 * aircrack: added detection of 802.1d in check_wep_key * airodump: restore prismheader link level info w/ hostap * airodump: create the output file if there's no pcap header * airdecap: added flag -l to disable ethernet conversion * updated the win32 port and rewrote the documentation Version 2.2-beta9 released on 2005-07-21. Changes from version 2.2-beta8: * aireplay: fixed the invalid rtc file descriptor bug * aircrack: actually fixed the prism header endianness bug Version 2.2-beta8 released on 2005-07-21. Changes from version 2.2-beta7: * aireplay: specify the deauth count instead of delay * aircrack: fixed an endianness issue with the prism header * aircrack: added the experimental single bruteforce attack * airodump: do enable the prismheader with wlan-ng * airodump: WEP/WPA: show the number of data packets * airodump: show total number of captured beacon packets * airodump: orinoco: fixed "iwpriv ethX monitor 1" command * airdecap: fixed an endianness issue with the packet length * airdecap: skip already processed duplicate packets Version 2.2-beta7 released on 2005-07-14. Changes from version 2.2-beta6: * airodump: don't enable the prismheader with wlan-ng * aircrack: fixed check_wepkey() to avoid false positives * completed the preliminary win32 port Version 2.2-beta6 released on 2005-07-12. Changes from version 2.2-beta5: * aireplay: fixed injection of fromds packets on Prism2 * aireplay: attack 0: target access point must be specified * aireplay: attack 1: allow the user to change reauth delay * aircrack: fixed race condition when realloc() ap->ivbuf * airodump: fixed endianness issue when parsing prism header Version 2.2-beta5 released on 2005-07-10. Changes from version 2.2-beta4: * aireplay: added patch for single-nic injection on hostap * aireplay: fixed chopchop attack in non-authenticated mode * aireplay: don't flood the AP with authentication requests * aircrack: bruteforce the last two keybytes by default * aircrack: improved handling of partial WPA handshakes * aircrack, airdecap: added WPA2 (RSN / 802.11i) support Version 2.2-beta4 released on 2005-07-03. Changes from version 2.2-beta3: * aircrack: new option to restrict WEP search space to ascii * aircrack: fixed concurrency bug with multiple .cap files * aircrack: fixed incorrect detection of WPA CCMP handshakes * aircrack: fixed incorrect handling of HMAC-SHA1 WPA MIC * aireplay: fixed deauth problem when chopchoping a packet * aireplay: added a workaround for error "Write buffer full" * airodump: added support for prism header on prism54 * airodump: save the list of detected wireless clients * airunwep: renamed to airdecap, added WPA decryption support Version 2.2-beta3 released on 2005-06-28. Changes from version 2.2-beta2: * aircrack: fixed the tracking of new IVs * aireplay: fixed the CPU usage bug in attack 3 * when reading pcap files, check the packet length Version 2.2-beta2 released on 2005-06-27. Changes from version 2.2-beta1: * aireplay: added fully automated ARP replay attack * aireplay: added automated deauthentication attack * aireplay: added fake authentication in Monitor mode * aircrack: various pthread enhancements & bugfixes Version 2.2-beta1 released on 2005-06-22. Changes from version 2.1: * aircrack: now auto-updates if new IVs are available * aircrack: fixed #285441 (struct pcap_pkthdr on AMD64) * aircrack: fixed the pcap endianness problem * aircrack: added essid filtering option and quiet mode * aircrack: only print status info every 1/20th second * aircrack: added WPA-PSK cracking support from cowpatty * aircrack: added EAPOL frame type detection and display * aircrack: each korek attack can be disabled selectively * airodump: added 802.11 b/g (2.4 GHz) channel hopping * airodump: added a file format for logging only the IVs * airodump: CRC is properly removed if driver is madwifi * airodump: input packets can be read from a pcap file * airodump: bugfixed WPA detection and ESSID uncloaking * airodump: also display a list of detected stations * aireplay: implemented chopchop and arp-forgery * aireplay: added patches for single-nic injection * 802ether: bugfixed and renamed to airunwep Version 2.1 released on 2004-10-01. Changes from version 2.0.2: * added 11g and WPA detection support in airodump * aircrack automatically avoids using WPA IVs * aircrack can break 256-bit and 512-bit WEP keys * win32 - fixed yet again the "missed IVs" bug * win32 - ported the 802ether WEP decryptor program Version 2.0.2 released on 2004-09-24. Changes from version 2.0.1: * win32 - added the WZCOOK key recovery program * fixed a bug in the BSSID iteration code in airodump * completely rewrote the documentation, moved to /docs Version 2.0.1 released on 2004-09-21. Changes from version 2.0: * win32 - fixed the channel reset bug * win32 - fixed the "missed IVs" bug * win32 - rewrote drivers.txt Version 2.0 released on 2004-09-03. Changes from version 1.4: * native win32 port of airodump and aircrack * aireplay better spots potential arp-requests Version 1.4 released on 2004-08-26. Changes from version 1.3: * fixed check_wepkey, works with exotic LLC headers * airodump prints lots of information, Kismet-style Version 1.3 released on 2004-08-19. Changes from version 1.2: * bugfixed and improved KoreK's code * renamed airunwep to 802ether Version 1.2 released on 2004-08-17. Changes from version 1.1: * implemented KoreK's advanced WEP attacks * completely rewrote the SMP engine Version 1.1 released on 2004-08-11. Changes from version 1.0: * implemented WEP arp-requests replay attack * improved the fudge calculation algorithm * added multi-processor support Version 1.0 released on 2004-07-29 aircrack-ng-1.6/INSTALLING000066400000000000000000000312531361312141100151250ustar00rootroot00000000000000== Building == === Requirements === * Autoconf * Automake * Libtool * shtool * OpenSSL development package or libgcrypt development package. * Airmon-ng (Linux) requires ethtool. * On windows, cygwin has to be used and it also requires w32api package. * On Windows, if using clang, libiconv and libiconv-devel * Linux: LibNetlink 1 or 3. It can be disabled by passing --disable-libnl to configure. * pkg-config (pkgconf on FreeBSD) * FreeBSD, OpenBSD, NetBSD, Solaris and OS X with macports: gmake * Linux/Cygwin: make and Standard C++ Library development package (Debian: libstdc++-dev) === Optional stuff === * If you want SSID filtering with regular expression in airodump-ng (-essid-regex) pcre development package is required. * If you want to use airolib-ng and '-r' option in aircrack-ng, SQLite development package >= 3.3.17 (3.6.X version or better is recommended) * If you want to use Airpcap, the 'developer' directory from the CD/ISO/SDK is required. * In order to build besside-ng, besside-ng-crawler, easside-ng, tkiptun-ng and wesside-ng, libpcap development package is required (on Cygwin, use the Aircap SDK instead; see above) * For best performance on FreeBSD (50-70% more), install gcc5 (or better) via: pkg install gcc9 * rfkill * If you want Airodump-ng to log GPS coordinates, gpsd is needed * For best performance on SMP machines, ensure the hwloc library and headers are installed. It is strongly recommended on high core count systems, it may give a serious speed boost * CMocka for unit testing * For intergation testing on Linux only: tcpdump, HostAPd, WPA Supplicant and screen === Installing required and optional dependencies === Below are instructions for installing the basic requirements to build `aircrack-ng` for a number of operating systems. Note: CMocka, tcpdump, screen, HostAPd and WPA Supplicant should not be dependencies when packaging Aircrack-ng. ==== Linux ==== ===== Debian/Ubuntu ===== `sudo apt-get install build-essential autoconf automake libtool pkg-config libnl-3-dev libnl-genl-3-dev libssl-dev ethtool shtool rfkill zlib1g-dev libpcap-dev libsqlite3-dev libpcre3-dev libhwloc-dev libcmocka-dev hostapd wpasupplicant tcpdump screen iw usbutils` ===== Fedora/CentOS/RHEL ===== `sudo yum install libtool pkgconfig sqlite-devel autoconf automake openssl-devel libpcap-devel pcre-devel rfkill libnl3-devel gcc gcc-c++ ethtool hwloc-devel libcmocka-devel git make file expect hostapd wpa_supplicant iw usbutils tcpdump screen` Note: on CentOS and RedHat, HostAPd requires 'epel' repository to be enabled: sudo yum install epel-release ===== openSUSE ===== `sudo zypper install autoconf automake libtool pkg-config libnl3-devel libopenssl-1_1-devel zlib-devel libpcap-devel sqlite3-devel pcre-devel hwloc-devel libcmocka-devel hostapd wpa_supplicant tcpdump screen iw gcc-c++ gcc` ===== Mageia ===== `sudo urpmi autoconf automake libtool pkgconfig libnl3-devel libopenssl-devel zlib-devel libpcap-devel sqlite3-devel pcre-devel hwloc-devel libcmocka-devel hostapd wpa_supplicant tcpdump screen iw gcc-c++ gcc make` ===== Alpine ===== `sudo apk add gcc g++ make autoconf automake libtool libnl3-dev openssl-dev ethtool libpcap-dev cmocka-dev hostapd wpa_supplicant tcpdump screen iw pkgconf util-linux sqlite-dev pcre-dev linux-headers zlib-dev` ==== BSD ==== ===== FreeBSD ===== `pkg install pkgconf shtool libtool gcc9 automake autoconf pcre sqlite3 openssl gmake hwloc cmocka` ===== DragonflyBSD ===== `pkg install pkgconf shtool libtool gcc8 automake autoconf pcre sqlite3 libgcrypt gmake cmocka` ===== OpenBSD ===== `pkg_add pkgconf shtool libtool gcc automake autoconf pcre sqlite3 openssl gmake cmocka` ==== OSX ==== XCode, Xcode command line tools and HomeBrew are required. `brew install autoconf automake libtool openssl shtool pkg-config hwloc pcre sqlite3 libpcap cmocka` ==== Windows ==== ===== Cygwin ===== Cygwin requires the full path to the `setup.exe` utility, in order to automate the installation of the necessary packages. In addition, it requires the location of your installation, a path to the cached packages download location, and a mirror URL. An example of automatically installing all the dependencies is as follows: `c:\cygwin\setup-x86.exe -qnNdO -R C:/cygwin -s http://cygwin.mirror.constant.com -l C:/cygwin/var/cache/setup -P autoconf -P automake -P bison -P gcc-core -P gcc-g++ -P mingw-runtime -P mingw-binutils -P mingw-gcc-core -P mingw-gcc-g++ -P mingw-pthreads -P mingw-w32api -P libtool -P make -P python -P gettext-devel -P gettext -P intltool -P libiconv -P pkg-config -P git -P wget -P curl -P libpcre-devel -P libssl-devel -P libsqlite3-devel` ===== MSYS2 ===== `pacman -Sy autoconf automake-wrapper libtool msys2-w32api-headers msys2-w32api-runtime gcc pkg-config git python openssl-devel openssl libopenssl msys2-runtime-devel gcc binutils make pcre-devel libsqlite-devel` === Compiling === To build `aircrack-ng`, the Autotools build system is utilized. Autotools replaces the older method of compilation. NOTE: If utilizing a developer version, eg: one checked out from source control, you will need to run a pre-`configure` script. The script to use is one of the following: `autoreconf -i` or `env NOCONFIGURE=1 ./autogen.sh`. First, `./configure` the project for building with the appropriate options specified for your environment: `./configure ` TIP: If the above fails, please see above about developer source control versions. Next, compile the project (respecting if `make` or `gmake` is needed): * Compilation: `make` * Compilation on *BSD or Solaris: `gmake` Finally, the additional targets listed below may be of use in your environment: * Execute all unit testing: `make check` * Execute all integration testing (requires root): `make integration` * Installing: `make install` * Uninstall: `make uninstall` ==== `./configure` flags ==== When configuring, the following flags can be used and combined to adjust the suite to your choosing: * with-airpcap=DIR: needed for supporting airpcap devices on windows (cygwin or msys2 only) Replace DIR above with the absolute location to the root of the extracted source code from the Airpcap CD or downloaded SDK available online. Required on Windows to build besside-ng, besside-ng-crawler, easside-ng, tkiptun-ng and wesside-ng when building experimental tools. The developer pack (Compatible with version 4.1.1 and 4.1.3) can be downloaded at https://support.riverbed.com/content/support/software/steelcentral-npm/airpcap.html * with-experimental: needed to compile tkiptun-ng, easside-ng, buddy-ng, buddy-ng-crawler, airventriloquist and wesside-ng. libpcap development package is also required to compile most of the tools. If not present, not all experimental tools will be built. On Cygwin, libpcap is not present and the Airpcap SDK replaces it. See --with-airpcap option above. * with-ext-scripts: needed to build `airoscript-ng`, `versuck-ng`, `airgraph-ng` and `airdrop-ng`. Note: Each script has its own dependencies. * with-gcrypt: Use libgcrypt crypto library instead of the default OpenSSL. And also use internal fast sha1 implementation (borrowed from GIT) Dependency (Debian): libgcrypt20-dev * with-duma: Compile with DUMA support. DUMA is a library to detect buffer overruns and under-runs. Dependencies (debian): duma * disable-libnl: Set-up the project to be compiled without libnl (1 or 3). Linux option only. * without-opt: Do not enable stack protector (on GCC 4.9 and above). * enable-shared: Make a OSdep a shared library. * disable-shared: When combined with enable-static, it will statically compile Aircrack-ng. * with-avx512: On x86, add support for AVX512 instructions in aircrack-ng. Only use it when the current CPU supports AVX512. * with-static-simd=: Compile a single optimization in aircrack-ng binary. Useful when compiling statically and/or for space-constrained devices. Valid SIMD options: x86-sse2, x86-avx, x86-avx2, x86-avx512, ppc-altivec, ppc-power8, arm-neon, arm-asimd. Must be used with --enable-static --disable-shared. When using those 2 options, the default is to compile the generic optimization in the binary. --with-static-simd merely allows to choose another one. ===== Examples ===== * Configure and compiling: `./configure --with-experimental` `make` * Compiling with gcrypt: `./configure --with-gcrypt` `make` * Installing: `make install` * Installing (strip binaries): `make install-strip` * Installing, with external scripts: `./configure --with-experimental --with-ext-scripts` `make` `make install` * Testing (with sqlite, experimental and pcre) `./configure --with-experimental` `make` `make check` * Compiling on OS X with macports (and all options): `./configure --with-experimental` `gmake` * Compiling on OS X 10.10 with XCode 7.1 and Homebrew: `env CC=gcc-4.9 CXX=g++-4.9 ./configure` `make` `make check` *NOTE*: Older XCode ships with a version of LLVM that does not support CPU feature detection; which causes the `./configure` to fail. To work around this older LLVM, it is required that a different compile suite is used, such as GCC or a newer LLVM from Homebrew. If you wish to use OpenSSL from Homebrew, you may need to specify the location to its' installation. To figure out where OpenSSL lives, run: `brew --prefix openssl` Use the output above as the DIR for `--with-openssl=DIR` in the `./configure` line: `env CC=gcc-4.9 CXX=g++-4.9 ./configure --with-openssl=DIR` `make` `make check` * Compiling on FreeBSD with gcc9 `env CC=gcc9 CXX=g++9 MAKE=gmake ./configure` `gmake` * Compiling on Cygwin with Airpcap (assuming Airpcap devpack is unpacked in Aircrack-ng directory) ``` cp -vfp Airpcap_Devpack/bin/x86/airpcap.dll src cp -vfp Airpcap_Devpack/bin/x86/airpcap.dll src/aircrack-osdep cp -vfp Airpcap_Devpack/bin/x86/airpcap.dll src/aircrack-crypto cp -vfp Airpcap_Devpack/bin/x86/airpcap.dll src/aircrack-util dlltool -D Airpcap_Devpack/bin/x86/airpcap.dll -d build/airpcap.dll.def -l Airpcap_Devpack/bin/x86/libairpcap.dll.a autoreconf -i ./configure --with-experimental --with-airpcap=$(pwd) make ``` * Compiling on DragonflyBSD with gcrypt using GCC 8 ``` autoreconf -i env CC=gcc8 CXX=g++8 MAKE=gmake ./configure --with-experimental --with-gcrypt gmake ``` * Compiling on OpenBSD (with autoconf 2.69 and automake 1.16) ``` export AUTOCONF_VERSION=2.69 export AUTOMAKE_VERSION=1.16 autoreconf -i env MAKE=gmake ./configure gmake ``` * Compiling and debugging aircrack-ng ``` export CFLAGS='-O0 -g' export CXXFLAGS='-O0 -g' ./configure make LD_LIBRARY_PATH=.libs gdb --args ./aircrack-ng [PARAMETERS] ``` == Packaging == Automatic detection of CPU optimization is done at run time. This behavior **is** desirable when packaging Aircrack-ng (for a Linux or other distribution.) Also, in some cases it may be desired to provide your own flags completely and not having the suite auto-detect a number of optimizations. To do this, add the additional flag `--without-opt` to the `./configure` line: `./configure --without-opt` == Using precompiled binaries == === Linux/BSD === * Use your package manager to download aircrack-ng * In most cases, they have an old version. * Packages (DEB and RPM) built from current git master are available on PackageCloud: https://packagecloud.io/aircrack-ng/git === Windows === * Install the appropriate "monitor" driver for your card (standard drivers doesn't work for capturing data). * aircrack-ng suite is command line tools. So, you have to open a commandline `Start menu -> Run... -> cmd.exe` then use them * Run the executables without any parameters to have help == Continous integration == Travis (Linux/Mac): https://travis-ci.org/aircrack-ng/aircrack-ng AppVeyor: https://ci.appveyor.com/project/aircrack-ng/aircrack-ng Coverity Scan: https://scan.coverity.com/projects/aircrack-ng === Buildbots === URL: https://buildbot.aircrack-ng.org/ Current buildbots: - Intel Compiler - Alpine Linux - Kali Linux - Armel Kali Linux - Armhf Kali Linux - FreeBSD == Documentation == Documentation, tutorials, ... can be found on https://www.aircrack-ng.org See also manpages and the forum. aircrack-ng-1.6/LICENSE000066400000000000000000000431311361312141100145410ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. aircrack-ng-1.6/LICENSE.OpenSSL000066400000000000000000000142071361312141100160250ustar00rootroot00000000000000 LICENSE ISSUES ============== The OpenSSL toolkit stays under a dual license, i.e. both the conditions of the OpenSSL License and the original SSLeay license apply to the toolkit. See below for the actual license texts. Actually both licenses are BSD-style Open Source licenses. In case of any license issues related to OpenSSL please contact openssl-core@openssl.org. OpenSSL License --------------- /* ==================================================================== * Copyright (c) 1998-2007 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" * * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * openssl-core@openssl.org. * * 5. Products derived from this software may not be called "OpenSSL" * nor may "OpenSSL" appear in their names without prior written * permission of the OpenSSL Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the OpenSSL Project * for use in the OpenSSL Toolkit (http://www.openssl.org/)" * * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. * ==================================================================== * * This product includes cryptographic software written by Eric Young * (eay@cryptsoft.com). This product includes software written by Tim * Hudson (tjh@cryptsoft.com). * */ Original SSLeay License ----------------------- /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ aircrack-ng-1.6/Makefile.am000066400000000000000000000067351361312141100156010ustar00rootroot00000000000000# Aircrack-ng # # Copyright (C) 2017 Joseph Benden # # Autotool support was written by: Joseph Benden # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA # # In addition, as a special exception, the copyright holders give # permission to link the code of portions of this program with the # OpenSSL library under certain conditions as described in each # individual source file, and distribute linked combinations # including the two. # # You must obey the GNU General Public License in all respects # for all of the code used other than OpenSSL. # # If you modify file(s) with this exception, you may extend this # exception to your dnl version of the file(s), but you are not obligated # to do so. # # If you dnl do not wish to do so, delete this exception statement from your # version. # # If you delete this exception statement from all source files in the # program, then also delete it here. ACLOCAL_AMFLAGS = -I build/m4/stubs -I build/m4 SUBDIRS = manpages \ scripts AM_CPPFLAGS = -I$(abs_srcdir) \ -I$(abs_builddir)/include \ -I$(abs_srcdir)/include \ -I$(abs_builddir)/lib \ -I$(abs_srcdir)/lib \ -I$(abs_builddir)/lib/radiotap \ -I$(abs_srcdir)/lib/radiotap \ $(CRYPTO_INCLUDES) \ $(CODE_COVERAGE_CPPFLAGS) CFLAGS += $(CODE_COVERAGE_CFLAGS) CXXFLAGS += $(CODE_COVERAGE_CXXFLAGS) LIBS += $(CODE_COVERAGE_LIBS) COMMON_CFLAGS = $(PTHREAD_CFLAGS) $(CRYPTO_CFLAGS) $(ZLIB_CFLAGS) COMMON_LDADD = $(PTHREAD_LIBS) $(CRYPTO_LIBS) $(ZLIB_LIBS) bin_PROGRAMS = sbin_PROGRAMS = noinst_LTLIBRARIES = lib_LTLIBRARIES = EXTRA_DIST = VERSION check_PROGRAMS = TESTS = INTEGRATION_TESTS = LIBACCRYPTO_LIBS = libaccrypto.la LIBAIRCRACK_CE_WEP_LIBS = libaircrack-ce-wep.la LIBAIRCRACK_LIBS = libaircrack.la LIBAIRCRACK_OSDEP_LIBS= libaircrack-osdep.la if CYGWIN LIBAIRCRACK_OSDEP_LIBS+= -liphlpapi -lsetupapi endif LIBCOWPATTY_LIBS = libcowpatty.la LIBPTW_LIBS = libptw.la LIBRADIOTAP_LIBS = libradiotap.la LIBAIRCRACK_CE_WPA_LIBS = libaircrack-ce-wpa.la LIBAIRCRACK_CE_WPA_X86_AVX512_LIBS = libaircrack-ce-wpa-x86-avx512.la LIBAIRCRACK_CE_WPA_X86_AVX2_LIBS = libaircrack-ce-wpa-x86-avx2.la LIBAIRCRACK_CE_WPA_X86_AVX_LIBS = libaircrack-ce-wpa-x86-avx.la LIBAIRCRACK_CE_WPA_X86_SSE2_LIBS = libaircrack-ce-wpa-x86-sse2.la LIBAIRCRACK_CE_WPA_ARM_NEON_LIBS = libaircrack-ce-wpa-arm-neon.la LIBAIRCRACK_CE_WPA_PPC_ALTIVEC_LIBS = libaircrack-ce-wpa-ppc-altivec.la LIBAIRCRACK_CE_WPA_PPC_POWER8_LIBS = libaircrack-ce-wpa-ppc-power8.la LIBAIRCRACK_CE_WPA_PATH = $(abs_top_builddir)/ include $(top_srcdir)/Makefile.integration.mk include $(top_srcdir)/include/Makefile.inc include $(top_srcdir)/lib/Makefile.inc include $(top_srcdir)/src/Makefile.inc include $(top_srcdir)/test/Makefile.inc include $(top_srcdir)/aminclude_static.am clean-local: code-coverage-clean distclean-local: code-coverage-dist-clean aircrack-ng-1.6/Makefile.integration.mk000066400000000000000000000133501361312141100201240ustar00rootroot00000000000000 INTEGRATION_TEST_SUITE_LOG = integration-test-suite.log am__set_INTEGRATION_TESTS_bases = \ bases='$(INTEGRATION_TEST_LOGS)'; \ bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \ bases=`echo $$bases` am__integration_test_logs1 = $(INTEGRATION_TESTS:=.log) INTEGRATION_TEST_LOGS = $(am__integration_test_logs1:.log=.log) # Leading 'am--fnord' is there to ensure the list of targets does not # expand to empty, as could happen e.g. with make check TESTS=''. am--fnord $(INTEGRATION_TEST_LOGS) $(INTEGRATION_TEST_LOGS:.log=.trs): $(am__force_recheck) $(INTEGRATION_TEST_SUITE_LOG): $(INTEGRATION_TEST_LOGS) @$(am__set_INTEGRATION_TESTS_bases); \ am__f_ok () { test -f "$$1" && test -r "$$1"; }; \ redo_bases=`for i in $$bases; do \ am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \ done`; \ if test -n "$$redo_bases"; then \ redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \ redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \ if $(am__make_dryrun); then :; else \ rm -f $$redo_logs && rm -f $$redo_results || exit 1; \ fi; \ fi; \ if test -n "$$am__remaking_logs"; then \ echo "fatal: making $(INTEGRATION_TEST_SUITE_LOG): possible infinite" \ "recursion detected" >&2; \ elif test -n "$$redo_logs"; then \ am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ fi; \ if $(am__make_dryrun); then :; else \ st=0; \ errmsg="fatal: making $(INTEGRATION_TEST_SUITE_LOG): failed to create"; \ for i in $$redo_bases; do \ test -f $$i.trs && test -r $$i.trs \ || { echo "$$errmsg $$i.trs" >&2; st=1; }; \ test -f $$i.log && test -r $$i.log \ || { echo "$$errmsg $$i.log" >&2; st=1; }; \ done; \ test $$st -eq 0 || exit 1; \ fi @$(am__sh_e_setup); $(am__tty_colors); $(am__set_INTEGRATION_TESTS_bases); \ ws='[ ]'; \ results=`for b in $$bases; do echo $$b.trs; done`; \ test -n "$$results" || results=/dev/null; \ all=` grep "^$$ws*:test-result:" $$results | wc -l`; \ pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \ fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \ skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \ xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \ xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \ error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \ if test `expr $$fail + $$xpass + $$error` -eq 0; then \ success=true; \ else \ success=false; \ fi; \ br='==================='; br=$$br$$br$$br$$br; \ result_count () \ { \ if test x"$$1" = x"--maybe-color"; then \ maybe_colorize=yes; \ elif test x"$$1" = x"--no-color"; then \ maybe_colorize=no; \ else \ echo "$@: invalid 'result_count' usage" >&2; exit 4; \ fi; \ shift; \ desc=$$1 count=$$2; \ if test $$maybe_colorize = yes && test $$count -gt 0; then \ color_start=$$3 color_end=$$std; \ else \ color_start= color_end=; \ fi; \ echo "$${color_start}# $$desc $$count$${color_end}"; \ }; \ create_testsuite_report () \ { \ result_count $$1 "TOTAL:" $$all "$$brg"; \ result_count $$1 "PASS: " $$pass "$$grn"; \ result_count $$1 "SKIP: " $$skip "$$blu"; \ result_count $$1 "XFAIL:" $$xfail "$$lgn"; \ result_count $$1 "FAIL: " $$fail "$$red"; \ result_count $$1 "XPASS:" $$xpass "$$red"; \ result_count $$1 "ERROR:" $$error "$$mgn"; \ }; \ { \ echo "$(PACKAGE_STRING): $(subdir)/$(INTEGRATION_TEST_SUITE_LOG)" | \ $(am__rst_title); \ create_testsuite_report --no-color; \ echo; \ echo ".. contents:: :depth: 2"; \ echo; \ for b in $$bases; do echo $$b; done \ | $(am__create_global_log); \ } >$(INTEGRATION_TEST_SUITE_LOG).tmp || exit 1; \ mv $(INTEGRATION_TEST_SUITE_LOG).tmp $(INTEGRATION_TEST_SUITE_LOG); \ if $$success; then \ col="$$grn"; \ else \ col="$$red"; \ test x"$$VERBOSE" = x || cat $(INTEGRATION_TEST_SUITE_LOG); \ fi; \ echo "$${col}$$br$${std}"; \ echo "$${col}Integration test-suite summary for $(PACKAGE_STRING)$${std}"; \ echo "$${col}$$br$${std}"; \ create_testsuite_report --maybe-color; \ echo "$$col$$br$$std"; \ if $$success; then :; else \ echo "$${col}See $(subdir)/$(INTEGRATION_TEST_SUITE_LOG)$${std}"; \ if test -n "$(PACKAGE_BUGREPORT)"; then \ echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \ fi; \ echo "$$col$$br$$std"; \ fi; \ $$success || exit 1 integration-TESTS: @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list @test -z "$(INTEGRATION_TEST_SUITE_LOG)" || rm -f $(INTEGRATION_TEST_SUITE_LOG) @set +e; $(am__set_INTEGRATION_TESTS_bases); \ log_list=`for i in $$bases; do echo $$i.log; done`; \ trs_list=`for i in $$bases; do echo $$i.trs; done`; \ log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \ for b in $$bases; do \ p='$$b$(EXEEXT)'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$b" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$b" $(AM_TESTS_FD_REDIRECT); \ done; \ $(MAKE) $(AM_MAKEFLAGS) $(INTEGRATION_TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \ exit $$?; integration: $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) $(integration_PROGRAMS) $(MAKE) $(AM_MAKEFLAGS) integration-TESTS mostlyclean-local: -test -z "$(INTEGRATION_TEST_LOGS)" || rm -f $(INTEGRATION_TEST_LOGS) -test -z "$(INTEGRATION_TEST_LOGS:.log=.trs)" || rm -f $(INTEGRATION_TEST_LOGS:.log=.trs) -test -z "$(INTEGRATION_TEST_SUITE_LOG)" || rm -f $(INTEGRATION_TEST_SUITE_LOG) aircrack-ng-1.6/README000066400000000000000000000151471361312141100144220ustar00rootroot00000000000000Documentation, tutorials, ... can be found on https://www.aircrack-ng.org See also manpages and the forum. Installing ========== This version has more dependencies/libraries required than previous versions to be compiled. See INSTALLING file for more information OpenWrt Devices =============== You can use airodump-ng on OpenWrt devices. You'll have to use specify prism0 as interface. Airodump-ng will automatically create it. Rq: Aireplay DOESN'T work on OpenWrt (2.4 kernel) with broadcom chipset since the driver doesn't support injection. It *may* work with 2.6 kernels >= 2.6.24 (kamikaze 8.09+ custom-built). Known bugs: =========== Drivers ------- Madwifi-ng ---------- The cause of most of these problems (1, 2 and 3) is that Madwifi-ng cannot easily change the rate in monitor mode. Technically, when changing rate while in monitor mode, the raw socket gets invalidated and we have to get it again. Madwifi-ng is getting replaced by several drivers: ath5k, ath9k and ar9170. Problem 1: No client can associate to an airbase soft AP. Solution: Use a more recent driver. Madwifi-ng has been deprecated for years. Problem 2: When changing rate while you are capturing packet makes airodump-ng stall Solution 2: Restart airodump-ng or change rate before starting it. Problem 3: After some time it stops capturing packets and you're really sure no network manager are running at all. Solution 3: That's a known bug in the driver, it may happen at any time (the time before it fails can vary a lot: from 5 minutes to 50 or even more). Try (as root) unloading completely the driver with 'madwifi-unload' and then run 'modprobe ath_pci autocreate=monitor'. Problem 4: When creating a new VAP airodump-ng takes up to 10-15 seconds to see the first packet Solution 4: It's the behavior of madwifi-ng, don't worry (... be happy ;)). Orinoco ------- Problem: BSSID is not reported correctly or is 00:00:00:00:00:00 or signal is not reported correctly. Solution: None. Consider replacing your card, orinoco is really really old. Aircrack-ng ----------- Aireplay-ng ----------- Problem: Fakeauth on a WRT54G with WEP (shared authentication) doesn't work. Solution: None at this time (we'll try to fix it in an upcoming release). Airolib-ng ---------- Problem: On windows only, opening/creating a database doesn't work when airolib-ng is in directories containing special characters like 'ç', 'é', 'è', 'à', ... (directories containing spaces are not affected). Reason: It's a SQLite issue. Solution: Rename the directory or move the database into another directory. Airodump-ng ----------- Problem: Airodump-ng stop working after some time. Solution 1: You may have a network manager running that puts back the card in managed mode. You'll have to disable it (the fastest solution is killing the process) then restart airodump-ng. Solution 2: See Problem 3 of Madwifi-ng. Problem: On windows, it doesn't display a list of adapters like the old 0.X Solution: It requires you to develop your own DLL. Problem: Handshake is not captured/detected Reason: You might be too far and your signal is bad (or too close with a signal too strong). Another possibility is that Airodump-ng didn't detect the handshake properly due to being far apart in the capture. Solution 1: Check out our tutorial 'WPA Packet Capture Explained' in the wiki. Solution 2: Try running Aircrack-ng on your capture, it might detect the capture. Solution 3: Check out our wpaclean tool. Note: It will be fixed in an upcoming release. Cygwin ------ Problem: /usr/include/sys/reent.h:14:20: fatal error: stddef.h: No such file or directory Solution: It happens because the gcc and g++ version are different. Make sure they are the same. Sample files ============ wep.open.system.authentication.cap: It show a connexion (authentication then association) to a WEP network (open authentication). wep.shared.key.authentication.cap: It shows a connexion (authentication then association to a WEP network (shared authentication). The difference with open authentication is that the client has to encrypt a challenge text and send it back (encrypted) to the AP to prove it has the right key. wpa.cap: This is a sample file with a WPA handshake. It is located in the test/ directory of the install files. The passphrase is 'biscotte'. Use the password file (password.lst) which is in the same directory. wpa2.eapol.cap: This is a sample file with a WPA2 handshake. It is located in the test/ directory of the install files. The passphrase is '12345678'. Use the password file (password.lst) which is in the same directory. test.ivs (http://download.aircrack-ng.org/wiki-files/other/test.ivs): This is a 128 bit WEP key file. The key is AE:5B:7F:3A:03:D0:AF:9B:F6:8D:A5:E2:C7. wep_64_ptw.cap (http://dl.aircrack-ng.org/ptw.cap): This is a 64 bit WEP key file suitable for the PTW method. The key is '1F:1F:1F:1F:1F'. wpa-psk-linksys.cap: This is a sample file with a WPA1 handshake along with some encrypted packets. Useful for testing with airdecap-ng. The password is 'dictionary'. wpa2-psk-linksys.cap: This is a sample file with a WPA2 handshake along with some encrypted packets. Useful for testing with airdecap-ng. The password is 'dictionary'. wps2.0.pcap: This is a test file with WPS 2.0 beacon. password.lst and password-2.lst: This is a sample wordlist for WPA key cracking. More wordlists can be found at https://www.aircrack-ng.org/doku.php?id=faq#where_can_i_find_good_wordlists password.db This is a sample airolib-ng database for WPA key cracking. pingreply.c Replies to all ping requests. Useful for testing sniffing/injecting packets with airtun-ng. Chinese-SSID-Name.pcap Contains a beacon with an SSID displayed in Chinese. verify_inject.py Testing DNS requests using airtun-ng. n-02.cap: This is a test file with 802.11X-2004 AES-128-CMAC handshake. Useful for testing with aircrack-ng. The password is 'bo$$password'. test-pmkid.pcap: This is a test file with PMKID. Passphrase for 'WLAN-771698' is 'SP-91862D361' test1.pcap: This is another test file with PMKID. Passphrase for the network 'ogogo' is '15211521' StayAlfred.hccapx: Hashcat HCCAPx file with WPA handshake. Passphrase for 'StayAlfred' ESSID is 'staytogether' wpa3-psk.pcap: WPA3 PSK SAE authentication. Passphrase for the network 'WPA3-Network' is 'abcdefgh' More sample pcap are available from Wireshark: https://wiki.wireshark.org/SampleCaptures#Wifi_.2F_Wireless_LAN_captures_.2F_802.11 aircrack-ng-1.6/README.md000066400000000000000000000366061361312141100150240ustar00rootroot00000000000000# Aircrack-ng [![Linux/Mac Build Status](https://travis-ci.org/aircrack-ng/aircrack-ng.svg?branch=master)](https://travis-ci.org/aircrack-ng/aircrack-ng) [![Windows Build Status](https://ci.appveyor.com/api/projects/status/github/aircrack-ng/aircrack-ng?branch=master&svg=true)](https://ci.appveyor.com/project/aircrack-ng/aircrack-ng) [![Intel Compiler Build Status](https://buildbot.aircrack-ng.org/badges/aircrack-ng.svg?left_text=Intel%20Compiler%20Build)](https://buildbot.aircrack-ng.org/) [![Alpine Linux Build Status](https://buildbot.aircrack-ng.org/badges/aircrack-ng-alpine.svg?left_text=Alpine%20Linux%20Build)](https://buildbot.aircrack-ng.org/) [![Kali Linux Build Status](https://buildbot.aircrack-ng.org/badges/aircrack-ng-kali.svg?left_text=Kali%20Linux%20Build)](https://buildbot.aircrack-ng.org/) [![Armel Kali Linux Build Status](https://buildbot.aircrack-ng.org/badges/aircrack-ng-armel.svg?left_text=Armel%20Kali%20Linux%20Build)](https://buildbot.aircrack-ng.org/) [![Armhf Kali Linux Build Status](https://buildbot.aircrack-ng.org/badges/aircrack-ng-armhf.svg?left_text=Armhf%20Kali%20Linux%20Build)](https://buildbot.aircrack-ng.org/) [![DragonFly BSD Build Status](https://buildbot.aircrack-ng.org/badges/aircrack-ng-dfly.svg?left_text=DragonFly%20Build)](https://buildbot.aircrack-ng.org/) [![FreeBSD 11 Build Status](https://buildbot.aircrack-ng.org/badges/aircrack-ng-fbsd-11.svg?left_text=FreeBSD%2011%20Build)](https://buildbot.aircrack-ng.org/) [![FreeBSD 12 Build Status](https://buildbot.aircrack-ng.org/badges/aircrack-ng-fbsd-12.svg?left_text=FreeBSD%2012%20Build)](https://buildbot.aircrack-ng.org/) [![OpenBSD 6 Build Status](https://buildbot.aircrack-ng.org/badges/aircrack-ng-obsd.svg?left_text=OpenBSD%20Build)](https://buildbot.aircrack-ng.org/) [![NetBSD 8.1 Build Status](https://buildbot.aircrack-ng.org/badges/aircrack-ng-netbsd81.svg?left_text=NetBSD%20Build)](https://buildbot.aircrack-ng.org/) [![Coverity Scan Build Status](https://scan.coverity.com/projects/aircrack-ng/badge.svg)](https://scan.coverity.com/projects/aircrack-ng) [![PackageCloud DEB](https://img.shields.io/badge/deb-packagecloud.io-844fec.svg)](https://packagecloud.io/aircrack-ng/git/install#bash-deb) [![PackageCloud RPM](https://img.shields.io/badge/rpm-packagecloud.io-844fec.svg)](https://packagecloud.io/aircrack-ng/git/install#bash-rpm) Aircrack-ng is a complete suite of tools to assess WiFi network security. It focuses on different areas of WiFi security: * Monitoring: Packet capture and export of data to text files for further processing by third party tools. * Attacking: Replay attacks, deauthentication, fake access points and others via packet injection. * Testing: Checking WiFi cards and driver capabilities (capture and injection). * Cracking: WEP and WPA PSK (WPA 1 and 2). All tools are command line which allows for heavy scripting. A lot of GUIs have taken advantage of this feature. It works primarily Linux but also Windows, OS X, FreeBSD, OpenBSD, NetBSD, as well as Solaris and even eComStation 2. # Building ## Requirements * Autoconf * Automake * Libtool * shtool * OpenSSL development package or libgcrypt development package. * Airmon-ng (Linux) requires ethtool. * On windows, cygwin has to be used and it also requires w32api package. * On Windows, if using clang, libiconv and libiconv-devel * Linux: LibNetlink 1 or 3. It can be disabled by passing --disable-libnl to configure. * pkg-config (pkgconf on FreeBSD) * FreeBSD, OpenBSD, NetBSD, Solaris and OS X with macports: gmake * Linux/Cygwin: make and Standard C++ Library development package (Debian: libstdc++-dev) ## Optional stuff * If you want SSID filtering with regular expression in airodump-ng (-essid-regex) pcre development package is required. * If you want to use airolib-ng and '-r' option in aircrack-ng, SQLite development package >= 3.3.17 (3.6.X version or better is recommended) * If you want to use Airpcap, the 'developer' directory from the CD/ISO/SDK is required. * In order to build `besside-ng`, `besside-ng-crawler`, `easside-ng`, `tkiptun-ng` and `wesside-ng`, libpcap development package is required (on Cygwin, use the Aircap SDK instead; see above) * For best performance on FreeBSD (50-70% more), install gcc5 (or better) via: pkg install gcc9 * rfkill * If you want Airodump-ng to log GPS coordinates, gpsd is needed * For best performance on SMP machines, ensure the hwloc library and headers are installed. It is strongly recommended on high core count systems, it may give a serious speed boost * CMocka for unit testing * For intergation testing on Linux only: tcpdump, HostAPd, WPA Supplicant and screen ## Installing required and optional dependencies Below are instructions for installing the basic requirements to build `aircrack-ng` for a number of operating systems. **Note**: CMocka, tcpdump, screen, HostAPd and WPA Supplicant should not be dependencies when packaging Aircrack-ng. ### Linux #### Debian/Ubuntu sudo apt-get install build-essential autoconf automake libtool pkg-config libnl-3-dev libnl-genl-3-dev libssl-dev ethtool shtool rfkill zlib1g-dev libpcap-dev libsqlite3-dev libpcre3-dev libhwloc-dev libcmocka-dev hostapd wpasupplicant tcpdump screen iw usbutils #### Fedora/CentOS/RHEL sudo yum install libtool pkgconfig sqlite-devel autoconf automake openssl-devel libpcap-devel pcre-devel rfkill libnl3-devel gcc gcc-c++ ethtool hwloc-devel libcmocka-devel git make file expect hostapd wpa_supplicant iw usbutils tcpdump screen **Note**: on CentOS and RedHat, HostAPd requires 'epel' repository to be enabled: sudo yum install epel-release #### openSUSE sudo zypper install autoconf automake libtool pkg-config libnl3-devel libopenssl-1_1-devel zlib-devel libpcap-devel sqlite3-devel pcre-devel hwloc-devel libcmocka-devel hostapd wpa_supplicant tcpdump screen iw gcc-c++ gcc #### Mageia sudo urpmi autoconf automake libtool pkgconfig libnl3-devel libopenssl-devel zlib-devel libpcap-devel sqlite3-devel pcre-devel hwloc-devel libcmocka-devel hostapd wpa_supplicant tcpdump screen iw gcc-c++ gcc make #### Alpine sudo apk add gcc g++ make autoconf automake libtool libnl3-dev openssl-dev ethtool libpcap-dev cmocka-dev hostapd wpa_supplicant tcpdump screen iw pkgconf util-linux sqlite-dev pcre-dev linux-headers zlib-dev ### BSD #### FreeBSD pkg install pkgconf shtool libtool gcc9 automake autoconf pcre sqlite3 openssl gmake hwloc cmocka #### DragonflyBSD pkg install pkgconf shtool libtool gcc8 automake autoconf pcre sqlite3 libgcrypt gmake cmocka #### OpenBSD pkg_add pkgconf shtool libtool gcc automake autoconf pcre sqlite3 openssl gmake cmocka ### OSX XCode, Xcode command line tools and HomeBrew are required. brew install autoconf automake libtool openssl shtool pkg-config hwloc pcre sqlite3 libpcap cmocka ### Windows #### Cygwin Cygwin requires the full path to the `setup.exe` utility, in order to automate the installation of the necessary packages. In addition, it requires the location of your installation, a path to the cached packages download location, and a mirror URL. An example of automatically installing all the dependencies is as follows: c:\cygwin\setup-x86.exe -qnNdO -R C:/cygwin -s http://cygwin.mirror.constant.com -l C:/cygwin/var/cache/setup -P autoconf -P automake -P bison -P gcc-core -P gcc-g++ -P mingw-runtime -P mingw-binutils -P mingw-gcc-core -P mingw-gcc-g++ -P mingw-pthreads -P mingw-w32api -P libtool -P make -P python -P gettext-devel -P gettext -P intltool -P libiconv -P pkg-config -P git -P wget -P curl -P libpcre-devel -P libssl-devel -P libsqlite3-devel #### MSYS2 pacman -Sy autoconf automake-wrapper libtool msys2-w32api-headers msys2-w32api-runtime gcc pkg-config git python openssl-devel openssl libopenssl msys2-runtime-devel gcc binutils make pcre-devel libsqlite-devel ## Compiling To build `aircrack-ng`, the Autotools build system is utilized. Autotools replaces the older method of compilation. **NOTE**: If utilizing a developer version, eg: one checked out from source control, you will need to run a pre-`configure` script. The script to use is one of the following: `autoreconf -i` or `env NOCONFIGURE=1 ./autogen.sh`. First, `./configure` the project for building with the appropriate options specified for your environment: ./configure **TIP**: If the above fails, please see above about developer source control versions. Next, compile the project (respecting if `make` or `gmake` is needed): * Compilation: `make` * Compilation on *BSD or Solaris: `gmake` Finally, the additional targets listed below may be of use in your environment: * Execute all unit testing: `make check` * Execute all integration testing (requires root): `make integration` * Installing: `make install` * Uninstall: `make uninstall` ### `./configure` flags When configuring, the following flags can be used and combined to adjust the suite to your choosing: * **with-airpcap=DIR**: needed for supporting airpcap devices on windows (cygwin or msys2 only) Replace DIR above with the absolute location to the root of the extracted source code from the Airpcap CD or downloaded SDK available online. Required on Windows to build `besside-ng`, `besside-ng-crawler`, `easside-ng`, `tkiptun-ng` and `wesside-ng` when building experimental tools. The developer pack (Compatible with version 4.1.1 and 4.1.3) can be downloaded at https://support.riverbed.com/content/support/software/steelcentral-npm/airpcap.html * **with-experimental**: needed to compile `tkiptun-ng`, `easside-ng`, `buddy-ng`, `buddy-ng-crawler`, `airventriloquist` and `wesside-ng`. libpcap development package is also required to compile most of the tools. If not present, not all experimental tools will be built. On Cygwin, libpcap is not present and the Airpcap SDK replaces it. See --with-airpcap option above. * **with-ext-scripts**: needed to build `airoscript-ng`, `versuck-ng`, `airgraph-ng` and `airdrop-ng`. Note: Each script has its own dependencies. * **with-gcrypt**: Use libgcrypt crypto library instead of the default OpenSSL. And also use internal fast sha1 implementation (borrowed from GIT) Dependency (Debian): libgcrypt20-dev * **with-duma**: Compile with DUMA support. DUMA is a library to detect buffer overruns and under-runs. Dependencies (debian): duma * **disable-libnl**: Set-up the project to be compiled without libnl (1 or 3). Linux option only. * **without-opt**: Do not enable stack protector (on GCC 4.9 and above). * **enable-shared**: Make OSdep a shared library. * **disable-shared**: When combined with **enable-static**, it will statically compile Aircrack-ng. * **with-avx512**: On x86, add support for AVX512 instructions in aircrack-ng. Only use it when the current CPU supports AVX512. * **with-static-simd=**: Compile a single optimization in aircrack-ng binary. Useful when compiling statically and/or for space-constrained devices. Valid SIMD options: x86-sse2, x86-avx, x86-avx2, x86-avx512, ppc-altivec, ppc-power8, arm-neon, arm-asimd. Must be used with --enable-static --disable-shared. When using those 2 options, the default is to compile the generic optimization in the binary. --with-static-simd merely allows to choose another one. #### Examples: * Configure and compiling: ``` ./configure --with-experimental make ``` * Compiling with gcrypt: ``` ./configure --with-gcrypt make ``` * Installing: `make install` * Installing (strip binaries): `make install-strip` * Installing, with external scripts: ``` ./configure --with-experimental --with-ext-scripts make make install ``` * Testing (with sqlite, experimental and pcre) ``` ./configure --with-experimental make make check ``` * Compiling on OS X with macports (and all options): ``` ./configure --with-experimental gmake ``` * Compiling on OS X 10.10 with XCode 7.1 and Homebrew: ``` env CC=gcc-4.9 CXX=g++-4.9 ./configure make make check ``` *NOTE*: Older XCode ships with a version of LLVM that does not support CPU feature detection; which causes the `./configure` to fail. To work around this older LLVM, it is required that a different compile suite is used, such as GCC or a newer LLVM from Homebrew. If you wish to use OpenSSL from Homebrew, you may need to specify the location to its' installation. To figure out where OpenSSL lives, run: `brew --prefix openssl` Use the output above as the DIR for `--with-openssl=DIR` in the `./configure` line: ``` env CC=gcc-4.9 CXX=g++-4.9 ./configure --with-openssl=DIR make make check ``` * Compiling on FreeBSD with gcc9 ``` env CC=gcc9 CXX=g++9 MAKE=gmake ./configure gmake ``` * Compiling on Cygwin with Airpcap (assuming Airpcap devpack is unpacked in Aircrack-ng directory) ``` cp -vfp Airpcap_Devpack/bin/x86/airpcap.dll src cp -vfp Airpcap_Devpack/bin/x86/airpcap.dll src/aircrack-osdep cp -vfp Airpcap_Devpack/bin/x86/airpcap.dll src/aircrack-crypto cp -vfp Airpcap_Devpack/bin/x86/airpcap.dll src/aircrack-util dlltool -D Airpcap_Devpack/bin/x86/airpcap.dll -d build/airpcap.dll.def -l Airpcap_Devpack/bin/x86/libairpcap.dll.a autoreconf -i ./configure --with-experimental --with-airpcap=$(pwd) make ``` * Compiling on DragonflyBSD with gcrypt using GCC 8 ``` autoreconf -i env CC=gcc8 CXX=g++8 MAKE=gmake ./configure --with-experimental --with-gcrypt gmake ``` * Compiling on OpenBSD (with autoconf 2.69 and automake 1.16) ``` export AUTOCONF_VERSION=2.69 export AUTOMAKE_VERSION=1.16 autoreconf -i env MAKE=gmake ./configure gmake ``` * Compiling and debugging aircrack-ng ``` export CFLAGS='-O0 -g' export CXXFLAGS='-O0 -g' ./configure make LD_LIBRARY_PATH=.libs gdb --args ./aircrack-ng [PARAMETERS] ``` # Packaging Automatic detection of CPU optimization is done at run time. This behavior **is** desirable when packaging Aircrack-ng (for a Linux or other distribution.) Also, in some cases it may be desired to provide your own flags completely and not having the suite auto-detect a number of optimizations. To do this, add the additional flag `--without-opt` to the `./configure` line: `./configure --without-opt` # Using precompiled binaries ## Linux/BSD * Use your package manager to download aircrack-ng * In most cases, they have an old version. ## Windows * Install the appropriate "monitor" driver for your card (standard drivers doesn't work for capturing data). * aircrack-ng suite is command line tools. So, you have to open a commandline `Start menu -> Run... -> cmd.exe` then use them * Run the executables without any parameters to have help # Documentation Documentation, tutorials, ... can be found on https://aircrack-ng.org See also manpages and the forum. For further information check the [README](README) file # Infrastructure sponsors MacStadium aircrack-ng-1.6/SECURITY.md000066400000000000000000000057321361312141100153320ustar00rootroot00000000000000# Security Policy Altough we do our best to prevent vulnerabilities, and have tools to help catch most of them, we are humans after all, and there will be inevitably issues slipping through the cracks. They can fall into two categories, either in any of the tools in the Aircrack-ng suite, or in our presence online (website, forum, emails, DNS, etc.). Depending which category they fall into, different information is needed. We do believe in coordinated disclosure, so in order to address them, and coordinate disclosure with you (and properly credit you for the discovery), report them to us. Do not open bug reports or pull requests. Our contact email for security issues is security@aircrack-ng.org If you are unsure how to proceed, need clarifications or have questions or remarks about this policy, feel free to email us to inquire. ## Aircrack-ng suite vulnerabilities ### Supported versions We only support the latest stable present on https://aircrack-ng.org For security issues present in our GitHub repository (master or any recently active branch), open a pull request or bug report. For any security issue affecting older versions of Aircrack-ng still present in currently supported Linux or BSD distributions, file a report with them, and email us a short description of the vulnerability along with a link to the bug report. ### Reporting There is no particular template to report the vulnerabilities. Keep in mind that a vulnerability is essentially a bug, so please provide us detailed information on how to reproduce it, such as: - Which Aircrack-ng tools are affected? And how? Any proof of concept to demonstrate it? - Operating systems involved, kernel versions (`uname -a` and `lsb_release -a` for example). - CPU architecture (`aircrack-ng -u` output is useful); a vulnerability on a x86 32 bit may not be exploitable on ARM 64 bit. A bug may also only be present when Aircrack-ng is compiled a certain way. - All the commands needed to trigger the issue. - Did you compile it yourself or did you get it from a package? - What equipment did you use? A packet capture may be useful; different equipment behaves differently, they have different Wi-Fi stacks, drivers, and firmwares. - A patch to fix the issue, if available. - If CVE numbers have been assigned, please provide them as well. ### Public disclosure Altough it is essentially a bug, do not submit a bug report or a pull request, but email us the data first, so we can coordinate fixing the issue and assist you in filing the bug reports, and if you provided a patch, the pull request; a patch may need to be broken down in multiple commits for clarity, for example. ## Online presence For any security issue affecting us specifically (any aircrack-ng.org subdomain) such as misconfiguration of our hosting, DNS, email, servers, or misconfiguration of the software we are using, email us with all the details regarding your findings. Anything else should be reported to the author or provider of the software, hardware, or hosting. aircrack-ng-1.6/VERSION.in000066400000000000000000000000311361312141100152010ustar00rootroot00000000000000@_MAJ@.@_MIN@.@_SUB_MIN@ aircrack-ng-1.6/apparmor/000077500000000000000000000000001361312141100153535ustar00rootroot00000000000000aircrack-ng-1.6/apparmor/usr.bin.aircrack-ng000066400000000000000000000006111361312141100210340ustar00rootroot00000000000000#include /usr/bin/aircrack-ng { #include #include # No need to access dot files deny @{HOME}/.** rw, # For reading pcap files (and sqldb) @{HOME}/** r, /tmp/** r, # For -l (and writing sqldb) owner @{HOME}/** w, owner /tmp/** w, # Needed for ptrace/core dumps /usr/bin/aircrack-ng rm, } aircrack-ng-1.6/apparmor/usr.bin.airdecap-ng000066400000000000000000000005731361312141100210340ustar00rootroot00000000000000#include /usr/bin/airdecap-ng { #include #include # No need to access dot files deny @{HOME}/.** rw, # For reading pcap files @{HOME}/** r, /tmp/** r, # For writing output files owner @{HOME}/** w, owner /tmp/** w, # Needed for ptrace/core dumps /usr/bin/airdecap-ng rm, } aircrack-ng-1.6/apparmor/usr.bin.airdecloak-ng000066400000000000000000000005771361312141100213660ustar00rootroot00000000000000#include /usr/bin/airdecloak-ng { #include #include # No need to access dot files deny @{HOME}/.** rw, # For reading pcap files @{HOME}/** r, /tmp/** r, # For writing output files owner @{HOME}/** w, owner /tmp/** w, # Needed for ptrace/core dumps /usr/bin/airdecloak-ng rm, } aircrack-ng-1.6/apparmor/usr.bin.airgraph-ng000066400000000000000000000006471361312141100210630ustar00rootroot00000000000000#include /usr/bin/airgraph-ng { #include #include # No need to access dot files deny @{HOME}/.** rw, # For reading input @{HOME}/** r, /tmp/** r, # For writing output owner @{HOME}/** w, owner /tmp/** w, # For executing 'fdp' /usr/{,local/,s}bin/fdp ix, # Needed for ptrace/core dumps /usr/bin/airgraph-ng rm, } aircrack-ng-1.6/apparmor/usr.bin.airolib-ng000066400000000000000000000006341361312141100207030ustar00rootroot00000000000000#include /usr/bin/airolib-ng { #include #include # No need to access dot files deny @{HOME}/.** rw, # For reading database files @{HOME}/** r, /tmp/** r, # For writing database files and exporting cowpatty files owner @{HOME}/** w, owner /tmp/** w, # Needed for ptrace/core dumps /usr/bin/airolib-ng rm, } aircrack-ng-1.6/apparmor/usr.bin.buddy-ng000066400000000000000000000003351361312141100203670ustar00rootroot00000000000000#include /usr/bin/buddy-ng { #include capability setgid, capability setuid, capability sys_chroot, network inet dgram, network inet stream, /usr/bin/buddy-ng mr, } aircrack-ng-1.6/apparmor/usr.bin.ivstools000066400000000000000000000003731361312141100205420ustar00rootroot00000000000000#include /usr/bin/ivstools { #include #include capability dac_override, deny @{HOME}/.** rw, @{HOME}/** r, owner @{HOME}/** w, /usr/bin/ivstools mr, } aircrack-ng-1.6/apparmor/usr.bin.kstats000066400000000000000000000002751361312141100201720ustar00rootroot00000000000000#include /usr/bin/kstats { #include #include deny @{HOME}/.** rw, @{HOME}/** r, /usr/bin/kstats mr, } aircrack-ng-1.6/apparmor/usr.bin.packetforge-ng000066400000000000000000000003501361312141100215470ustar00rootroot00000000000000#include /usr/bin/packetforge-ng { #include #include deny @{HOME}/.** rw, @{HOME}/** r, owner @{HOME}/** w, /usr/bin/packetforge-ng mr, } aircrack-ng-1.6/apparmor/usr.sbin.airbase-ng000066400000000000000000000014501361312141100210500ustar00rootroot00000000000000#include /usr/sbin/airbase-ng { #include #include #include capability net_admin, capability net_raw, capability setuid, network inet dgram, network packet raw, deny @{HOME}/.** rw, @{HOME}/** r, owner @{HOME}/** w, /bin/ r, /bin/*sh rCx, /bin/ls r, /dev/net/tun rw, /usr/sbin/airbase-ng mr, /proc/*/net/psched r, /tmp/ r, /sbin/ r, /sbin/iwpriv rCx, /usr/bin/ r, /usr/local/bin/ r, /usr/local/sbin/ r, /usr/sbin/ r, profile /bin/*sh { #include /bin/*sh mr, /bin/ls mrix, /sys/class/ieee80211/ r, } profile /sbin/iwpriv { #include network dgram, /sbin/iwpriv mr, } } aircrack-ng-1.6/apparmor/usr.sbin.aireplay-ng000066400000000000000000000011601361312141100212460ustar00rootroot00000000000000#include /usr/sbin/aireplay-ng { #include #include capability net_admin, capability net_raw, capability setuid, network packet raw, deny @{HOME}/.** rw, @{HOME}/** r, owner @{HOME}/** w, /bin/*sh rCx, /usr/sbin/aireplay-ng mr, /proc/*/net/psched r, /sbin/ r, /sbin/iwpriv rCx, profile /bin/*sh { #include /bin/*sh mr, /bin/ls rix, /sys/class/ieee80211/ r, } profile /sbin/iwpriv { #include network inet dgram, /sbin/iwpriv mr, } } aircrack-ng-1.6/apparmor/usr.sbin.airmon-ng000066400000000000000000000057651361312141100207440ustar00rootroot00000000000000#include /usr/sbin/airmon-ng { #include #include #include /usr/sbin/airmon-ng rix, /bin/cat rix, /bin/dmesg rCx, profile /bin/dmesg { #include /bin/dmesg mr, } /bin/*sh ix, /bin/grep rix, /bin/ip rCx, profile /bin/ip { #include /bin/ip mr, capability net_admin, } /bin/kmod rCx, profile /bin/kmod { #include /bin/kmod mr, /proc/cmdline r, } /bin/ps rCx, profile /bin/ps { #include /bin/ps mr, capability sys_ptrace, capability dac_override, ptrace (trace), ptrace (read), /proc/ r, /proc/*/ r, /proc/*/maps r, /proc/*/net/dev r, /proc/*/stat r, /proc/*/status r, /proc/*/task/ r, /proc/sys/kernel/pid_max r, /proc/tty/drivers r, /proc/uptime r, } /bin/readlink rix, /bin/sed rix, /bin/sleep rix, /bin/uname rix, /dev/bus/usb/ r, /dev/rfkill rix, /dev/tty* r, /dev/vmnet r, /etc/udev/udev.conf r, /proc/*/net/dev r, /proc/*/net/psched r, /proc/bus/pci/ r, /proc/ide/hd*/model r, /proc/filesystems r, /proc/meminfo r, /proc/scsi/scsi/ r, /proc/sys/dev/*/fftxqmin r, /sbin/ethtool rCx, profile /sbin/ethtool { #include /sbin/ethtool mr, capability net_admin, capability net_raw, network, } /sbin/ifconfig rCx, profile /sbin/ifconfig { #include /sbin/ifconfig mr, } /sbin/iw rCx, profile /sbin/iw { #include /sbin/iw mr, capability net_admin, /proc/net/psched r, /sys/class/ieee80211/ r, /sys/class/ieee80211/** r, /sys/devices/** r, /proc/*/net/psched r, } /sbin/iwconfig rCx, profile /sbin/iwconfig { #include /sbin/iwconfig mr, capability net_admin, capability net_raw, network inet dgram, /proc/filesystems r, /proc/*/net/dev r, } /sbin/modinfo rCx, profile /sbin/modinfo { #include /sbin/modinfo mr, /proc/cmdline r, } /sbin/modprobe rCx, profile /sbin/modprobe { #include /sbin/modprobe mr, } /sys/bus/ r, /sys/bus/pci r, /sys/bus/pci_express r, /sys/bus/usb/devices/ r, /sys/class/ r, /sys/class/ieee80211/ r, /sys/class/ieee80211/** r, /sys/class/net/ r, /sys/class/net/** r, /sys/devices/** r, /sys/module/ r, /usr/bin/basename rix, /usr/bin/cut rix, /usr/bin/*awk rix, /usr/bin/head rix, /usr/bin/id rix, /usr/bin/lspci rix, /usr/bin/lscpu rix, /usr/bin/lsusb rix, /usr/bin/sort rix, /usr/sbin/dmidecode rCx, profile /usr/sbin/dmidecode { #include /usr/sbin/dmidecode mr, } /usr/sbin/rfkill rix, /var/lib/usbutils/usb.ids r, } aircrack-ng-1.6/apparmor/usr.sbin.airodump-ng000066400000000000000000000015601361312141100212640ustar00rootroot00000000000000#include /usr/sbin/airodump-ng { #include #include /usr/sbin/airodump-ng mr, capability dac_override, capability setuid, capability net_raw, capability net_admin, capability sys_module, network packet raw, deny @{HOME}/.** rw, @{HOME}/** r, owner @{HOME}/**.cap w, owner @{HOME}/**.csv w, owner @{HOME}/**.kismet.netxml w, owner @{HOME}/**.gps w, /proc/*/net/psched r, /proc/acpi/ac_adapter/ r, /proc/acpi/battery/ r, /usr/share/aircrack-ng/airodump-ng-oui.txt r, /sbin/ r, /sbin/iwpriv rCx, profile /sbin/iwpriv { #include network dgram, /sbin/iwpriv mr, } /bin/*sh rCx, profile /bin/*sh { #include /bin/*sh mr, /bin/ls mrix, /sys/class/ieee80211/ r, } } aircrack-ng-1.6/apparmor/usr.sbin.airserv-ng000066400000000000000000000012331361312141100211140ustar00rootroot00000000000000#include /usr/sbin/airserv-ng { #include capability net_admin, capability net_bind_service, capability net_raw, network inet stream, network packet raw, /usr/sbin/airserv-ng mr, /bin/ r, /bin/*sh Cx, /proc/*/net/psched r, /tmp/ r, /sbin/ r, /sbin/iwpriv Cx, /usr/bin/ r, /usr/local/bin/ r, /usr/local/sbin/ r, /usr/sbin/ r, profile /bin/*sh { #include /bin/*sh mr, /bin/ls r, /proc/filesystems r, /sys/class/ieee80211/ r, } profile /sbin/iwpriv { #include network inet dgram, /sbin/iwpriv mr, } } aircrack-ng-1.6/apparmor/usr.sbin.airtun-ng000066400000000000000000000013671361312141100207530ustar00rootroot00000000000000#include /usr/sbin/airtun-ng { #include #include capability net_admin, capability net_raw, capability setuid, network inet dgram, network packet raw, deny @{HOME}/.** rw, @{HOME}/** r, /bin/ r, /bin/*sh Cx, /dev/net/tun rw, /proc/*/net/psched r, /sbin/ r, /sbin/iwpriv Cx, /tmp/ r, /usr/bin/ r, /usr/local/bin/ r, /usr/local/sbin/ r, /usr/sbin/ r, /usr/sbin/airtun-ng mr, profile /bin/*sh { #include /bin/*sh mr, /bin/ls rix, /proc/filesystems r, /sys/class/ieee80211/ r, } profile /sbin/iwpriv { #include network dgram, /sbin/iwpriv mr, } } aircrack-ng-1.6/apparmor/usr.sbin.easside-ng000066400000000000000000000012751361312141100210640ustar00rootroot00000000000000#include /usr/sbin/easside-ng { #include capability net_admin, capability net_raw, network inet dgram, network packet raw, deny @{HOME}/.** rw, @{HOME}/**/prga.log w, /bin/ r, /bin/*sh Cx, /dev/net/tun rw, /usr/sbin/easside-ng mr, /proc/*/net/psched r, /sbin/ r, /sbin/iwpriv Cx, /tmp/ r, /usr/bin/ r, /usr/local/bin/ r, /usr/local/sbin/ r, /usr/sbin/ r, profile /bin/*sh { #include /bin/*sh mr, /bin/ls r, /proc/filesystems r, /sys/class/ieee80211/ r, } profile /sbin/iwpriv { #include network inet dgram, /sbin/iwpriv mr, } } aircrack-ng-1.6/apparmor/usr.sbin.tkiptun-ng000066400000000000000000000014401361312141100211370ustar00rootroot00000000000000#include /usr/sbin/tkiptun-ng { #include #include capability net_admin, capability net_raw, capability setuid, capability sys_module, network packet raw, deny @{HOME}/.** rw, @{HOME}/** r, /bin/ r, /bin/*sh Cx, /usr/sbin/tkiptun-ng mr, /proc/*/net/psched r, /sbin/ r, /sbin/iwpriv Cx, /tmp/ r, /usr/bin/ r, /usr/local/bin/ r, /usr/local/sbin/ r, /usr/sbin/ r, profile /bin/*sh { #include /bin/*sh mr, /bin/ls rix, /proc/filesystems r, /sys/class/ieee80211/ r, } profile /sbin/iwpriv { #include capability net_admin, capability sys_module, network inet dgram, /sbin/iwpriv mr, } } aircrack-ng-1.6/apparmor/usr.sbin.wesside-ng000066400000000000000000000013431361312141100211060ustar00rootroot00000000000000#include /usr/sbin/wesside-ng { #include #include capability dac_override, capability net_admin, capability net_raw, network packet raw, /bin/ r, /bin/*sh Cx, deny @{HOME}/.** rw, owner @{HOME}/**/wep.cap rw, /usr/sbin/wesside-ng mr, /proc/*/net/psched r, /sbin/ r, /sbin/iwpriv Cx, /tmp/ r, /usr/bin/ r, /usr/local/bin/ r, /usr/local/sbin/ r, /usr/sbin/ r, profile /bin/*sh { #include /bin/*sh mr, /bin/ls rix, /proc/filesystems r, /sys/class/ieee80211/ r, } profile /sbin/iwpriv { #include network inet dgram, /sbin/iwpriv mr, } } aircrack-ng-1.6/appveyor.yml000066400000000000000000000176131361312141100161320ustar00rootroot00000000000000version: 1.0.{build} pull_requests: do_not_increment_build_number: true # Do not build feature branch with open Pull Requests skip_branch_with_pr: true image: Visual Studio 2017 configuration: Release platform: x64 clone_depth: 500 environment: global: # APPVEYOR_SAVE_CACHE_ON_ERROR: true AIRCRACK_CI_CACHE: C:\aircrack_ci_cache CYG_CACHE: '%AIRCRACK_CI_CACHE%\cygwin' MSYS2_CACHE: '%AIRCRACK_CI_CACHE%\msys2' CHERE_INVOKING: 1 MSYSTEM: MSYS matrix: - TARGET: cygwin COMPILER: gcc - TARGET: cygwin64 COMPILER: gcc - TARGET: cygwin COMPILER: clang - TARGET: cygwin64 COMPILER: clang - TARGET: msys64 - TARGET: pkg matrix: fast_finish: true allow_failures: - TARGET: cygwin COMPILER: clang - TARGET: cygwin64 COMPILER: clang # cache: # - '%AIRCRACK_CI_CACHE%' # Uncomment to enable debugging on AppVeyor equipment # init: - git config --global core.autocrlf input - git config --global core.eol lf #- ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) install: - ps: | function Exec-External { param( [Parameter(Position=0,Mandatory=1)][scriptblock] $command ) & $command 2>&1 | %{ "$_" } if ($LASTEXITCODE -ne 0) { throw ("Command returned non-zero error-code ${LASTEXITCODE}: $command") } } - ps: | function downloadIfOlderThanDays($url, $path, $days) { if ( !(Test-Path $path -NewerThan (Get-Date).AddDays(-$days)) ) { Write-Host "$path does not exist or is older than $days days, downloading from $url" Invoke-WebRequest $url -OutFile $path } } - ps: | function updateCygwin($cygwinexe, $installFolder, $cacheFolder) { Write-Host "Update Cygwin: $cygwinexe" Exec-External {& cmd /c $cygwinexe -gqnNdO -R $installFolder -s http://mirrors.kernel.org/sourceware/cygwin/ -l $cacheFolder -P autoconf -P automake -P bison -P clang -P gcc-core -P gcc-g++ -P mingw-runtime -P mingw-binutils -P mingw-gcc-core -P mingw-gcc-g++ -P mingw-pthreads -P mingw-w32api -P libtool -P make -P python -P gettext-devel -P gettext -P intltool -P libiconv -P libiconv-devel -P pkg-config -P git -P wget -P curl -P libcurl4 -P libpcre-devel -P libssl-devel -P libsqlite3-devel -P zlib-devel -P cmocka -P unzip -P zip -P rsync -P expect -P libhwloc-devel} Write-Host "Update Cygwin: $cygwinexe " -NoNewLine Write-Host "[ OK ]" -ForegroundColor Green } - ps: | if ($env:TARGET -eq "cygwin" -or $env:TARGET -eq "pkg") { New-Item -Force -Type Directory $env:CYG_CACHE downloadIfOlderThanDays "https://cygwin.com/setup-x86.exe" "${env:AIRCRACK_CI_CACHE}\setup-x86.exe" 7 updateCygwin "${env:AIRCRACK_CI_CACHE}\setup-x86.exe" C:/cygwin $env:CYG_CACHE } - ps: | if ($env:TARGET -eq "cygwin64" -or $env:TARGET -eq "pkg") { New-Item -Force -Type Directory $env:CYG_CACHE downloadIfOlderThanDays "https://cygwin.com/setup-x86_64.exe" "${env:AIRCRACK_CI_CACHE}\setup-x86_64.exe" 7 updateCygwin "${env:AIRCRACK_CI_CACHE}\setup-x86_64.exe" C:/cygwin64 $env:CYG_CACHE } - ps: | if ($env:TARGET -eq "msys64") { function bash($bash_command) { Write-Host "MSYS2-Bash: $bash_command" Exec-External {& C:\msys64\usr\bin\bash.exe --login -e -c $bash_command } Write-Host "MSYS2-Bash $bash_command " -NoNewLine Write-Host "[ OK ]" -ForegroundColor Green } New-Item -Force -Type Directory $env:MSYS2_CACHE $unix_msys2_cache = (Exec-External {& C:\msys64\usr\bin\bash.exe --login -e -c "cygpath '${env:MSYS2_CACHE}'"}) # install latest pacman bash "pacman -Sy --noconfirm --cache `"$unix_msys2_cache`" pacman pacman-mirrors" # update core packages bash "pacman -Syu --noconfirm --cache `"$unix_msys2_cache`"" # install Aircrack-ng build dependencies bash "pacman --sync --noconfirm --cache `"$unix_msys2_cache`" autoconf automake1.15 libtool msys2-w32api-headers msys2-w32api-runtime pkg-config git python openssl-devel openssl libopenssl msys2-runtime-devel binutils make pcre-devel libsqlite-devel zlib-devel" } build_script: - cmd: | C:\cygwin\bin\bash -e -l -c "curl -RLO https://dl.aircrack-ng.org/AirPcap_Devpack_4_1_1_1838.zip" - ps: | $hashFromFile = Get-FileHash -Path "AirPcap_Devpack_4_1_1_1838.zip" -Algorithm SHA256 if ($hashFromFile.Hash -ne "86dcde46603cd1229245263499ef9cb4e43ee66cd7219605d30095562888da14") { Write-Host "AirPcap failed digest check." -ForegroundColor Red $hashFromFile | Format-List Break } - cmd: | C:\cygwin\bin\bash -e -l -c "7z -y x AirPcap_Devpack_4_1_1_1838.zip" - ps: | if ($env:TARGET -eq "cygwin") { Exec-External {& C:\cygwin\bin\bash -e -l -c "cp -vfp Airpcap_Devpack/bin/x86/airpcap.dll /cygdrive/c/Windows/System32"} Exec-External {& C:\cygwin\bin\bash -e -l -c "dlltool -D Airpcap_Devpack/bin/x86/airpcap.dll -d build/airpcap.dll.def -l Airpcap_Devpack/bin/x86/libairpcap.dll.a"} if ($env:COMPILER -eq "gcc") { Exec-External {& C:\cygwin\bin\bash -e -l -c "./build/cygwin.sh gcc --with-experimental --with-airpcap=/cygdrive/c/projects/aircrack-ng"} Exec-External {& C:\cygwin\bin\bash -e -l -c "./build/cygwin.sh gcc --with-experimental"} } else { Exec-External {& C:\cygwin\bin\bash -e -l -c "./build/cygwin.sh clang --with-experimental --with-airpcap=/cygdrive/c/projects/aircrack-ng"} } } - ps: | if ($env:TARGET -eq "cygwin64") { Exec-External {& C:\cygwin64\bin\bash -e -l -c "cp -vfp Airpcap_Devpack/bin/x64/airpcap.dll /cygdrive/c/Windows/System"} Exec-External {& C:\cygwin64\bin\bash -e -l -c "dlltool -D Airpcap_Devpack/bin/x64/airpcap.dll -d build/airpcap.dll.def -l Airpcap_Devpack/bin/x64/libairpcap.dll.a"} if ($env:COMPILER -eq "gcc") { Exec-External {& C:\cygwin64\bin\bash -e -l -c "./build/cygwin.sh gcc --with-experimental --with-airpcap=/cygdrive/c/projects/aircrack-ng"} Exec-External {& C:\cygwin64\bin\bash -e -l -c "./build/cygwin.sh gcc --with-experimental"} } else { Exec-External {& C:\cygwin64\bin\bash -e -l -c "./build/cygwin.sh clang --with-experimental --with-airpcap=/cygdrive/c/projects/aircrack-ng"} } } - ps: | if ($env:TARGET -eq "msys64") { Exec-External {& C:\msys64\usr\bin\bash -e -l -c "cp -vfp Airpcap_Devpack/bin/x64/airpcap.dll /c/Windows/System"} Exec-External {& C:\msys64\usr\bin\bash -e -l -c "dlltool -D Airpcap_Devpack/bin/x64/airpcap.dll -d build/airpcap.dll.def -l Airpcap_Devpack/bin/x64/libairpcap.dll.a"} Exec-External {& C:\msys64\usr\bin\bash -e -l -c "./build/cygwin.sh gcc --with-experimental --with-airpcap=/c/projects/aircrack-ng"} Exec-External {& C:\msys64\usr\bin\bash -e -l -c "./build/cygwin.sh gcc --with-experimental"} } - ps: | if ($env:TARGET -eq "pkg") { Exec-External {& C:\msys64\usr\bin\bash -e -l -c "cp -vfp Airpcap_Devpack/bin/x64/airpcap.dll /c/Windows/System"} Exec-External {& C:\msys64\usr\bin\bash -e -l -c "cp -vfp Airpcap_Devpack/bin/x86/airpcap.dll /c/Windows/System32"} Exec-External {& C:\msys64\usr\bin\bash -e -l -c "dlltool -D Airpcap_Devpack/bin/x64/airpcap.dll -d build/airpcap.dll.def -l Airpcap_Devpack/bin/x64/libairpcap.dll.a"} Exec-External {& C:\cygwin\bin\bash -e -l -c "dlltool -D Airpcap_Devpack/bin/x86/airpcap.dll -d build/airpcap.dll.def -l Airpcap_Devpack/bin/x86/libairpcap.dll.a"} .\build\package-win32.ps1 2>&1 | %{ "$_" } } artifacts: - path: 'aircrack-ng-*.zip' deploy: - provider: FTP host: secure.thrallingpenguin.com protocol: ftps username: appveyor password: secure: TMwjjDnIFGZclF9TbbgBprDa1kRweHrh6Gw4vnDW/QegdmR4CT/LUiDf9L+OdNVZ folder: artifacts/aircrack-ng/development/$(APPVEYOR_REPO_COMMIT)/win artifact: /aircrack-ng-.*\.zip/ beta: true debug: true on: branch: master aircrack-ng-1.6/autogen.sh000077500000000000000000000063171361312141100155420ustar00rootroot00000000000000#!/bin/sh # # Aircrack-ng # # Copyright (C) 2017 Joseph Benden # # Autotool support was written by: Joseph Benden # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA # # In addition, as a special exception, the copyright holders give # permission to link the code of portions of this program with the # OpenSSL library under certain conditions as described in each # individual source file, and distribute linked combinations # including the two. # # You must obey the GNU General Public License in all respects # for all of the code used other than OpenSSL. # # If you modify file(s) with this exception, you may extend this # exception to your dnl version of the file(s), but you are not obligated # to do so. # # If you dnl do not wish to do so, delete this exception statement from your # version. # # If you delete this exception statement from all source files in the # program, then also delete it here. set -euf test -n "${srcdir:-}" || srcdir="$(dirname "$0")" test -n "${srcdir:-}" || srcdir=. olddir="$(pwd)" cd "$srcdir" missing_tool() { _prog="$1" _env="$2" echo "Could not auto-detect '${_prog}'; please install or specify the '${_env}' environment variable." exit 1 } if [ -z "${LIBTOOLIZE:-}" ]; then if which libtoolize >/dev/null 2>/dev/null; then LIBTOOLIZE="$(which libtoolize 2>/dev/null)" elif which glibtoolize >/dev/null 2>/dev/null; then LIBTOOLIZE="$(which glibtoolize 2>/dev/null)" else missing_tool libtoolize LIBTOOLIZE fi fi if [ -z "${ACLOCAL:-}" ]; then if which aclocal >/dev/null 2>/dev/null; then ACLOCAL="$(which aclocal 2>/dev/null)" else missing_tool aclocal ACLOCAL fi fi if [ -z "${AUTOCONF:-}" ]; then if which autoconf >/dev/null 2>/dev/null; then AUTOCONF="$(which autoconf 2>/dev/null)" else missing_tool autoconf AUTOCONF fi fi if [ -z "${AUTOHEADER:-}" ]; then if which autoheader >/dev/null 2>/dev/null; then AUTOHEADER="$(which autoheader 2>/dev/null)" else missing_tool autoheader AUTOHEADER fi fi if [ -z "${AUTOMAKE:-}" ]; then if which automake >/dev/null 2>/dev/null; then AUTOMAKE="$(which automake 2>/dev/null)" else missing_tool automake AUTOMAKE fi fi "$LIBTOOLIZE" --force --copy --automake "$ACLOCAL" -I build/m4/stubs -I build/m4 ${ACLOCAL_FLAGS:-} "$AUTOCONF" "$AUTOHEADER" "$AUTOMAKE" \ --gnu --add-missing --force --copy \ -Wno-portability -Wno-portability { cat < reautogen.sh chmod +x reautogen.sh if [ ! -z "${NOCONFIGURE:-}" ]; then echo "Done. ./configure skipped." exit $? fi exec ./configure "$@" aircrack-ng-1.6/build/000077500000000000000000000000001361312141100146315ustar00rootroot00000000000000aircrack-ng-1.6/build/airpcap.dll.def000077500000000000000000000023601361312141100175060ustar00rootroot00000000000000LIBRARY airpcap.dll EXPORTS AirpcapClose AirpcapConvertChannelToFrequency AirpcapConvertFrequencyToChannel AirpcapFreeDeviceList AirpcapGetDecryptionState AirpcapGetDeviceCapabilities AirpcapGetDeviceChannel AirpcapGetDeviceChannelEx AirpcapGetDeviceChannelLock AirpcapGetDeviceKeys AirpcapGetDeviceList AirpcapGetDeviceMacFlags AirpcapGetDeviceSupportedChannels AirpcapGetDeviceTimestamp AirpcapGetDeviceTransmissionLock AirpcapGetDriverDecryptionState AirpcapGetDriverKeys AirpcapGetFcsPresence AirpcapGetFcsValidation AirpcapGetKernelBufferSize AirpcapGetLastError AirpcapGetLedsNumber AirpcapGetLinkType AirpcapGetMacAddress AirpcapGetReadEvent AirpcapGetStats AirpcapGetTxPower AirpcapGetVersion AirpcapOpen AirpcapRead AirpcapSetDecryptionState AirpcapSetDeviceChannel AirpcapSetDeviceChannelEx AirpcapSetDeviceChannelLock AirpcapSetDeviceKeys AirpcapSetDeviceMacFlags AirpcapSetDeviceTransmissionLock AirpcapSetDriverDecryptionState AirpcapSetDriverKeys AirpcapSetFcsPresence AirpcapSetFcsValidation AirpcapSetFilter AirpcapSetKernelBuffer AirpcapSetLinkType AirpcapSetMacAddress AirpcapSetMinToCopy AirpcapSetTxPower AirpcapStoreCurConfigAsAdapterDefault AirpcapTurnLedOff AirpcapTurnLedOn AirpcapWrite aircrack-ng-1.6/build/benchmark000077500000000000000000000013231361312141100165100ustar00rootroot00000000000000#!/usr/bin/env bash set -euf TESTS=$(./src/aircrack-ng --simd-list) BENCHMARKS=benchmark.csv TOP=$(dirname "$0")/.. REV=$(cd "$TOP" && "./evalrev") touch "$BENCHMARKS" echo "revision,processor,simd,nbcpus,kps" | tee -a "$BENCHMARKS" for T in $TESTS; do NCPU=$(nproc) while [ $NCPU -ge 1 ]; do LOOPS=1 while [ $LOOPS -le 5 ]; do RESULT=$(./src/aircrack-ng --simd=$T -p $NCPU -S | tr '\r' '\n' | awk -v max=0 '{if($1>max){max=$1}}END{print max}') echo "$REV,$(uname -m),$T,$NCPU,$RESULT" | tee -a "$BENCHMARKS" LOOPS=$(($LOOPS + 1)) done [ ${NCPU} -eq 1 ] && break [ $(( $NCPU & 1 )) ] && NCPU=$((NCPU + 1)) NCPU=$((NCPU/2)) done done aircrack-ng-1.6/build/clang_format_all.sh000077500000000000000000000044751361312141100204660ustar00rootroot00000000000000#!/bin/sh # # Adapted from: # https://github.com/baldurk/renderdoc/raw/v1.x/util/clang_format_all.sh # CLANG_MAJOR=3 CLANG_MINOR=8 CLANG_FORMAT_VERSION=$CLANG_MAJOR.$CLANG_MINOR # Locate the clang-format executable. We try: # - the existing value of $CLANG_FORMAT # - the first command line argument to the script # - in order: # clang-format-Maj.Min # clang-format-Maj # clang-format # define a function to check the current $CLANG_FORMAT valid_clang_format() { if which $CLANG_FORMAT > /dev/null 2>&1; then if $CLANG_FORMAT --version | grep -q $CLANG_FORMAT_VERSION; then echo "Located $CLANG_FORMAT"; return 0; fi fi return 1; } if test ! -e configure.ac; then echo "Must be at the root of the entire project." exit 1; fi; if ! valid_clang_format; then # if not valid yet, first try the command line parameter CLANG_FORMAT=$1 fi; if ! valid_clang_format; then # Next try the full version CLANG_FORMAT=clang-format-$CLANG_MAJOR.$CLANG_MINOR fi; if ! valid_clang_format; then # Then -maj just in case CLANG_FORMAT=clang-format-$CLANG_MAJOR fi; if ! valid_clang_format; then # Then finally with no version suffix CLANG_FORMAT=clang-format fi; # Check if we have a valid $CLANG_FORMAT if ! valid_clang_format; then # If we didn't find one, bail out echo "Couldn't find correct clang-format version, was looking for $CLANG_FORMAT_VERSION" echo "Aircrack-ng requires a very specific clang-format version to ensure there isn't" echo "any variance between versions that can happen. You can install it as" echo "'clang-format-$CLANG_FORMAT_VERSION' so that it doesn't interfere with any other" echo "versions you might have installed, and this script will find it there" exit 1; fi; # Format all source code find src -iname '*.h' -a \( ! -path "include/aircrack-ng/third-party/*" -a ! -path "lib/radiotap/*" \) | \ xargs -n1 $CLANG_FORMAT -i -style=file find src -iname '*.cpp' -a \( ! -path "include/aircrack-ng/third-party/*" -a ! -path "lib/radiotap/*" \) | \ xargs -n1 $CLANG_FORMAT -i -style=file find src -iname '*.c' -a \( ! -path "include/aircrack-ng/third-party/*" -a ! -path "lib/radiotap/*" \) | \ xargs -n1 $CLANG_FORMAT -i -style=file $CLANG_FORMAT -i -style=file include/aircrack-ng/third-party/eapol.h $CLANG_FORMAT -i -style=file include/aircrack-ng/third-party/hashcat.h aircrack-ng-1.6/build/cygwin.sh000077500000000000000000000014511361312141100164710ustar00rootroot00000000000000#!/usr/bin/env bash set -euf COMPILER=gcc if [ $# -gt 0 ] then COMPILER="${1}" shift fi echo "I: ${COMPILER} compiler" if [ "x${COMPILER}" = xclang ] then CC=clang-5.0 CXX=clang++-5.0 LIBS='-liconv' export CC CXX LIBS fi CPUS=$((`grep processor /proc/cpuinfo | wc -l` * 3 / 2)) CFLAGS="-O2 -DNDEBUG" CXXFLAGS="-O2 -DNDEBUG" export CFLAGS CXXFLAGS RETRY=0 while [ $RETRY -lt 3 ]; do # ./autogen.sh "$@" && break autoreconf -vi && ./configure "$@" && break [ -f config.log ] && cat config.log echo "W: failed to run autogen.sh, will retry..." RETRY=$(($RETRY + 1)) sleep $((10 * $RETRY)) done if [ $RETRY -ge 3 ]; then echo "F: All retries failed, aborting..." exit 1 fi make -j ${CPUS:-1} make check || { find . -name 'test-suite.log' -exec cat {} ';' && exit 1; } make clean exit 0 aircrack-ng-1.6/build/dist_check.sh000077500000000000000000000014651361312141100172760ustar00rootroot00000000000000#!/usr/bin/env bash set -eufx # # Bail on OS X for testing this functionality. # if [ "$TRAVIS_OS_NAME" == "osx" ]; then exit 0 fi find . -name .deps -o -name '*.la' -o -name .libs -o -name Makefile -print0 | xargs -0 rm -vfr if [ "$TRAVIS_OS_NAME" == "osx" ]; then ./autogen.sh --with-experimental --with-ext-scripts else ./autogen.sh fi make make dist BN=$(find . -name '*.tar.gz' | tail -n1 | sed -e 's/\.tar\.gz//g;s/^\.\///g') [ -d dist_build ] && rm -fr dist_build mkdir dist_build cd dist_build tar xzf ../$BN.tar.gz cd "$BN" if [ "$TRAVIS_OS_NAME" == "osx" ]; then ./configure --with-experimental --with-ext-scripts; else ./configure --with-experimental --with-ext-scripts; fi make make check || { find . -name 'test-suite.log' -exec cat {} ';' && exit 1; } make DESTDIR=/tmp/ac install exit 0 aircrack-ng-1.6/build/gcrypt.sh000077500000000000000000000005771361312141100165110ustar00rootroot00000000000000#!/usr/bin/env bash set -e EXTRA= case "${CC:=}" in clang*|llvm*) export CXX=clang++;; *) export CFLAGS="-Werror -Wno-unused-result"; export CXXFLAGS="-Werror -Wno-unused-result";; esac ./autogen.sh --with-experimental --with-gcrypt ${EXTRA} || { cat config.log; exit 1; } make make check || { find . -name 'test-suite.log' -exec cat {} ';' && exit 1; } make clean exit 0 aircrack-ng-1.6/build/m4/000077500000000000000000000000001361312141100151515ustar00rootroot00000000000000aircrack-ng-1.6/build/m4/aircrack_ng_airpcap.m4000066400000000000000000000055061361312141100213630ustar00rootroot00000000000000dnl Aircrack-ng dnl dnl Copyright (C) 2017 Joseph Benden dnl dnl Autotool support was written by: Joseph Benden dnl dnl This program is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by dnl the Free Software Foundation; either version 2 of the License, or dnl (at your option) any later version. dnl dnl This program is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the dnl GNU General Public License for more details. dnl dnl You should have received a copy of the GNU General Public License dnl along with this program; if not, write to the Free Software dnl Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA dnl dnl In addition, as a special exception, the copyright holders give dnl permission to link the code of portions of this program with the dnl OpenSSL library under certain conditions as described in each dnl individual source file, and distribute linked combinations dnl including the two. dnl dnl You must obey the GNU General Public License in all respects dnl for all of the code used other than OpenSSL. dnl dnl If you modify file(s) with this exception, you may extend this dnl exception to your dnl version of the file(s), but you are not obligated dnl to do so. dnl dnl If you dnl do not wish to do so, delete this exception statement from your dnl version. dnl dnl If you delete this exception statement from all source files in the dnl program, then also delete it here. AC_DEFUN([AIRCRACK_NG_AIRPCAP], [ AC_ARG_WITH(airpcap, [AS_HELP_STRING([--with-airpcap=DIR], [use given DIR for the Airpcap library])]) case $with_airpcap in no | "") AIRPCAP=no ;; *) AC_MSG_CHECKING([for 32-bit environment]) case "$(uname -m)" in x86_64* | amd64*) AC_MSG_RESULT([no]) AIRPCAP_LIB="bin/x64" ;; *) AC_MSG_RESULT([yes]) AIRPCAP_LIB="bin/x86" ;; esac AC_MSG_CHECKING([for airpcap.h]) if test -r "$with_airpcap/Airpcap_Devpack/include/airpcap.h" ; then AIRPCAP_CFLAGS="-I$with_airpcap/Airpcap_Devpack/include" AIRPCAP_LIBS="-L$with_airpcap/Airpcap_Devpack/${AIRPCAP_LIB} -lairpcap" AC_SUBST(AIRPCAP_CFLAGS) AC_SUBST(AIRPCAP_LIBS) AC_DEFINE([HAVE_AIRPCAP], [1], [Define if you have AirPcap.]) AC_MSG_RESULT([yes]) AIRPCAP=yes else AC_MSG_ERROR([airpcap.h could not be found in $with_airpcap/Airpcap_Devpack/include]) AIRPCAP=no fi ;; esac AM_CONDITIONAL([AIRPCAP], [test "$AIRPCAP" = yes]) ]) aircrack-ng-1.6/build/m4/aircrack_ng_asan.m4000066400000000000000000000043041361312141100206610ustar00rootroot00000000000000dnl Aircrack-ng dnl dnl Copyright (C) 2017 Joseph Benden dnl dnl Autotool support was written by: Joseph Benden dnl dnl This program is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by dnl the Free Software Foundation; either version 2 of the License, or dnl (at your option) any later version. dnl dnl This program is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the dnl GNU General Public License for more details. dnl dnl You should have received a copy of the GNU General Public License dnl along with this program; if not, write to the Free Software dnl Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA dnl dnl In addition, as a special exception, the copyright holders give dnl permission to link the code of portions of this program with the dnl OpenSSL library under certain conditions as described in each dnl individual source file, and distribute linked combinations dnl including the two. dnl dnl You must obey the GNU General Public License in all respects dnl for all of the code used other than OpenSSL. dnl dnl If you modify file(s) with this exception, you may extend this dnl exception to your dnl version of the file(s), but you are not obligated dnl to do so. dnl dnl If you dnl do not wish to do so, delete this exception statement from your dnl version. dnl dnl If you delete this exception statement from all source files in the dnl program, then also delete it here. AC_DEFUN([AIRCRACK_NG_ASAN], [ AC_ARG_ENABLE(asan, AS_HELP_STRING([--enable-asan], [Enable AddressSanitizer (ASAN)]), [asan=$enableval], [asan=no]) if test "x$asan" != "xno"; then # Assume both C and C++ compiler either support ASAN or not. LDFLAGS_saved="$LDFLAGS" LDFLAGS="$LDFLAGS -fsanitize=address" AX_CHECK_COMPILE_FLAG([-fsanitize=address], [ CFLAGS="$CFLAGS -fsanitize=address -DSANITIZE_ADDRESS=1" CXXFLAGS="$CXXFLAGS -fsanitize=address -DSANITIZE_ADDRESS=1" ], [LDFLAGS="$LDFLAGS_saved"]) fi ]) aircrack-ng-1.6/build/m4/aircrack_ng_code_coverage.m4000066400000000000000000000037371361312141100225350ustar00rootroot00000000000000dnl Aircrack-ng dnl dnl Copyright (C) 2017 Joseph Benden dnl dnl Autotool support was written by: Joseph Benden dnl dnl This program is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by dnl the Free Software Foundation; either version 2 of the License, or dnl (at your option) any later version. dnl dnl This program is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the dnl GNU General Public License for more details. dnl dnl You should have received a copy of the GNU General Public License dnl along with this program; if not, write to the Free Software dnl Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA dnl dnl In addition, as a special exception, the copyright holders give dnl permission to link the code of portions of this program with the dnl OpenSSL library under certain conditions as described in each dnl individual source file, and distribute linked combinations dnl including the two. dnl dnl You must obey the GNU General Public License in all respects dnl for all of the code used other than OpenSSL. dnl dnl If you modify file(s) with this exception, you may extend this dnl exception to your dnl version of the file(s), but you are not obligated dnl to do so. dnl dnl If you dnl do not wish to do so, delete this exception statement from your dnl version. dnl dnl If you delete this exception statement from all source files in the dnl program, then also delete it here. AC_DEFUN([AIRCRACK_NG_CODE_COVERAGE], [ AX_REQUIRE_DEFINED([AX_CODE_COVERAGE]) AX_REQUIRE_DEFINED([AX_APPEND_FLAG]) CODE_COVERAGE_IGNORE_PATTERN="/usr/include/\* /usr/local/include/\* /usr/lib/gcc/\* /usr/local/lib/gcc/\*" AC_SUBST(CODE_COVERAGE_IGNORE_PATTERN) CODE_COVERAGE_BRANCH_COVERAGE=1 AC_SUBST(CODE_COVERAGE_BRANCH_COVERAGE) AX_CODE_COVERAGE ]) aircrack-ng-1.6/build/m4/aircrack_ng_compiler.m4000066400000000000000000000144121361312141100215520ustar00rootroot00000000000000dnl Aircrack-ng dnl dnl Copyright (C) 2017 Joseph Benden dnl dnl Autotool support was written by: Joseph Benden dnl dnl This program is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by dnl the Free Software Foundation; either version 2 of the License, or dnl (at your option) any later version. dnl dnl This program is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the dnl GNU General Public License for more details. dnl dnl You should have received a copy of the GNU General Public License dnl along with this program; if not, write to the Free Software dnl Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA dnl dnl In addition, as a special exception, the copyright holders give dnl permission to link the code of portions of this program with the dnl OpenSSL library under certain conditions as described in each dnl individual source file, and distribute linked combinations dnl including the two. dnl dnl You must obey the GNU General Public License in all respects dnl for all of the code used other than OpenSSL. dnl dnl If you modify file(s) with this exception, you may extend this dnl exception to your dnl version of the file(s), but you are not obligated dnl to do so. dnl dnl If you dnl do not wish to do so, delete this exception statement from your dnl version. dnl dnl If you delete this exception statement from all source files in the dnl program, then also delete it here. AC_DEFUN([AIRCRACK_NG_COMPILER], [ AX_REQUIRE_DEFINED([AX_COMPILER_VENDOR]) AX_REQUIRE_DEFINED([AX_COMPILER_VERSION]) AX_REQUIRE_DEFINED([AX_COMPARE_VERSION]) AX_REQUIRE_DEFINED([AX_CHECK_COMPILE_FLAG]) AX_REQUIRE_DEFINED([AX_CFLAGS_WARN_ALL]) AX_REQUIRE_DEFINED([AX_CXXFLAGS_WARN_ALL]) AX_REQUIRE_DEFINED([AX_APPEND_FLAG]) AX_COMPILER_VENDOR AX_COMPILER_VERSION saved_cflags="$CFLAGS" CFLAGS="" AX_CFLAGS_WARN_ALL AX_APPEND_FLAG($CFLAGS, [opt_cflags]) CFLAGS="$saved_cflags" saved_cxxflags="$CXXFLAGS" CXXFLAGS="" AX_CXXFLAGS_WARN_ALL AX_APPEND_FLAG($CXXFLAGS, [opt_cxxflags]) CXXFLAGS="$saved_cxxflags" case "$ax_cv_c_compiler_vendor" in clang) AX_APPEND_FLAG(-Wno-unused-command-line-argument, [opt_cppflags]) AX_APPEND_FLAG(-Wno-unused-command-line-argument, [opt_cflags]) AX_APPEND_FLAG(-Wno-unused-command-line-argument, [opt_cxxflags]) AX_APPEND_FLAG(-Wno-unused-command-line-argument, [opt_ldflags]) ;; esac AC_ARG_WITH(opt, [AS_HELP_STRING([--without-opt], [disable -O3 optimizations])]) AS_IF([test "x$enable_code_coverage" = "xno"], [ case $with_opt in yes | "") AX_CHECK_COMPILE_FLAG([-O3], [ AX_APPEND_FLAG(-O3, [opt_[]_AC_LANG_ABBREV[]flags]) ]) ;; esac ]) AC_LANG_CASE([C], [ saved_cflags="$CFLAGS" AX_CHECK_COMPILE_FLAG([-std=gnu99], [ AX_APPEND_FLAG(-std=gnu99, [opt_[]_AC_LANG_ABBREV[]flags]) ]) AX_CHECK_COMPILE_FLAG([-fno-strict-aliasing], [ AX_APPEND_FLAG(-fno-strict-aliasing, [opt_[]_AC_LANG_ABBREV[]flags]) ]) AX_CHECK_COMPILE_FLAG([-Wpointer-arith], [ AX_APPEND_FLAG(-Wpointer-arith, [opt_[]_AC_LANG_ABBREV[]flags]) ]) case "$ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor" in gnu|clang) AX_CHECK_COMPILE_FLAG([-Wstrict-overflow=2], [ AX_APPEND_FLAG(-Wstrict-overflow=2, [opt_[]_AC_LANG_ABBREV[]flags]) ]) ;; esac case "$ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor" in intel) dnl warning 2218 is: result of call is not used AX_APPEND_FLAG(-diag-disable 2218, [opt_[]_AC_LANG_ABBREV[]flags]) ;; esac case "$ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor" in gnu|clang|intel) AX_APPEND_FLAG(-Wstrict-prototypes, [opt_[]_AC_LANG_ABBREV[]flags]) ;; esac ]) AX_CHECK_COMPILE_FLAG([-fvisibility=hidden], [ AX_APPEND_FLAG(-fvisibility=hidden, [opt_[]_AC_LANG_ABBREV[]flags]) ]) case "$ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor" in gnu|clang|intel) AX_COMPARE_VERSION([$ax_cv_[]_AC_LANG_ABBREV[]_compiler_version], [ge], [4.1], [gcc_over41=yes], [gcc_over41=x]) AX_COMPARE_VERSION([$ax_cv_[]_AC_LANG_ABBREV[]_compiler_version], [ge], [4.5], [gcc_over45=yes], [gcc_over45=x]) AX_COMPARE_VERSION([$ax_cv_[]_AC_LANG_ABBREV[]_compiler_version], [ge], [4.9], [gcc_over49=yes], [gcc_over49=x]) ;; esac dnl dnl Enable compiler flags that meet the required minimum version dnl case "$ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor" in gnu|clang) case "$host_os" in CYGWIN*|MSYS*|cygwin*|msys*) ;; *) case $with_opt in yes | "") AS_IF([test "x$gcc_over49" = "xno"], [ AS_IF([test "x$gcc_over41" = "xyes"], [ AX_CHECK_COMPILE_FLAG([-fstack-protector], [ AX_APPEND_FLAG(-fstack-protector, [opt_[]_AC_LANG_ABBREV[]flags]) ]) ], []) ], []) AS_IF([test "x$gcc_over49" = "xyes"], [ AX_CHECK_COMPILE_FLAG([-fstack-protector-strong], [ AX_APPEND_FLAG(-fstack-protector-strong, [opt_[]_AC_LANG_ABBREV[]flags]) ]) ], []) ;; esac ;; esac ;; esac AS_IF([test "x$gcc_over45" = "xyes"], [ case "$ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor" in gnu|intel) AX_CHECK_COMPILE_FLAG([-Wno-unused-but-set-variable], [ AX_APPEND_FLAG(-Wno-unused-but-set-variable, [opt_[]_AC_LANG_ABBREV[]flags]) ]) ;; esac AX_CHECK_COMPILE_FLAG([-Wno-array-bounds], [ AX_APPEND_FLAG(-Wno-array-bounds, [opt_[]_AC_LANG_ABBREV[]flags]) ]) ], []) ]) AC_DEFUN([AIRCRACK_NG_COMPILER_C], [ AC_LANG_PUSH([C]) AIRCRACK_NG_COMPILER AC_LANG_POP([C]) ]) AC_DEFUN([AIRCRACK_NG_COMPILER_CXX], [ AC_LANG_PUSH([C++]) AIRCRACK_NG_COMPILER AC_LANG_POP([C++]) ]) aircrack-ng-1.6/build/m4/aircrack_ng_crypto.m4000066400000000000000000000062521361312141100212630ustar00rootroot00000000000000dnl Aircrack-ng dnl dnl Copyright (C) 2017 Joseph Benden dnl dnl Autotool support was written by: Joseph Benden dnl dnl This program is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by dnl the Free Software Foundation; either version 2 of the License, or dnl (at your option) any later version. dnl dnl This program is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the dnl GNU General Public License for more details. dnl dnl You should have received a copy of the GNU General Public License dnl along with this program; if not, write to the Free Software dnl Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA dnl dnl In addition, as a special exception, the copyright holders give dnl permission to link the code of portions of this program with the dnl OpenSSL library under certain conditions as described in each dnl individual source file, and distribute linked combinations dnl including the two. dnl dnl You must obey the GNU General Public License in all respects dnl for all of the code used other than OpenSSL. dnl dnl If you modify file(s) with this exception, you may extend this dnl exception to your dnl version of the file(s), but you are not obligated dnl to do so. dnl dnl If you dnl do not wish to do so, delete this exception statement from your dnl version. dnl dnl If you delete this exception statement from all source files in the dnl program, then also delete it here. AC_DEFUN([AIRCRACK_NG_CRYPTO],[ AC_ARG_ENABLE(static-crypto, AS_HELP_STRING([--enable-static-crypto], [Enable statically linked OpenSSL libcrypto.]), [static_crypto=$enableval], [static_crypto=no]) if test "x$static_crypto" != "xno"; then AC_REQUIRE([AX_EXT_HAVE_STATIC_LIB_DETECT]) AX_EXT_HAVE_STATIC_LIB(ZLIB, ${DEFAULT_STATIC_LIB_SEARCH_PATHS}, z libz, compress) AX_EXT_HAVE_STATIC_LIB(OPENSSL, ${DEFAULT_STATIC_LIB_SEARCH_PATHS}, crypto libcrypto, HMAC, -lz -ldl) else AX_CHECK_OPENSSL([OPENSSL_FOUND=yes],[OPENSSL_FOUND=no]) AX_LIB_GCRYPT fi CRYPTO_CFLAGS= CRYPTO_INCLUDES= CRYPTO_LIBS= CRYPTO_LDFLAGS= CRYPTO_TYPE= AC_MSG_CHECKING([for OpenSSL or libgcrypt]) if test x"$GCRYPT_LIBS" != x; then AC_MSG_RESULT([libgcrypt]) CRYPTO_CFLAGS="$GCRYPT_CFLAGS -DUSE_GCRYPT" CRYPTO_INCLUDES="" CRYPTO_LIBS="$GCRYPT_LIBS" CRYPTO_LDFLAGS="" CRYPTO_TYPE=libgcrypt elif test "$OPENSSL_FOUND" = yes; then AC_MSG_RESULT([OpenSSL]) CRYPTO_INCLUDES="$OPENSSL_INCLUDES" CRYPTO_LIBS="$OPENSSL_LIBS" CRYPTO_LDFLAGS="$OPENSSL_LDFLAGS" CRYPTO_TYPE=openssl AC_CHECK_HEADERS([openssl/cmac.h], [ AC_DEFINE([HAVE_OPENSSL_CMAC_H], [1], [Define if you have openssl/cmac.h header present.]) HAVE_CMAC=yes ], [HAVE_CMAC=no]) else AC_MSG_ERROR([one of OpenSSL or Gcrypt was not found]) fi AC_SUBST(CRYPTO_CFLAGS) AC_SUBST(CRYPTO_INCLUDES) AC_SUBST(CRYPTO_LIBS) AC_SUBST(CRYPTO_LDFLAGS) AM_CONDITIONAL([LIBGCRYPT], [test "$CRYPTO_TYPE" = libgcrypt]) AM_CONDITIONAL([STATIC_CRYPTO], [test "$static_crypto" != no]) ]) aircrack-ng-1.6/build/m4/aircrack_ng_duma.m4000066400000000000000000000037731361312141100206760ustar00rootroot00000000000000dnl Aircrack-ng dnl dnl Copyright (C) 2017 Joseph Benden dnl dnl Autotool support was written by: Joseph Benden dnl dnl This program is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by dnl the Free Software Foundation; either version 2 of the License, or dnl (at your option) any later version. dnl dnl This program is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the dnl GNU General Public License for more details. dnl dnl You should have received a copy of the GNU General Public License dnl along with this program; if not, write to the Free Software dnl Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA dnl dnl In addition, as a special exception, the copyright holders give dnl permission to link the code of portions of this program with the dnl OpenSSL library under certain conditions as described in each dnl individual source file, and distribute linked combinations dnl including the two. dnl dnl You must obey the GNU General Public License in all respects dnl for all of the code used other than OpenSSL. dnl dnl If you modify file(s) with this exception, you may extend this dnl exception to your dnl version of the file(s), but you are not obligated dnl to do so. dnl dnl If you dnl do not wish to do so, delete this exception statement from your dnl version. dnl dnl If you delete this exception statement from all source files in the dnl program, then also delete it here. AC_DEFUN([AIRCRACK_NG_DUMA], [ AX_REQUIRE_DEFINED([AC_CHECK_LIB]) AC_ARG_WITH(duma, [AS_HELP_STRING([--with-duma[[=auto|yes|no]]], [use DUMA library, [default=auto]])]) case $with_duma in yes | "" | auto) AC_CHECK_LIB([duma], [malloc], [ LIBS="$LIBS -lduma" DUMA=yes ],[ DUMA=no ]) ;; *) DUMA=no ;; esac ]) aircrack-ng-1.6/build/m4/aircrack_ng_ethtool.m4000066400000000000000000000043761361312141100214260ustar00rootroot00000000000000dnl Aircrack-ng dnl dnl Copyright (C) 2017 Joseph Benden dnl dnl Autotool support was written by: Joseph Benden dnl dnl This program is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by dnl the Free Software Foundation; either version 2 of the License, or dnl (at your option) any later version. dnl dnl This program is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the dnl GNU General Public License for more details. dnl dnl You should have received a copy of the GNU General Public License dnl along with this program; if not, write to the Free Software dnl Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA dnl dnl In addition, as a special exception, the copyright holders give dnl permission to link the code of portions of this program with the dnl OpenSSL library under certain conditions as described in each dnl individual source file, and distribute linked combinations dnl including the two. dnl dnl You must obey the GNU General Public License in all respects dnl for all of the code used other than OpenSSL. dnl dnl If you modify file(s) with this exception, you may extend this dnl exception to your dnl version of the file(s), but you are not obligated dnl to do so. dnl dnl If you dnl do not wish to do so, delete this exception statement from your dnl version. dnl dnl If you delete this exception statement from all source files in the dnl program, then also delete it here. AC_DEFUN([AIRCRACK_NG_ETHTOOL],[ case "$target" in *-linux-*) AC_ARG_VAR([ETHTOOL],[Use this ethtool for Airmon-ng.]) dnl Allow env override but do not be fooled by 'ETHTOOL=t'. test t = "$ETHTOOL" && unset ETHTOOL AC_CHECK_PROG([ETHTOOL], [ethtool], [$as_dir/$ac_word$ac_exec_ext], [], [$ETHTOOL_PATH$PATH_SEPARATOR$PATH$PATH_SEPARATOR/sbin$PATH_SEPARATOR/usr/sbin$PATH_SEPARATOR/usr/local/sbin]) AS_IF([test "x$ETHTOOL" = "x"],[ AC_MSG_WARN([ethtool not found; cannot build Airmon-ng]) ETHTOOL_FOUND="not found, skipping Airmon-ng" ], [ ETHTOOL_FOUND="yes, found $ETHTOOL" ]) ;; *) ETHTOOL_FOUND="not required" ;; esac ]) aircrack-ng-1.6/build/m4/aircrack_ng_expect.m4000066400000000000000000000040171361312141100212300ustar00rootroot00000000000000dnl Aircrack-ng dnl dnl Copyright (C) 2019 Joseph Benden dnl dnl Autotool support was written by: Joseph Benden dnl dnl This program is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by dnl the Free Software Foundation; either version 2 of the License, or dnl (at your option) any later version. dnl dnl This program is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the dnl GNU General Public License for more details. dnl dnl You should have received a copy of the GNU General Public License dnl along with this program; if not, write to the Free Software dnl Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA dnl dnl In addition, as a special exception, the copyright holders give dnl permission to link the code of portions of this program with the dnl OpenSSL library under certain conditions as described in each dnl individual source file, and distribute linked combinations dnl including the two. dnl dnl You must obey the GNU General Public License in all respects dnl for all of the code used other than OpenSSL. dnl dnl If you modify file(s) with this exception, you may extend this dnl exception to your dnl version of the file(s), but you are not obligated dnl to do so. dnl dnl If you dnl do not wish to do so, delete this exception statement from your dnl version. dnl dnl If you delete this exception statement from all source files in the dnl program, then also delete it here. AC_DEFUN([AIRCRACK_NG_EXPECT],[ AC_ARG_VAR([EXPECT],[Use this expect tool for tests.]) dnl Allow env override but do not be fooled by 'EXPECT=t'. test t = "$EXPECT" && unset EXPECT AC_CHECK_PROG([EXPECT], [expect], [$as_dir/$ac_word$ac_exec_ext], []) AS_IF([test "x$EXPECT" = "x"],[ AC_MSG_WARN([expect not found; cannot run some tests]) EXPECT_FOUND="not found" ], [ EXPECT_FOUND="yes" ]) ]) aircrack-ng-1.6/build/m4/aircrack_ng_experimental.m4000066400000000000000000000037471361312141100224460ustar00rootroot00000000000000dnl Aircrack-ng dnl dnl Copyright (C) 2017 Joseph Benden dnl dnl Autotool support was written by: Joseph Benden dnl dnl This program is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by dnl the Free Software Foundation; either version 2 of the License, or dnl (at your option) any later version. dnl dnl This program is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the dnl GNU General Public License for more details. dnl dnl You should have received a copy of the GNU General Public License dnl along with this program; if not, write to the Free Software dnl Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA dnl dnl In addition, as a special exception, the copyright holders give dnl permission to link the code of portions of this program with the dnl OpenSSL library under certain conditions as described in each dnl individual source file, and distribute linked combinations dnl including the two. dnl dnl You must obey the GNU General Public License in all respects dnl for all of the code used other than OpenSSL. dnl dnl If you modify file(s) with this exception, you may extend this dnl exception to your dnl version of the file(s), but you are not obligated dnl to do so. dnl dnl If you dnl do not wish to do so, delete this exception statement from your dnl version. dnl dnl If you delete this exception statement from all source files in the dnl program, then also delete it here. AC_DEFUN([AIRCRACK_NG_EXPERIMENTAL], [ AC_ARG_WITH(experimental, [AS_HELP_STRING([--with-experimental=[[yes|no]]], [use experimental features of Aircrack-ng, [default=no]])]) case $with_experimental in yes) EXPERIMENTAL=yes ;; *) EXPERIMENTAL=no ;; esac AM_CONDITIONAL([EXPERIMENTAL], [test "$EXPERIMENTAL" = yes]) ]) aircrack-ng-1.6/build/m4/aircrack_ng_ext_scripts.m4000066400000000000000000000052661361312141100223160ustar00rootroot00000000000000dnl Aircrack-ng dnl dnl Copyright (C) 2017 Joseph Benden dnl dnl Autotool support was written by: Joseph Benden dnl dnl This program is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by dnl the Free Software Foundation; either version 2 of the License, or dnl (at your option) any later version. dnl dnl This program is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the dnl GNU General Public License for more details. dnl dnl You should have received a copy of the GNU General Public License dnl along with this program; if not, write to the Free Software dnl Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA dnl dnl In addition, as a special exception, the copyright holders give dnl permission to link the code of portions of this program with the dnl OpenSSL library under certain conditions as described in each dnl individual source file, and distribute linked combinations dnl including the two. dnl dnl You must obey the GNU General Public License in all respects dnl for all of the code used other than OpenSSL. dnl dnl If you modify file(s) with this exception, you may extend this dnl exception to your dnl version of the file(s), but you are not obligated dnl to do so. dnl dnl If you dnl do not wish to do so, delete this exception statement from your dnl version. dnl dnl If you delete this exception statement from all source files in the dnl program, then also delete it here. AC_DEFUN([AIRCRACK_NG_EXT_SCRIPTS], [ if test "$cross_compiling" = no; then AC_CHECK_PROGS([PYTHON], [python python3 python2]) if test $PYTHON = no; then AC_MSG_FAILURE(failed to find Python) fi if test "x$PYTHON" != "x"; then pc_cv_python_site_dir=`$PYTHON -c 'import site; print(site.getsitepackages()[[-1]])'` dnl AC_SUBST([pythondir], [\${prefix}/$pc_cv_python_site_dir]) AC_SUBST([pythondir], [$pc_cv_python_site_dir]) AC_SUBST([pkgpythondir], [\${pythondir}/$PACKAGE_NAME]) fi fi AC_CHECK_PROGS([READLINK], [greadlink readlink]) AC_ARG_WITH(ext-scripts, [AS_HELP_STRING([--with-ext-scripts], [enable experimental, extra scripts])]) case "$with_ext_scripts" in yes) AC_MSG_CHECKING([for Python requirement for ext-scripts]) if test "x$PYTHON" = x ; then AC_MSG_FAILURE([not found]) else AC_MSG_RESULT([found; $PYTHON]) fi EXT_SCRIPTS=yes ;; *) EXT_SCRIPTS=no ;; esac AM_CONDITIONAL([EXT_SCRIPTS], [test "$EXT_SCRIPTS" = yes]) ]) aircrack-ng-1.6/build/m4/aircrack_ng_hwloc.m4000066400000000000000000000055641361312141100210640ustar00rootroot00000000000000dnl Aircrack-ng dnl dnl Copyright (C) 2018 Joseph Benden dnl dnl Autotool support was written by: Joseph Benden dnl dnl This program is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by dnl the Free Software Foundation; either version 2 of the License, or dnl (at your option) any later version. dnl dnl This program is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the dnl GNU General Public License for more details. dnl dnl You should have received a copy of the GNU General Public License dnl along with this program; if not, write to the Free Software dnl Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA dnl dnl In addition, as a special exception, the copyright holders give dnl permission to link the code of portions of this program with the dnl OpenSSL library under certain conditions as described in each dnl individual source file, and distribute linked combinations dnl including the two. dnl dnl You must obey the GNU General Public License in all respects dnl for all of the code used other than OpenSSL. dnl dnl If you modify file(s) with this exception, you may extend this dnl exception to your dnl version of the file(s), but you are not obligated dnl to do so. dnl dnl If you dnl do not wish to do so, delete this exception statement from your dnl version. dnl dnl If you delete this exception statement from all source files in the dnl program, then also delete it here. AC_DEFUN([AIRCRACK_NG_HWLOC], [ AC_ARG_ENABLE([hwloc],[AC_HELP_STRING([--enable-hwloc], [include hwloc library, [default=yes]])]) HAVE_HWLOC=no AC_ARG_ENABLE(static-hwloc, AS_HELP_STRING([--enable-static-hwloc], [Enable statically linked OpenMPI libhwloc.]), [static_hwloc=$enableval], [static_hwloc=no]) if test "x$static_hwloc" != "xno"; then enable_hwloc=yes fi AS_IF([test "x$enable_hwloc" != "xno"], [ if test "x$static_hwloc" != "xno"; then AC_REQUIRE([AX_EXT_HAVE_STATIC_LIB_DETECT]) AX_EXT_HAVE_STATIC_LIB(HWLOC, ${DEFAULT_STATIC_LIB_SEARCH_PATHS}, hwloc libhwloc, hwloc_bitmap_alloc, -lnuma -lltdl) AX_EXT_HAVE_STATIC_LIB(NUMA, ${DEFAULT_STATIC_LIB_SEARCH_PATHS}, numa libnuma, numa_bitmask_setbit, -lltdl) AX_EXT_HAVE_STATIC_LIB(LTDL, ${DEFAULT_STATIC_LIB_SEARCH_PATHS}, ltdl libltdl, lt_dlopen, -ldl) HWLOC_LIBS="$HWLOC_LIBS $NUMA_LIBS $LTDL_LIBS" AC_SUBST([HWLOC_LIBS]) HAVE_HWLOC=yes else PKG_CHECK_MODULES(HWLOC, hwloc, HWLOC_FOUND=yes, HWLOC_FOUND=no) fi AS_IF([test "x$HWLOC_FOUND" = "xyes"], [ AC_DEFINE([HAVE_HWLOC], [1], [Define if you have hwloc library.]) HAVE_HWLOC=yes ]) ]) AM_CONDITIONAL([HAVE_HWLOC], [test "$HWLOC_FOUND" = yes]) AM_CONDITIONAL([STATIC_HWLOC], [test "$static_hwloc" != no]) ]) aircrack-ng-1.6/build/m4/aircrack_ng_jemalloc.m4000066400000000000000000000040211361312141100215210ustar00rootroot00000000000000dnl Aircrack-ng dnl dnl Copyright (C) 2018 Joseph Benden dnl dnl Autotool support was written by: Joseph Benden dnl dnl This program is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by dnl the Free Software Foundation; either version 2 of the License, or dnl (at your option) any later version. dnl dnl This program is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the dnl GNU General Public License for more details. dnl dnl You should have received a copy of the GNU General Public License dnl along with this program; if not, write to the Free Software dnl Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA dnl dnl In addition, as a special exception, the copyright holders give dnl permission to link the code of portions of this program with the dnl OpenSSL library under certain conditions as described in each dnl individual source file, and distribute linked combinations dnl including the two. dnl dnl You must obey the GNU General Public License in all respects dnl for all of the code used other than OpenSSL. dnl dnl If you modify file(s) with this exception, you may extend this dnl exception to your dnl version of the file(s), but you are not obligated dnl to do so. dnl dnl If you dnl do not wish to do so, delete this exception statement from your dnl version. dnl dnl If you delete this exception statement from all source files in the dnl program, then also delete it here. AC_DEFUN([AIRCRACK_NG_JEMALLOC], [ AX_REQUIRE_DEFINED([AC_CHECK_LIB]) AC_ARG_WITH(jemalloc, [AS_HELP_STRING([--with-jemalloc[[=yes|no]]], [use jemalloc library, [default=no]])]) case $with_jemalloc in yes) AC_CHECK_LIB([jemalloc], [mallocx], [ LIBS="$LIBS -ljemalloc" JEMALLOC=yes ],[ JEMALLOC=no ]) ;; *) JEMALLOC=no ;; esac ]) aircrack-ng-1.6/build/m4/aircrack_ng_largefile.m4000066400000000000000000000036451361312141100217000ustar00rootroot00000000000000dnl Aircrack-ng dnl dnl Copyright (C) 2017 Joseph Benden dnl dnl Autotool support was written by: Joseph Benden dnl dnl This program is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by dnl the Free Software Foundation; either version 2 of the License, or dnl (at your option) any later version. dnl dnl This program is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the dnl GNU General Public License for more details. dnl dnl You should have received a copy of the GNU General Public License dnl along with this program; if not, write to the Free Software dnl Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA dnl dnl In addition, as a special exception, the copyright holders give dnl permission to link the code of portions of this program with the dnl OpenSSL library under certain conditions as described in each dnl individual source file, and distribute linked combinations dnl including the two. dnl dnl You must obey the GNU General Public License in all respects dnl for all of the code used other than OpenSSL. dnl dnl If you modify file(s) with this exception, you may extend this dnl exception to your dnl version of the file(s), but you are not obligated dnl to do so. dnl dnl If you dnl do not wish to do so, delete this exception statement from your dnl version. dnl dnl If you delete this exception statement from all source files in the dnl program, then also delete it here. AC_DEFUN([AIRCRACK_NG_LARGEFILE], [ AX_REQUIRE_DEFINED([AC_SYS_LARGEFILE])[]dnl AC_SYS_LARGEFILE AS_IF([test ".$ac_cv_sys_file_offset_bits$ac_cv_sys_large_files" != ".nono"], [ AC_DEFINE([_LARGEFILE64_SOURCE], [1], [Define this if 64-bit file access requires this define to be present]) ]) ]) aircrack-ng-1.6/build/m4/aircrack_ng_libnl.m4000066400000000000000000000115261361312141100210430ustar00rootroot00000000000000dnl Aircrack-ng dnl dnl Copyright (C) 2017 Joseph Benden dnl dnl Autotool support was written by: Joseph Benden dnl dnl This program is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by dnl the Free Software Foundation; either version 2 of the License, or dnl (at your option) any later version. dnl dnl This program is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the dnl GNU General Public License for more details. dnl dnl You should have received a copy of the GNU General Public License dnl along with this program; if not, write to the Free Software dnl Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA dnl dnl In addition, as a special exception, the copyright holders give dnl permission to link the code of portions of this program with the dnl OpenSSL library under certain conditions as described in each dnl individual source file, and distribute linked combinations dnl including the two. dnl dnl You must obey the GNU General Public License in all respects dnl for all of the code used other than OpenSSL. dnl dnl If you modify file(s) with this exception, you may extend this dnl exception to your dnl version of the file(s), but you are not obligated dnl to do so. dnl dnl If you dnl do not wish to do so, delete this exception statement from your dnl version. dnl dnl If you delete this exception statement from all source files in the dnl program, then also delete it here. AC_DEFUN([AIRCRACK_NG_LIBNL], [ AC_ARG_ENABLE([libnl],[AC_HELP_STRING([--enable-libnl], [include netlink library, [default=yes on Linux]])]) _aircrack_ng_enable_libnl=no case "$host_os" in LINUX* | linux*) _aircrack_ng_enable_libnl=yes ;; esac case "$_aircrack_ng_enable_libnl" in yes) case "$enable_libnl" in yes | "" | auto) PKG_CHECK_MODULES([LIBNL3X], [libnl-3.0 >= 3.2], [ # CPPFLAGS="$CPPFLAGS $LIBNL3X_CFLAGS -DCONFIG_LIBNL30 -DCONFIG_LIBNL" # LIBS="$LIBS $LIBNL3X_LIBS -lnl-genl-3" AC_DEFINE([CONFIG_LIBNL30], [1], [Define this if libnl-3.0 is present on your system]) LIBNL_CFLAGS="$LIBNL3X_CFLAGS" LIBNL_LIBS="$LIBNL3X_LIBS -lnl-genl-3" NLLIBNAME="libnl-3.0" ], [ PKG_CHECK_MODULES([LIBNL31], [libnl-3.1 = 3.1], [ AC_DEFINE([CONFIG_LIBNL30], [1], [Define this if libnl-3.0 is present on your system]) LIBNL_CFLAGS="$LIBNL31_CFLAGS" LIBNL_LIBS="$LIBNL31_LIBS -lnl-genl" NLLIBNAME="libnl-3.1" ], [ PKG_CHECK_MODULES([LIBNL30], [libnl-3.0 >= 3], [ AC_DEFINE([CONFIG_LIBNL30], [1], [Define this if libnl-3.0 is present on your system]) LIBNL_CFLAGS="$LIBNL30_CFLAGS" LIBNL_LIBS="$LIBNL30_LIBS -lnl-genl" NLLIBNAME="libnl-3.0" ], [ PKG_CHECK_MODULES([LIBNL1], [libnl-1 >= 1], [ LIBNL_CFLAGS="$LIBNL1_CFLAGS" LIBNL_LIBS="$LIBNL1_LIBS" NLLIBNAME="libnl-1" ], [ PKG_CHECK_MODULES([LIBNLT], [libnl-tiny >= 1], [ AC_DEFINE([CONFIG_LIBNL20], [1], [Define this if libnl-tiny is present on your system]) LIBNL_CFLAGS="$LIBNLT_CFLAGS" LIBNL_LIBS="$LIBNLT_LIBS" NLLIBNAME="libnl-tiny" ], [ AC_MSG_RESULT([could not find development files for any supported version of libnl. install either libnl1 or libnl3.]) NLLIBNAME="" ]) ]) ]) ]) ]) AC_SUBST([LIBNL_CFLAGS]) AC_SUBST([LIBNL_LIBS]) AC_SUBST([NLLIBNAME]) if test "x$NLLIBNAME" = x; then NLLIBNAME_FOUND="no" else NLLIBNAME_FOUND="yes, found $NLLIBNAME" AC_DEFINE([CONFIG_LIBNL], [1], [Define this if you have any supported netlink library required]) fi ;; *) NLLIBNAME_FOUND="not enabled" ;; esac ;; *) NLLIBNAME_FOUND="not required" ;; esac ]) aircrack-ng-1.6/build/m4/aircrack_ng_mac.m4000066400000000000000000000071341361312141100205030ustar00rootroot00000000000000dnl Aircrack-ng dnl dnl Copyright (C) 2017 Joseph Benden dnl dnl Autotool support was written by: Joseph Benden dnl dnl This program is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by dnl the Free Software Foundation; either version 2 of the License, or dnl (at your option) any later version. dnl dnl This program is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the dnl GNU General Public License for more details. dnl dnl You should have received a copy of the GNU General Public License dnl along with this program; if not, write to the Free Software dnl Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA dnl dnl In addition, as a special exception, the copyright holders give dnl permission to link the code of portions of this program with the dnl OpenSSL library under certain conditions as described in each dnl individual source file, and distribute linked combinations dnl including the two. dnl dnl You must obey the GNU General Public License in all respects dnl for all of the code used other than OpenSSL. dnl dnl If you modify file(s) with this exception, you may extend this dnl exception to your dnl version of the file(s), but you are not obligated dnl to do so. dnl dnl If you dnl do not wish to do so, delete this exception statement from your dnl version. dnl dnl If you delete this exception statement from all source files in the dnl program, then also delete it here. AC_DEFUN([AIRCRACK_NG_MAC],[ AX_REQUIRE_DEFINED([AC_CHECK_HEADER])[]dnl AX_REQUIRE_DEFINED([AC_CHECK_FILE])[]dnl AC_ARG_WITH(xcode, [AS_HELP_STRING([--with-xcode], [enable XCode support])]) case "$host_os" in DARWIN*|MACOS*|darwin*|macos*) dnl dnl Homebrew dnl AC_ARG_VAR([BREW],[Use this brew for macOS dependencies.]) dnl Allow env override but do not be fooled by 'BREW=t'. test t = "$BREW" && unset BREW AC_CHECK_PROG([BREW], [brew], [$as_dir/$ac_word$ac_exec_ext], [], [$BREW_PATH$PATH_SEPARATOR$PATH$PATH_SEPARATOR/bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR/usr/local/bin]) AS_IF([test "x$BREW" = "x"],[ AC_MSG_WARN([Homebrew not found]) BREW_FOUND=no ], [ BREW_FOUND=yes ]) if test "x$BREW_FOUND" = xyes; then CFLAGS="$CFLAGS -I$(brew --prefix openssl)/include" CXXFLAGS="$CXXFLAGS -I$(brew --prefix openssl)/include" CPPFLAGS="$CPPFLAGS -I$(brew --prefix openssl)/include" LDFLAGS="$LDFLAGS -L$(brew --prefix openssl)/lib" fi AC_CHECK_FILE(/usr/local/Homebrew, [ CPPFLAGS="$CPPFLAGS -I/usr/local/include" ]) dnl MacPorts AC_CHECK_FILE(/opt/local/include, [ CPPFLAGS="$CPPFLAGS -I/opt/local/include -I../.." OSX_ALT_FLAGS=true AC_CHECK_FILE(/opt/local/lib, [ LDFLAGS="$LDFLAGS -L/opt/local/lib" ], [ AC_MSG_ERROR([MacPorts installation seems broken, have includes but no libs.]) ]) ]) dnl XCode case $with_xcode in yes | "") AC_CHECK_FILE(/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-migrator/sdk/MacOSX.sdk/usr/include, [ CPPFLAGS="$CPPFLAGS -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-migrator/sdk/MacOSX.sdk/usr/include/ -D_XCODE -I../.." OSX_ALT_FLAGS=true ]) ;; esac ;; esac ]) aircrack-ng-1.6/build/m4/aircrack_ng_os_detect.m4000066400000000000000000000046761361312141100217240ustar00rootroot00000000000000dnl Aircrack-ng dnl dnl Copyright (C) 2017 Joseph Benden dnl dnl Autotool support was written by: Joseph Benden dnl dnl This program is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by dnl the Free Software Foundation; either version 2 of the License, or dnl (at your option) any later version. dnl dnl This program is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the dnl GNU General Public License for more details. dnl dnl You should have received a copy of the GNU General Public License dnl along with this program; if not, write to the Free Software dnl Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA dnl dnl In addition, as a special exception, the copyright holders give dnl permission to link the code of portions of this program with the dnl OpenSSL library under certain conditions as described in each dnl individual source file, and distribute linked combinations dnl including the two. dnl dnl You must obey the GNU General Public License in all respects dnl for all of the code used other than OpenSSL. dnl dnl If you modify file(s) with this exception, you may extend this dnl exception to your dnl version of the file(s), but you are not obligated dnl to do so. dnl dnl If you dnl do not wish to do so, delete this exception statement from your dnl version. dnl dnl If you delete this exception statement from all source files in the dnl program, then also delete it here. AC_DEFUN([AIRCRACK_NG_OS_DETECT],[ case "$host_os" in cygwin* | msys*) OS=cygwin ;; darwin* | macos*) OS=darwin ;; linux*) OS=linux ;; netbsd* | NetBSD*) OS=netbsd ;; openbsd* | OpenBSD*) OS=openbsd ;; freebsd* | FreeBSD* | hardenedbsd* | hbsd* | dragonfly* | DragonFly* | trueos* | TrueOS* | midnightbsd* | MidnightBSD*) OS=freebsd ;; *) OS=dummy ;; esac AM_CONDITIONAL([CYGWIN], [test "$OS" = cygwin]) AM_CONDITIONAL([DARWIN], [test "$OS" = darwin]) AM_CONDITIONAL([LINUX], [test "$OS" = linux]) AM_CONDITIONAL([NETBSD], [test "$OS" = netbsd]) AM_CONDITIONAL([FREEBSD], [test "$OS" = freebsd]) AM_CONDITIONAL([OPENBSD], [test "$OS" = openbsd]) AM_CONDITIONAL([DUMMY], [test "$OS" = dummy]) ]) aircrack-ng-1.6/build/m4/aircrack_ng_pcap.m4000066400000000000000000000070771361312141100206740ustar00rootroot00000000000000dnl Aircrack-ng dnl dnl Copyright (C) 2017 Joseph Benden dnl dnl Autotool support was written by: Joseph Benden dnl dnl This program is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by dnl the Free Software Foundation; either version 2 of the License, or dnl (at your option) any later version. dnl dnl This program is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the dnl GNU General Public License for more details. dnl dnl You should have received a copy of the GNU General Public License dnl along with this program; if not, write to the Free Software dnl Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA dnl dnl In addition, as a special exception, the copyright holders give dnl permission to link the code of portions of this program with the dnl OpenSSL library under certain conditions as described in each dnl individual source file, and distribute linked combinations dnl including the two. dnl dnl You must obey the GNU General Public License in all respects dnl for all of the code used other than OpenSSL. dnl dnl If you modify file(s) with this exception, you may extend this dnl exception to your dnl version of the file(s), but you are not obligated dnl to do so. dnl dnl If you dnl do not wish to do so, delete this exception statement from your dnl version. dnl dnl If you delete this exception statement from all source files in the dnl program, then also delete it here. AC_DEFUN([AIRCRACK_NG_PCAP], [ AC_ARG_WITH(libpcap-include, [AS_HELP_STRING([--with-libpcap-include=DIR], [use PCAP includes in DIR, [default=auto]]) ],[ if test -d "$withval" ; then CPPFLAGS="$CPPFLAGS -I$withval" fi ]) AC_ARG_WITH(libpcap-lib, [AS_HELP_STRING([--with-libpcap-lib=DIR], [use PCAP libraries in DIR, [default=auto]]) ],[ if test -d "$withval" ; then LDFLAGS="$LDFLAGS -L$withval" fi ]) dnl dnl Search for headers dnl if test "${with_libpcap_include+set}" != set; then AC_MSG_CHECKING(pcap header directories) found_pcap_dir="" for pcap_dir in /usr/include/pcap /usr/local/include/pcap \ $prefix/include ; do if test -d "$pcap_dir" ; then found_pcap_dir="$pcap_dir" break fi done if test "$found_pcap_dir" != "" ; then PCAP_CFLAGS="-I$found_pcap_dir" AC_SUBST([PCAP_CFLAGS]) AC_MSG_RESULT([$found_pcap_dir]) else AC_MSG_RESULT([not found]) fi fi dnl dnl Verify that required headers are useable dnl saved_cflags="$CFLAGS" CFLAGS="$PCAP_INCLUDES $CFLAGS" AC_CHECK_HEADERS([pcap.h], [ PCAP_FOUND=yes ], [ PCAP_FOUND=no ]) CFLAGS="$saved_cflags" AC_ARG_ENABLE(static-pcap, AS_HELP_STRING([--enable-static-pcap], [Enable statically linked PCAP libpcap.]), [static_pcap=$enableval], [static_pcap=no]) dnl dnl Locate the library dnl AS_IF([test "$PCAP_FOUND" = yes], [ if test "x$static_pcap" != "xno"; then AC_REQUIRE([AX_EXT_HAVE_STATIC_LIB_DETECT]) AX_EXT_HAVE_STATIC_LIB(PCAP, ${DEFAULT_STATIC_LIB_SEARCH_PATHS}, pcap libpcap, pcap_open_live) if test "x$PCAP_FOUND" = xyes; then AC_DEFINE([HAVE_PCAP], [1], [Define this if you have libpcap on your system]) fi else AC_CHECK_LIB([pcap], [pcap_open_live], [ PCAP_LIBS=-lpcap AC_DEFINE([HAVE_PCAP], [1], [Define this if you have libpcap on your system]) AC_SUBST(PCAP_LIBS) PCAP_FOUND=yes ],[ PCAP_FOUND=no ]) fi ]) AM_CONDITIONAL([HAVE_PCAP], [test "$PCAP_FOUND" = yes]) ]) aircrack-ng-1.6/build/m4/aircrack_ng_pcre.m4000066400000000000000000000044041361312141100206710ustar00rootroot00000000000000dnl Aircrack-ng dnl dnl Copyright (C) 2017 Joseph Benden dnl dnl Autotool support was written by: Joseph Benden dnl dnl This program is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by dnl the Free Software Foundation; either version 2 of the License, or dnl (at your option) any later version. dnl dnl This program is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the dnl GNU General Public License for more details. dnl dnl You should have received a copy of the GNU General Public License dnl along with this program; if not, write to the Free Software dnl Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA dnl dnl In addition, as a special exception, the copyright holders give dnl permission to link the code of portions of this program with the dnl OpenSSL library under certain conditions as described in each dnl individual source file, and distribute linked combinations dnl including the two. dnl dnl You must obey the GNU General Public License in all respects dnl for all of the code used other than OpenSSL. dnl dnl If you modify file(s) with this exception, you may extend this dnl exception to your dnl version of the file(s), but you are not obligated dnl to do so. dnl dnl If you dnl do not wish to do so, delete this exception statement from your dnl version. dnl dnl If you delete this exception statement from all source files in the dnl program, then also delete it here. AC_DEFUN([AIRCRACK_NG_PCRE], [ AC_ARG_ENABLE(static-pcre, AS_HELP_STRING([--enable-static-pcre], [Enable statically linked PCRE libpcre.]), [static_pcre=$enableval], [static_pcre=no]) if test "x$static_pcre" != "xno"; then AC_REQUIRE([AX_EXT_HAVE_STATIC_LIB_DETECT]) AX_EXT_HAVE_STATIC_LIB(PCRE, ${DEFAULT_STATIC_LIB_SEARCH_PATHS}, pcre libpcre, pcre_version) if test "x$PCRE_FOUND" = xyes; then HAVE_PCRE=yes else HAVE_PCRE=no fi else PKG_CHECK_MODULES(PCRE, libpcre, HAVE_PCRE=yes, HAVE_PCRE=no) fi AS_IF([test "x$HAVE_PCRE" = "xyes"], [ AC_DEFINE([HAVE_PCRE], [1], [Define this if you have libpcre on your system]) ]) ]) aircrack-ng-1.6/build/m4/aircrack_ng_prog_cc.m4000066400000000000000000000035201361312141100213520ustar00rootroot00000000000000dnl Aircrack-ng dnl dnl Copyright (C) 2017 Joseph Benden dnl dnl Autotool support was written by: Joseph Benden dnl dnl This program is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by dnl the Free Software Foundation; either version 2 of the License, or dnl (at your option) any later version. dnl dnl This program is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the dnl GNU General Public License for more details. dnl dnl You should have received a copy of the GNU General Public License dnl along with this program; if not, write to the Free Software dnl Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA dnl dnl In addition, as a special exception, the copyright holders give dnl permission to link the code of portions of this program with the dnl OpenSSL library under certain conditions as described in each dnl individual source file, and distribute linked combinations dnl including the two. dnl dnl You must obey the GNU General Public License in all respects dnl for all of the code used other than OpenSSL. dnl dnl If you modify file(s) with this exception, you may extend this dnl exception to your dnl version of the file(s), but you are not obligated dnl to do so. dnl dnl If you dnl do not wish to do so, delete this exception statement from your dnl version. dnl dnl If you delete this exception statement from all source files in the dnl program, then also delete it here. AC_DEFUN([AIRCRACK_NG_PROG_CC],[ dnl dnl Require a C compiler, while working around a known problem of dnl Autoconf including the GCC flags '-g -O2'. dnl saved_cflags="$CFLAGS" AC_PROG_CC CFLAGS="$saved_cflags" ]) aircrack-ng-1.6/build/m4/aircrack_ng_prog_cxx.m4000066400000000000000000000035321361312141100215720ustar00rootroot00000000000000dnl Aircrack-ng dnl dnl Copyright (C) 2017 Joseph Benden dnl dnl Autotool support was written by: Joseph Benden dnl dnl This program is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by dnl the Free Software Foundation; either version 2 of the License, or dnl (at your option) any later version. dnl dnl This program is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the dnl GNU General Public License for more details. dnl dnl You should have received a copy of the GNU General Public License dnl along with this program; if not, write to the Free Software dnl Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA dnl dnl In addition, as a special exception, the copyright holders give dnl permission to link the code of portions of this program with the dnl OpenSSL library under certain conditions as described in each dnl individual source file, and distribute linked combinations dnl including the two. dnl dnl You must obey the GNU General Public License in all respects dnl for all of the code used other than OpenSSL. dnl dnl If you modify file(s) with this exception, you may extend this dnl exception to your dnl version of the file(s), but you are not obligated dnl to do so. dnl dnl If you dnl do not wish to do so, delete this exception statement from your dnl version. dnl dnl If you delete this exception statement from all source files in the dnl program, then also delete it here. AC_DEFUN([AIRCRACK_NG_PROG_CXX],[ dnl dnl Require a C compiler, while working around a known problem of dnl Autoconf including the GCC flags '-g -O2'. dnl saved_cxxflags="$CXXFLAGS" AC_PROG_CXX CXXFLAGS="$saved_cxxflags" ]) aircrack-ng-1.6/build/m4/aircrack_ng_pthread.m4000066400000000000000000000056301361312141100213710ustar00rootroot00000000000000dnl Aircrack-ng dnl dnl Copyright (C) 2018 Joseph Benden dnl dnl Autotool support was written by: Joseph Benden dnl dnl This program is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by dnl the Free Software Foundation; either version 2 of the License, or dnl (at your option) any later version. dnl dnl This program is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the dnl GNU General Public License for more details. dnl dnl You should have received a copy of the GNU General Public License dnl along with this program; if not, write to the Free Software dnl Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA dnl dnl In addition, as a special exception, the copyright holders give dnl permission to link the code of portions of this program with the dnl OpenSSL library under certain conditions as described in each dnl individual source file, and distribute linked combinations dnl including the two. dnl dnl You must obey the GNU General Public License in all respects dnl for all of the code used other than OpenSSL. dnl dnl If you modify file(s) with this exception, you may extend this dnl exception to your dnl version of the file(s), but you are not obligated dnl to do so. dnl dnl If you dnl do not wish to do so, delete this exception statement from your dnl version. dnl dnl If you delete this exception statement from all source files in the dnl program, then also delete it here. AC_DEFUN([AIRCRACK_NG_PTHREAD], [ AX_PTHREAD([ AC_CHECK_LIB([pthread], [pthread_create], [ PTHREAD_LIBS="-lpthread" ]) dnl AC_DEFINE([_REENTRANT], [], [Define this if your library functions are re-entrant]) ]) AC_MSG_CHECKING([for pthread_setaffinity_np]) AS_VAR_PUSHDEF([FLAGS],[_AC_LANG_PREFIX[]FLAGS])dnl ac_save_[]FLAGS="$[]FLAGS" ac_save_LDFLAGS="$LDFLAGS" FLAGS="$ac_save_[]FLAGS -pthread" LDFLAGS="$LDFLAGS $PTHREAD_LIBS -pthread" # Check for pthread_{,attr_}[sg]etaffinity_np. AC_LINK_IFELSE([ AC_LANG_PROGRAM([ #define _GNU_SOURCE #include ], [ cpu_set_t cpuset; pthread_attr_t attr; pthread_getaffinity_np (pthread_self (), sizeof (cpu_set_t), &cpuset); if (CPU_ISSET (0, &cpuset)) CPU_SET (1, &cpuset); else CPU_ZERO (&cpuset); pthread_setaffinity_np (pthread_self (), sizeof (cpu_set_t), &cpuset); pthread_attr_init (&attr); pthread_attr_getaffinity_np (&attr, sizeof (cpu_set_t), &cpuset); pthread_attr_setaffinity_np (&attr, sizeof (cpu_set_t), &cpuset); ]) ], [ AC_MSG_RESULT([yes]) AC_DEFINE(HAVE_PTHREAD_AFFINITY_NP, 1, [Define if pthread_{,attr_}{g,s}etaffinity_np is supported.]) ], [ AC_MSG_RESULT([no]) ]) LDFLAGS="$ac_save_LDFLAGS" FLAGS="$ac_save_[]FLAGS" AS_VAR_POPDEF([FLAGS])dnl ])aircrack-ng-1.6/build/m4/aircrack_ng_rfkill.m4000066400000000000000000000037351361312141100212310ustar00rootroot00000000000000dnl Aircrack-ng dnl dnl Copyright (C) 2017 Joseph Benden dnl dnl Autotool support was written by: Joseph Benden dnl dnl This program is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by dnl the Free Software Foundation; either version 2 of the License, or dnl (at your option) any later version. dnl dnl This program is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the dnl GNU General Public License for more details. dnl dnl You should have received a copy of the GNU General Public License dnl along with this program; if not, write to the Free Software dnl Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA dnl dnl In addition, as a special exception, the copyright holders give dnl permission to link the code of portions of this program with the dnl OpenSSL library under certain conditions as described in each dnl individual source file, and distribute linked combinations dnl including the two. dnl dnl You must obey the GNU General Public License in all respects dnl for all of the code used other than OpenSSL. dnl dnl If you modify file(s) with this exception, you may extend this dnl exception to your dnl version of the file(s), but you are not obligated dnl to do so. dnl dnl If you dnl do not wish to do so, delete this exception statement from your dnl version. dnl dnl If you delete this exception statement from all source files in the dnl program, then also delete it here. AC_DEFUN([AIRCRACK_NG_RFKILL],[ AC_ARG_VAR([RFKILL],[Use this rfkill tool.]) dnl Allow env override but do not be fooled by 'ETHTOOL=t'. test t = "$RFKILL" && unset RFKILL AC_CHECK_PROG([RFKILL], [rfkill], [$as_dir/$ac_word$ac_exec_ext], [], [$RFKILL_PATH$PATH_SEPARATOR$PATH$PATH_SEPARATOR/sbin$PATH_SEPARATOR/usr/sbin$PATH_SEPARATOR/usr/local/sbin]) ]) aircrack-ng-1.6/build/m4/aircrack_ng_simd.m4000066400000000000000000000231101361312141100206670ustar00rootroot00000000000000dnl Aircrack-ng dnl dnl Copyright (C) 2017 Joseph Benden dnl dnl Autotool support was written by: Joseph Benden dnl dnl This program is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by dnl the Free Software Foundation; either version 2 of the License, or dnl (at your option) any later version. dnl dnl This program is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the dnl GNU General Public License for more details. dnl dnl You should have received a copy of the GNU General Public License dnl along with this program; if not, write to the Free Software dnl Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA dnl dnl In addition, as a special exception, the copyright holders give dnl permission to link the code of portions of this program with the dnl OpenSSL library under certain conditions as described in each dnl individual source file, and distribute linked combinations dnl including the two. dnl dnl You must obey the GNU General Public License in all respects dnl for all of the code used other than OpenSSL. dnl dnl If you modify file(s) with this exception, you may extend this dnl exception to your dnl version of the file(s), but you are not obligated dnl to do so. dnl dnl If you dnl do not wish to do so, delete this exception statement from your dnl version. dnl dnl If you delete this exception statement from all source files in the dnl program, then also delete it here. AC_DEFUN([AIRCRACK_NG_SIMD], [ AX_REQUIRE_DEFINED([AX_COMPILER_VENDOR]) AX_REQUIRE_DEFINED([AX_COMPILER_VERSION]) AX_REQUIRE_DEFINED([AX_CHECK_COMPILE_FLAG]) AX_REQUIRE_DEFINED([AX_APPEND_FLAG]) AX_COMPILER_VENDOR AX_COMPILER_VERSION OPENBSD=0 IS_X86=0 IS_ARM=0 IS_PPC=0 IS_CROSS=0 if test "$cross_compiling" != yes then IS_CROSS=0 else IS_CROSS=1 fi case "$host_cpu" in x86_64 | amd64 | i*86*) IS_X86=1 ;; *arm* | *aarch64*) IS_ARM=1 ;; *mips*) IS_MIPS=1 ;; powerpc*) IS_PPC=1 ;; esac case "$host_os" in *openbsd* | *OpenBSD*) OPENBSD=1 ;; esac AS_IF([test $OPENBSD -eq 0], [ AC_LANG_CASE([C++], [ AX_CHECK_COMPILE_FLAG([-masm=intel], [ AX_APPEND_FLAG(-masm=intel, [opt_cxxflags]) AC_DEFINE([INTEL_ASM], [1], [Define if Intel assembly style is supported]) ]) ]) ]) if test $IS_ARM -eq 1 then AX_CHECK_COMPILE_FLAG([-Werror -mfpu=neon], [ AX_APPEND_FLAG(-mfpu=neon, [arm_neon_[]_AC_LANG_ABBREV[]flags]) AC_SUBST(arm_neon_[]_AC_LANG_ABBREV[]flags) ]) AS_VAR_PUSHDEF([CACHEVAR], [ax_cv_neon_[]_AC_LANG_ABBREV[]flags]) AC_CACHE_CHECK([whether _AC_LANG compiler supports NEON instructions], CACHEVAR, [ ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS _AC_LANG_PREFIX[]FLAGS="$arm_neon_[]_AC_LANG_ABBREV[]flags $[]_AC_LANG_PREFIX[]FLAGS" AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ #if !defined(__ARM_NEON) && !defined(__ARM_NEON__) && !defined(__aarch64) && !defined(__aarch64__) #error macro not defined #endif ]])], [AS_VAR_SET(CACHEVAR,[yes])], [AS_VAR_SET(CACHEVAR,[no])]) _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags ]) AS_IF([test x"AS_VAR_GET(CACHEVAR)" = xyes], [NEON_FOUND=1], [NEON_FOUND=0]) AS_VAR_POPDEF([CACHEVAR]) fi if test $IS_PPC -eq 1 then AX_CHECK_COMPILE_FLAG([-finline-functions], [ AX_APPEND_FLAG(-finline-functions, [ppc_altivec_[]_AC_LANG_ABBREV[]flags]) AC_SUBST(ppc_altivec_[]_AC_LANG_ABBREV[]flags) ]) AX_CHECK_COMPILE_FLAG([-finline-limit=4000], [ AX_APPEND_FLAG(-finline-limit=4000, [ppc_altivec_[]_AC_LANG_ABBREV[]flags]) AC_SUBST(ppc_altivec_[]_AC_LANG_ABBREV[]flags) ]) AX_CHECK_COMPILE_FLAG([-fno-strict-aliasing], [ AX_APPEND_FLAG(-fno-strict-aliasing, [ppc_altivec_[]_AC_LANG_ABBREV[]flags]) AC_SUBST(ppc_altivec_[]_AC_LANG_ABBREV[]flags) ]) AX_CHECK_COMPILE_FLAG([-maltivec], [ AX_APPEND_FLAG(-maltivec, [ppc_altivec_[]_AC_LANG_ABBREV[]flags]) AC_SUBST(ppc_altivec_[]_AC_LANG_ABBREV[]flags) ]) AX_CHECK_COMPILE_FLAG([-mabi=altivec], [ AX_APPEND_FLAG(-mabi=altivec, [ppc_altivec_[]_AC_LANG_ABBREV[]flags]) AC_SUBST(ppc_altivec_[]_AC_LANG_ABBREV[]flags) ]) AS_VAR_PUSHDEF([CACHEVAR], [ax_cv_altivec_[]_AC_LANG_ABBREV[]flags]) AC_CACHE_CHECK([whether _AC_LANG compiler supports VSX instructions], CACHEVAR, [ ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS _AC_LANG_PREFIX[]FLAGS="$ppc_altivec_[]_AC_LANG_ABBREV[]flags -mvsx -mpower8-vector $[]_AC_LANG_PREFIX[]FLAGS" AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ #if !defined(__VSX__) && !defined(__POWER8_VECTOR__) #error macro not defined #endif ]])], [AS_VAR_SET(CACHEVAR,[yes])], [AS_VAR_SET(CACHEVAR,[no])]) _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags ]) AS_IF([test x"AS_VAR_GET(CACHEVAR)" = xyes], [ ALTIVEC_FOUND=1 POWER8_FOUND=1 AX_APPEND_FLAG(-mvsx, [ppc_altivec_[]_AC_LANG_ABBREV[]flags]) AX_APPEND_FLAG(-mpower8-vector, [ppc_altivec_[]_AC_LANG_ABBREV[]flags]) AC_SUBST(ppc_altivec_[]_AC_LANG_ABBREV[]flags) ], [ ALTIVEC_FOUND=0 POWER8_FOUND=0 ]) AS_VAR_POPDEF([CACHEVAR]) fi if test $IS_X86 -eq 0 then AC_CHECK_HEADERS([sys/auxv.h], [ AC_DEFINE([HAS_AUXV], [1], [Define if your system has sys/auxv.h header]) ]) fi AC_ARG_WITH(cacheline-size, [AS_HELP_STRING([--with-cacheline-size=[width]], [use specific CPU L1 cache-line size, in bytes. [default=64]])]) case $with_cacheline_size in no | "") CACHELINE_SIZE=64;; *) CACHELINE_SIZE=$with_cacheline_size;; esac AC_SUBST([CACHELINE_SIZE]) AC_DEFINE_UNQUOTED([CACHELINE_SIZE], [$CACHELINE_SIZE], [Define to set the specific CPU L1 cache-line size, in bytes.]) AC_ARG_WITH(static-simd, [AS_HELP_STRING([--with-static-simd[[=x86-sse2|x86-avx|x86-avx2|x86-avx512|ppc-altivec|ppc-power8|arm-neon|arm-asimd]], [use specific SIMD implementation at static link, [default=none]]])]) case $with_static_simd in no | "") ;; x86-sse2|x86-avx|x86-avx2|x86-avx512|ppc-altivec|ppc-power8|arm-neon|arm-asimd) SIMD_SUFFIX=_$(echo $with_static_simd | tr '[a-z]' '[A-Z]' | tr '-' '_') AC_SUBST([SIMD_SUFFIX]) case "$enable_static,$enable_shared" in "yes,yes" | "no,yes" | "no,no" ) AC_MSG_ERROR([The --with-static-simd option is only valid with static builds.]) ;; esac ;; *) AC_MSG_ERROR([Invalid SIMD given to --with-static-simd option.]) ;; esac AC_ARG_WITH(avx512, [AS_HELP_STRING([--with-avx512[[=yes|no]]], [use AVX-512F instruction set, [default=no]])]) if test $IS_X86 -eq 1 then case $with_avx512 in yes) case "$ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor" in intel) AX_APPEND_FLAG(-march=skylake-avx512, [x86_avx512_[]_AC_LANG_ABBREV[]flags]) AC_SUBST(x86_avx512_[]_AC_LANG_ABBREV[]flags) AVX512F_FOUND=1 AC_SUBST([AVX512F_FOUND], [1], [Define if your system supports AVX-512F]) ;; *) AX_CHECK_COMPILE_FLAG([-mavx512f], [ AX_APPEND_FLAG(-mavx512f, [x86_avx512_[]_AC_LANG_ABBREV[]flags]) AC_SUBST(x86_avx512_[]_AC_LANG_ABBREV[]flags) AVX512F_FOUND=1 AC_SUBST([AVX512F_FOUND], [1], [Define if your system supports AVX-512F]) ]) ;; esac AC_DEFINE_UNQUOTED([AVX512F_FOUND], [$AVX512F_FOUND], [Define to enable AVX-512F buffers.]) ;; esac case "$ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor" in intel) AX_APPEND_FLAG(-march=core-avx2, [x86_avx2_[]_AC_LANG_ABBREV[]flags]) AC_SUBST(x86_avx2_[]_AC_LANG_ABBREV[]flags) AX_APPEND_FLAG(-march=corei7-avx, [x86_avx_[]_AC_LANG_ABBREV[]flags]) AC_SUBST(x86_avx_[]_AC_LANG_ABBREV[]flags) AX_APPEND_FLAG(-march=corei7, [x86_sse2_[]_AC_LANG_ABBREV[]flags]) AC_SUBST(x86_sse2_[]_AC_LANG_ABBREV[]flags) AX_APPEND_FLAG(-march=pentiumii, [x86_mmx_[]_AC_LANG_ABBREV[]flags]) AC_SUBST(x86_mmx_[]_AC_LANG_ABBREV[]flags) ;; *) AX_CHECK_COMPILE_FLAG([-mavx2], [ AX_APPEND_FLAG(-mavx2, [x86_avx2_[]_AC_LANG_ABBREV[]flags]) AC_SUBST(x86_avx2_[]_AC_LANG_ABBREV[]flags) ]) AX_CHECK_COMPILE_FLAG([-mavx], [ AX_APPEND_FLAG(-mavx, [x86_avx_[]_AC_LANG_ABBREV[]flags]) AC_SUBST(x86_avx_[]_AC_LANG_ABBREV[]flags) ]) AX_CHECK_COMPILE_FLAG([-msse2], [ AX_APPEND_FLAG(-msse2, [x86_sse2_[]_AC_LANG_ABBREV[]flags]) AC_SUBST(x86_sse2_[]_AC_LANG_ABBREV[]flags) ]) AX_CHECK_COMPILE_FLAG([-mmmx], [ AX_APPEND_FLAG(-mmmx, [x86_mmx_[]_AC_LANG_ABBREV[]flags]) AC_SUBST(x86_mmx_[]_AC_LANG_ABBREV[]flags) ]) ;; esac fi AM_CONDITIONAL([X86], [test "$IS_X86" = 1]) AM_CONDITIONAL([ARM], [test "$IS_ARM" = 1]) AM_CONDITIONAL([PPC], [test "$IS_PPC" = 1]) AM_CONDITIONAL([NEON], [test "$NEON_FOUND" = 1]) AM_CONDITIONAL([AVX512F], [test "$AVX512F_FOUND" = 1]) AM_CONDITIONAL([ALTIVEC], [test "$ALTIVEC_FOUND" = 1]) AM_CONDITIONAL([POWER8], [test "$POWER8_FOUND" = 1]) ]) AC_DEFUN([AIRCRACK_NG_SIMD_C], [ AC_LANG_PUSH([C]) AIRCRACK_NG_SIMD AC_LANG_POP([C]) ]) AC_DEFUN([AIRCRACK_NG_SIMD_CXX], [ AC_LANG_PUSH([C++]) AIRCRACK_NG_SIMD AC_LANG_POP([C++]) ]) aircrack-ng-1.6/build/m4/aircrack_ng_sqlite.m4000066400000000000000000000045171361312141100212460ustar00rootroot00000000000000dnl Aircrack-ng dnl dnl Copyright (C) 2017 Joseph Benden dnl dnl Autotool support was written by: Joseph Benden dnl dnl This program is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by dnl the Free Software Foundation; either version 2 of the License, or dnl (at your option) any later version. dnl dnl This program is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the dnl GNU General Public License for more details. dnl dnl You should have received a copy of the GNU General Public License dnl along with this program; if not, write to the Free Software dnl Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA dnl dnl In addition, as a special exception, the copyright holders give dnl permission to link the code of portions of this program with the dnl OpenSSL library under certain conditions as described in each dnl individual source file, and distribute linked combinations dnl including the two. dnl dnl You must obey the GNU General Public License in all respects dnl for all of the code used other than OpenSSL. dnl dnl If you modify file(s) with this exception, you may extend this dnl exception to your dnl version of the file(s), but you are not obligated dnl to do so. dnl dnl If you dnl do not wish to do so, delete this exception statement from your dnl version. dnl dnl If you delete this exception statement from all source files in the dnl program, then also delete it here. AC_DEFUN([AIRCRACK_NG_SQLITE],[ AC_ARG_ENABLE(static-sqlite3, AS_HELP_STRING([--enable-static-sqlite3], [Enable statically linked SQLite3 libsqlite3.]), [static_sqlite3=$enableval], [static_sqlite3=no]) if test "x$static_sqlite3" != "xno"; then AC_REQUIRE([AX_EXT_HAVE_STATIC_LIB_DETECT]) AX_EXT_HAVE_STATIC_LIB(SQLITE3, ${DEFAULT_STATIC_LIB_SEARCH_PATHS}, sqlite3 libsqlite3, sqlite3_open, -lpthread -ldl) if test "x$SQLITE3_FOUND" = xyes; then HAVE_SQLITE3=yes fi else AX_LIB_SQLITE3 fi if test x"$HAVE_SQLITE3" = xyes; then AC_DEFINE([HAVE_SQLITE], [1], [Define if you have sqlite3]) HAVE_SQLITE3=yes else HAVE_SQLITE3=no fi AM_CONDITIONAL([HAVE_SQLITE3], [test "$HAVE_SQLITE3" = yes]) ]) aircrack-ng-1.6/build/m4/aircrack_ng_tcmalloc.m4000066400000000000000000000046541361312141100215450ustar00rootroot00000000000000dnl Aircrack-ng dnl dnl Copyright (C) 2018 Joseph Benden dnl dnl Autotool support was written by: Joseph Benden dnl dnl This program is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by dnl the Free Software Foundation; either version 2 of the License, or dnl (at your option) any later version. dnl dnl This program is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the dnl GNU General Public License for more details. dnl dnl You should have received a copy of the GNU General Public License dnl along with this program; if not, write to the Free Software dnl Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA dnl dnl In addition, as a special exception, the copyright holders give dnl permission to link the code of portions of this program with the dnl OpenSSL library under certain conditions as described in each dnl individual source file, and distribute linked combinations dnl including the two. dnl dnl You must obey the GNU General Public License in all respects dnl for all of the code used other than OpenSSL. dnl dnl If you modify file(s) with this exception, you may extend this dnl exception to your dnl version of the file(s), but you are not obligated dnl to do so. dnl dnl If you dnl do not wish to do so, delete this exception statement from your dnl version. dnl dnl If you delete this exception statement from all source files in the dnl program, then also delete it here. AC_DEFUN([AIRCRACK_NG_TCMALLOC], [ AX_REQUIRE_DEFINED([AX_COMPILER_VENDOR]) AX_REQUIRE_DEFINED([AC_CHECK_LIB]) AX_COMPILER_VENDOR AC_ARG_WITH(tcmalloc, [AS_HELP_STRING([--with-tcmalloc[[=yes|no]]], [use tcmalloc library, [default=no]])]) case $with_tcmalloc in yes) AC_CHECK_LIB([tcmalloc], [TCMallocGetenvSafe], [ LIBS="$LIBS -ltcmalloc" TCMALLOC=yes ],[ TCMALLOC=no ]) ;; *) TCMALLOC=no ;; esac case "$ax_cv_c_compiler_vendor" in clang|gnu) if test "$TCMALLOC" = yes; then CFLAGS="$CFLAGS -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free" CXXFLAGS="$CXXFLAGS -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free" fi ;; esac ]) aircrack-ng-1.6/build/m4/aircrack_ng_tsan.m4000066400000000000000000000041641361312141100207100ustar00rootroot00000000000000dnl Aircrack-ng dnl dnl Copyright (C) 2018 Joseph Benden dnl dnl Autotool support was written by: Joseph Benden dnl dnl This program is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by dnl the Free Software Foundation; either version 2 of the License, or dnl (at your option) any later version. dnl dnl This program is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the dnl GNU General Public License for more details. dnl dnl You should have received a copy of the GNU General Public License dnl along with this program; if not, write to the Free Software dnl Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA dnl dnl In addition, as a special exception, the copyright holders give dnl permission to link the code of portions of this program with the dnl OpenSSL library under certain conditions as described in each dnl individual source file, and distribute linked combinations dnl including the two. dnl dnl You must obey the GNU General Public License in all respects dnl for all of the code used other than OpenSSL. dnl dnl If you modify file(s) with this exception, you may extend this dnl exception to your dnl version of the file(s), but you are not obligated dnl to do so. dnl dnl If you dnl do not wish to do so, delete this exception statement from your dnl version. dnl dnl If you delete this exception statement from all source files in the dnl program, then also delete it here. AC_DEFUN([AIRCRACK_NG_TSAN], [ AC_ARG_ENABLE(tsan, AS_HELP_STRING([--enable-tsan], [Enable ThreadSanitizer (TSAN)]), [tsan=$enableval], [tsan=no]) if test "x$tsan" != "xno"; then # Assume both C and C++ compiler either support TSAN or not. LDFLAGS_saved="$LDFLAGS" LDFLAGS="$LDFLAGS -fsanitize=thread" AX_CHECK_COMPILE_FLAG([-fsanitize=thread], [CFLAGS="$CFLAGS -fsanitize=thread"; CXXFLAGS="$CXXFLAGS -fsanitize=thread"], [LDFLAGS="$LDFLAGS_saved"]) fi ]) aircrack-ng-1.6/build/m4/aircrack_ng_windows.m4000066400000000000000000000054331361312141100214350ustar00rootroot00000000000000dnl Aircrack-ng dnl dnl Copyright (C) 2017 Joseph Benden dnl dnl Autotool support was written by: Joseph Benden dnl dnl This program is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by dnl the Free Software Foundation; either version 2 of the License, or dnl (at your option) any later version. dnl dnl This program is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the dnl GNU General Public License for more details. dnl dnl You should have received a copy of the GNU General Public License dnl along with this program; if not, write to the Free Software dnl Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA dnl dnl In addition, as a special exception, the copyright holders give dnl permission to link the code of portions of this program with the dnl OpenSSL library under certain conditions as described in each dnl individual source file, and distribute linked combinations dnl including the two. dnl dnl You must obey the GNU General Public License in all respects dnl for all of the code used other than OpenSSL. dnl dnl If you modify file(s) with this exception, you may extend this dnl exception to your dnl version of the file(s), but you are not obligated dnl to do so. dnl dnl If you dnl do not wish to do so, delete this exception statement from your dnl version. dnl dnl If you delete this exception statement from all source files in the dnl program, then also delete it here. AC_DEFUN([AIRCRACK_NG_WINDOWS],[ AX_REQUIRE_DEFINED([AC_CHECK_HEADER])[]dnl AX_REQUIRE_DEFINED([AX_COMPILER_VENDOR])dnl AC_ARG_ENABLE(win32-portable, AS_HELP_STRING([--enable-win32-portable], [Enable portable WIN32 edition]), [ AC_DEFINE([WIN32_PORTABLE], [1], [Define if portable WIN32 is supported]) ], []) case "$host_os" in CYGWIN*|MSYS*|cygwin*|msys*) AC_CHECK_FILE(/usr/include/w32api/windows.h, [ CPPFLAGS="$CPPFLAGS -I/usr/include/w32api" ], []) AC_CHECK_LIB(w32api, WinMain, [ LIBS="$LIBS -lw32api" ]) AC_CHECK_HEADER(windows.h, [], [AC_MSG_ERROR([windows.h was not found])]) CPPFLAGS="$CPPFLAGS -DCYGWIN" CFLAGS="$CFLAGS -mconsole -mwindows" CXXFLAGS="$CXXFLAGS -mconsole -mwindows" LDFLAGS="$LDFLAGS -mconsole -mwindows" case "$host_os" in MSYS*|msys*) CPPFLAGS="$CPPFLAGS -DMSYS2" CFLAGS="$CFLAGS -DMSYS2" CXXFLAGS="$CXXFLAGS -DMSYS2" ;; esac case "$ax_cv_c_compiler_vendor" in clang) LIBS="$LIBS -liconv" ;; esac ;; esac ]) aircrack-ng-1.6/build/m4/aircrack_ng_zlib.m4000066400000000000000000000034401361312141100206770ustar00rootroot00000000000000dnl Aircrack-ng dnl dnl Copyright (C) 2017 Joseph Benden dnl dnl Autotool support was written by: Joseph Benden dnl dnl This program is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by dnl the Free Software Foundation; either version 2 of the License, or dnl (at your option) any later version. dnl dnl This program is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the dnl GNU General Public License for more details. dnl dnl You should have received a copy of the GNU General Public License dnl along with this program; if not, write to the Free Software dnl Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA dnl dnl In addition, as a special exception, the copyright holders give dnl permission to link the code of portions of this program with the dnl OpenSSL library under certain conditions as described in each dnl individual source file, and distribute linked combinations dnl including the two. dnl dnl You must obey the GNU General Public License in all respects dnl for all of the code used other than OpenSSL. dnl dnl If you modify file(s) with this exception, you may extend this dnl exception to your dnl version of the file(s), but you are not obligated dnl to do so. dnl dnl If you dnl do not wish to do so, delete this exception statement from your dnl version. dnl dnl If you delete this exception statement from all source files in the dnl program, then also delete it here. AC_DEFUN([AIRCRACK_NG_ZLIB], [ PKG_CHECK_MODULES([ZLIB], [zlib], [ HAVE_ZLIB=yes AC_DEFINE([HAVE_ZLIB], [1], [Define if you have zlib]) ], [HAVE_ZLIB=no]) ]) aircrack-ng-1.6/build/m4/ax_ac_append_to_file.m4000066400000000000000000000016221361312141100215170ustar00rootroot00000000000000# =========================================================================== # https://www.gnu.org/software/autoconf-archive/ax_ac_append_to_file.html # =========================================================================== # # SYNOPSIS # # AX_AC_APPEND_TO_FILE([FILE],[DATA]) # # DESCRIPTION # # Appends the specified data to the specified Autoconf is run. If you want # to append to a file when configure is run use AX_APPEND_TO_FILE instead. # # LICENSE # # Copyright (c) 2009 Allan Caffee # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. #serial 10 AC_DEFUN([AX_AC_APPEND_TO_FILE],[ AC_REQUIRE([AX_FILE_ESCAPES]) m4_esyscmd( AX_FILE_ESCAPES [ printf "%s" "$2" >> "$1" ]) ]) aircrack-ng-1.6/build/m4/ax_ac_print_to_file.m4000066400000000000000000000016111361312141100214020ustar00rootroot00000000000000# =========================================================================== # https://www.gnu.org/software/autoconf-archive/ax_ac_print_to_file.html # =========================================================================== # # SYNOPSIS # # AX_AC_PRINT_TO_FILE([FILE],[DATA]) # # DESCRIPTION # # Writes the specified data to the specified file when Autoconf is run. If # you want to print to a file when configure is run use AX_PRINT_TO_FILE # instead. # # LICENSE # # Copyright (c) 2009 Allan Caffee # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. #serial 10 AC_DEFUN([AX_AC_PRINT_TO_FILE],[ m4_esyscmd( AC_REQUIRE([AX_FILE_ESCAPES]) [ printf "%s" "$2" > "$1" ]) ]) aircrack-ng-1.6/build/m4/ax_add_am_macro_static.m4000066400000000000000000000015251361312141100220430ustar00rootroot00000000000000# =========================================================================== # https://www.gnu.org/software/autoconf-archive/ax_add_am_macro_static.html # =========================================================================== # # SYNOPSIS # # AX_ADD_AM_MACRO_STATIC([RULE]) # # DESCRIPTION # # Adds the specified rule to $AMINCLUDE. # # LICENSE # # Copyright (c) 2009 Tom Howard # Copyright (c) 2009 Allan Caffee # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. #serial 8 AC_DEFUN([AX_ADD_AM_MACRO_STATIC],[ AC_REQUIRE([AX_AM_MACROS_STATIC]) AX_AC_APPEND_TO_FILE(AMINCLUDE_STATIC,[$1]) ]) aircrack-ng-1.6/build/m4/ax_add_fortify_source.m4000066400000000000000000000032641361312141100217620ustar00rootroot00000000000000# =========================================================================== # https://www.gnu.org/software/autoconf-archive/ax_add_fortify_source.html # =========================================================================== # # SYNOPSIS # # AX_ADD_FORTIFY_SOURCE # # DESCRIPTION # # Check whether -D_FORTIFY_SOURCE=2 can be added to CPPFLAGS without macro # redefinition warnings. Some distributions (such as Gentoo Linux) enable # _FORTIFY_SOURCE globally in their compilers, leading to unnecessary # warnings in the form of # # :0:0: error: "_FORTIFY_SOURCE" redefined [-Werror] # : note: this is the location of the previous definition # # which is a problem if -Werror is enabled. This macro checks whether # _FORTIFY_SOURCE is already defined, and if not, adds -D_FORTIFY_SOURCE=2 # to CPPFLAGS. # # LICENSE # # Copyright (c) 2017 David Seifert # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. #serial 2 AC_DEFUN([AX_ADD_FORTIFY_SOURCE],[ AC_MSG_CHECKING([whether to add -D_FORTIFY_SOURCE=2 to CPPFLAGS]) AC_LINK_IFELSE([ AC_LANG_SOURCE( [[ int main() { #ifndef _FORTIFY_SOURCE return 0; #else this_is_an_error; #endif } ]] )], [ AC_MSG_RESULT([yes]) CPPFLAGS="$CPPFLAGS -D_FORTIFY_SOURCE=2" ], [ AC_MSG_RESULT([no]) ]) ]) aircrack-ng-1.6/build/m4/ax_am_macros_static.m4000066400000000000000000000021251361312141100214130ustar00rootroot00000000000000# =========================================================================== # https://www.gnu.org/software/autoconf-archive/ax_am_macros_static.html # =========================================================================== # # SYNOPSIS # # AX_AM_MACROS_STATIC # # DESCRIPTION # # Adds support for macros that create Automake rules. You must manually # add the following line # # include $(top_srcdir)/aminclude_static.am # # to your Makefile.am files. # # LICENSE # # Copyright (c) 2009 Tom Howard # Copyright (c) 2009 Allan Caffee # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. #serial 11 AC_DEFUN([AMINCLUDE_STATIC],[aminclude_static.am]) AC_DEFUN([AX_AM_MACROS_STATIC], [ AX_AC_PRINT_TO_FILE(AMINCLUDE_STATIC,[ # ]AMINCLUDE_STATIC[ generated automatically by Autoconf # from AX_AM_MACROS_STATIC on ]m4_esyscmd([LC_ALL=C date])[ ]) ]) aircrack-ng-1.6/build/m4/ax_append_flag.m4000066400000000000000000000053331361312141100203470ustar00rootroot00000000000000# =========================================================================== # https://www.gnu.org/software/autoconf-archive/ax_append_flag.html # =========================================================================== # # SYNOPSIS # # AX_APPEND_FLAG(FLAG, [FLAGS-VARIABLE]) # # DESCRIPTION # # FLAG is appended to the FLAGS-VARIABLE shell variable, with a space # added in between. # # If FLAGS-VARIABLE is not specified, the current language's flags (e.g. # CFLAGS) is used. FLAGS-VARIABLE is not changed if it already contains # FLAG. If FLAGS-VARIABLE is unset in the shell, it is set to exactly # FLAG. # # NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. # # LICENSE # # Copyright (c) 2008 Guido U. Draheim # Copyright (c) 2011 Maarten Bosmans # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation, either version 3 of the License, or (at your # option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program. If not, see . # # As a special exception, the respective Autoconf Macro's copyright owner # gives unlimited permission to copy, distribute and modify the configure # scripts that are the output of Autoconf when processing the Macro. You # need not follow the terms of the GNU General Public License when using # or distributing such scripts, even though portions of the text of the # Macro appear in them. The GNU General Public License (GPL) does govern # all other use of the material that constitutes the Autoconf Macro. # # This special exception to the GPL applies to versions of the Autoconf # Macro released by the Autoconf Archive. When you make and distribute a # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. #serial 7 AC_DEFUN([AX_APPEND_FLAG], [dnl AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_SET_IF AS_VAR_PUSHDEF([FLAGS], [m4_default($2,_AC_LANG_PREFIX[FLAGS])]) AS_VAR_SET_IF(FLAGS,[ AS_CASE([" AS_VAR_GET(FLAGS) "], [*" $1 "*], [AC_RUN_LOG([: FLAGS already contains $1])], [ AS_VAR_APPEND(FLAGS,[" $1"]) AC_RUN_LOG([: FLAGS="$FLAGS"]) ]) ], [ AS_VAR_SET(FLAGS,[$1]) AC_RUN_LOG([: FLAGS="$FLAGS"]) ]) AS_VAR_POPDEF([FLAGS])dnl ])dnl AX_APPEND_FLAG aircrack-ng-1.6/build/m4/ax_cflags_warn_all.m4000066400000000000000000000117031361312141100212230ustar00rootroot00000000000000# =========================================================================== # https://www.gnu.org/software/autoconf-archive/ax_cflags_warn_all.html # =========================================================================== # # SYNOPSIS # # AX_CFLAGS_WARN_ALL [(shellvar [,default, [A/NA]])] # AX_CXXFLAGS_WARN_ALL [(shellvar [,default, [A/NA]])] # AX_FCFLAGS_WARN_ALL [(shellvar [,default, [A/NA]])] # # DESCRIPTION # # Try to find a compiler option that enables most reasonable warnings. # # For the GNU compiler it will be -Wall (and -ansi -pedantic) The result # is added to the shellvar being CFLAGS, CXXFLAGS, or FCFLAGS by default. # # Currently this macro knows about the GCC, Solaris, Digital Unix, AIX, # HP-UX, IRIX, NEC SX-5 (Super-UX 10), Cray J90 (Unicos 10.0.0.8), and # Intel compilers. For a given compiler, the Fortran flags are much more # experimental than their C equivalents. # # - $1 shell-variable-to-add-to : CFLAGS, CXXFLAGS, or FCFLAGS # - $2 add-value-if-not-found : nothing # - $3 action-if-found : add value to shellvariable # - $4 action-if-not-found : nothing # # NOTE: These macros depend on AX_APPEND_FLAG. # # LICENSE # # Copyright (c) 2008 Guido U. Draheim # Copyright (c) 2010 Rhys Ulerich # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 3 of the License, or (at your # option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program. If not, see . # # As a special exception, the respective Autoconf Macro's copyright owner # gives unlimited permission to copy, distribute and modify the configure # scripts that are the output of Autoconf when processing the Macro. You # need not follow the terms of the GNU General Public License when using # or distributing such scripts, even though portions of the text of the # Macro appear in them. The GNU General Public License (GPL) does govern # all other use of the material that constitutes the Autoconf Macro. # # This special exception to the GPL applies to versions of the Autoconf # Macro released by the Autoconf Archive. When you make and distribute a # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. #serial 16 AC_DEFUN([AX_FLAGS_WARN_ALL],[dnl AS_VAR_PUSHDEF([FLAGS],[_AC_LANG_PREFIX[]FLAGS])dnl AS_VAR_PUSHDEF([VAR],[ac_cv_[]_AC_LANG_ABBREV[]flags_warn_all])dnl AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for maximum warnings], VAR,[VAR="no, unknown" ac_save_[]FLAGS="$[]FLAGS" for ac_arg dnl in "-warn all % -warn all" dnl Intel "-pedantic % -Wall" dnl GCC "-xstrconst % -v" dnl Solaris C "-std1 % -verbose -w0 -warnprotos" dnl Digital Unix "-qlanglvl=ansi % -qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd" dnl AIX "-ansi -ansiE % -fullwarn" dnl IRIX "+ESlit % +w1" dnl HP-UX C "-Xc % -pvctl[,]fullmsg" dnl NEC SX-5 (Super-UX 10) "-h conform % -h msglevel 2" dnl Cray C (Unicos) # do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'` AC_COMPILE_IFELSE([AC_LANG_PROGRAM], [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break]) done FLAGS="$ac_save_[]FLAGS" ]) AS_VAR_POPDEF([FLAGS])dnl AX_REQUIRE_DEFINED([AX_APPEND_FLAG]) case ".$VAR" in .ok|.ok,*) m4_ifvaln($3,$3) ;; .|.no|.no,*) m4_default($4,[m4_ifval($2,[AX_APPEND_FLAG([$2], [$1])])]) ;; *) m4_default($3,[AX_APPEND_FLAG([$VAR], [$1])]) ;; esac AS_VAR_POPDEF([VAR])dnl ])dnl AX_FLAGS_WARN_ALL dnl implementation tactics: dnl the for-argument contains a list of options. The first part of dnl these does only exist to detect the compiler - usually it is dnl a global option to enable -ansi or -extrawarnings. All other dnl compilers will fail about it. That was needed since a lot of dnl compilers will give false positives for some option-syntax dnl like -Woption or -Xoption as they think of it is a pass-through dnl to later compile stages or something. The "%" is used as a dnl delimiter. A non-option comment can be given after "%%" marks dnl which will be shown but not added to the respective C/CXXFLAGS. AC_DEFUN([AX_CFLAGS_WARN_ALL],[dnl AC_LANG_PUSH([C]) AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4]) AC_LANG_POP([C]) ]) AC_DEFUN([AX_CXXFLAGS_WARN_ALL],[dnl AC_LANG_PUSH([C++]) AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4]) AC_LANG_POP([C++]) ]) AC_DEFUN([AX_FCFLAGS_WARN_ALL],[dnl AC_LANG_PUSH([Fortran]) AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4]) AC_LANG_POP([Fortran]) ]) aircrack-ng-1.6/build/m4/ax_check_cflags.m4000066400000000000000000000005451361312141100205030ustar00rootroot00000000000000AC_DEFUN([AX_CHECK_CFLAGS], [ AC_MSG_CHECKING([whether compiler accepts "$1"]) cat > conftest.c++ << EOF int main(){ return 0; } EOF if $CC $CPPFLAGS $CFLAGS -o conftest.o conftest.c++ [$1] > /dev/null 2>&1 then AC_MSG_RESULT([yes]) CFLAGS="${CFLAGS} [$1]" [$2] else AC_MSG_RESULT([no]) [$3] fi ])dnl AX_CHECK_CFLAGS aircrack-ng-1.6/build/m4/ax_check_compile_flag.m4000066400000000000000000000064031361312141100216640ustar00rootroot00000000000000# =========================================================================== # https://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html # =========================================================================== # # SYNOPSIS # # AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT]) # # DESCRIPTION # # Check whether the given FLAG works with the current language's compiler # or gives an error. (Warnings, however, are ignored) # # ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on # success/failure. # # If EXTRA-FLAGS is defined, it is added to the current language's default # flags (e.g. CFLAGS) when the check is done. The check is thus made with # the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to # force the compiler to issue an error when a bad flag is given. # # INPUT gives an alternative input source to AC_COMPILE_IFELSE. # # NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this # macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG. # # LICENSE # # Copyright (c) 2008 Guido U. Draheim # Copyright (c) 2011 Maarten Bosmans # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation, either version 3 of the License, or (at your # option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program. If not, see . # # As a special exception, the respective Autoconf Macro's copyright owner # gives unlimited permission to copy, distribute and modify the configure # scripts that are the output of Autoconf when processing the Macro. You # need not follow the terms of the GNU General Public License when using # or distributing such scripts, even though portions of the text of the # Macro appear in them. The GNU General Public License (GPL) does govern # all other use of the material that constitutes the Autoconf Macro. # # This special exception to the GPL applies to versions of the Autoconf # Macro released by the Autoconf Archive. When you make and distribute a # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. #serial 5 AC_DEFUN([AX_CHECK_COMPILE_FLAG], [AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [ ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1" AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])], [AS_VAR_SET(CACHEVAR,[yes])], [AS_VAR_SET(CACHEVAR,[no])]) _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags]) AS_VAR_IF(CACHEVAR,yes, [m4_default([$2], :)], [m4_default([$3], :)]) AS_VAR_POPDEF([CACHEVAR])dnl ])dnl AX_CHECK_COMPILE_FLAGS aircrack-ng-1.6/build/m4/ax_check_gnu_make.m4000066400000000000000000000077271361312141100210430ustar00rootroot00000000000000# =========================================================================== # https://www.gnu.org/software/autoconf-archive/ax_check_gnu_make.html # =========================================================================== # # SYNOPSIS # # AX_CHECK_GNU_MAKE([run-if-true],[run-if-false]) # # DESCRIPTION # # This macro searches for a GNU version of make. If a match is found: # # * The makefile variable `ifGNUmake' is set to the empty string, otherwise # it is set to "#". This is useful for including a special features in a # Makefile, which cannot be handled by other versions of make. # * The makefile variable `ifnGNUmake' is set to #, otherwise # it is set to the empty string. This is useful for including a special # features in a Makefile, which can be handled # by other versions of make or to specify else like clause. # * The variable `_cv_gnu_make_command` is set to the command to invoke # GNU make if it exists, the empty string otherwise. # * The variable `ax_cv_gnu_make_command` is set to the command to invoke # GNU make by copying `_cv_gnu_make_command`, otherwise it is unset. # * If GNU Make is found, its version is extracted from the output of # `make --version` as the last field of a record of space-separated # columns and saved into the variable `ax_check_gnu_make_version`. # * Additionally if GNU Make is found, run shell code run-if-true # else run shell code run-if-false. # # Here is an example of its use: # # Makefile.in might contain: # # # A failsafe way of putting a dependency rule into a makefile # $(DEPEND): # $(CC) -MM $(srcdir)/*.c > $(DEPEND) # # @ifGNUmake@ ifeq ($(DEPEND),$(wildcard $(DEPEND))) # @ifGNUmake@ include $(DEPEND) # @ifGNUmake@ else # fallback code # @ifGNUmake@ endif # # Then configure.in would normally contain: # # AX_CHECK_GNU_MAKE() # AC_OUTPUT(Makefile) # # Then perhaps to cause gnu make to override any other make, we could do # something like this (note that GNU make always looks for GNUmakefile # first): # # if ! test x$_cv_gnu_make_command = x ; then # mv Makefile GNUmakefile # echo .DEFAULT: > Makefile ; # echo \ $_cv_gnu_make_command \$@ >> Makefile; # fi # # Then, if any (well almost any) other make is called, and GNU make also # exists, then the other make wraps the GNU make. # # LICENSE # # Copyright (c) 2008 John Darrington # Copyright (c) 2015 Enrico M. Crisostomo # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. #serial 12 AC_DEFUN([AX_CHECK_GNU_MAKE],dnl [AC_PROG_AWK AC_CACHE_CHECK([for GNU make],[_cv_gnu_make_command],[dnl _cv_gnu_make_command="" ; dnl Search all the common names for GNU make for a in "$MAKE" make gmake gnumake ; do if test -z "$a" ; then continue ; fi ; if "$a" --version 2> /dev/null | grep GNU 2>&1 > /dev/null ; then _cv_gnu_make_command=$a ; AX_CHECK_GNU_MAKE_HEADLINE=$("$a" --version 2> /dev/null | grep "GNU Make") ax_check_gnu_make_version=$(echo ${AX_CHECK_GNU_MAKE_HEADLINE} | ${AWK} -F " " '{ print $(NF); }') break ; fi done ;]) dnl If there was a GNU version, then set @ifGNUmake@ to the empty string, '#' otherwise AS_VAR_IF([_cv_gnu_make_command], [""], [AS_VAR_SET([ifGNUmake], ["#"])], [AS_VAR_SET([ifGNUmake], [""])]) AS_VAR_IF([_cv_gnu_make_command], [""], [AS_VAR_SET([ifnGNUmake], [""])], [AS_VAR_SET([ifnGNUmake], ["#"])]) AS_VAR_IF([_cv_gnu_make_command], [""], [AS_UNSET(ax_cv_gnu_make_command)], [AS_VAR_SET([ax_cv_gnu_make_command], [${_cv_gnu_make_command}])]) AS_VAR_IF([_cv_gnu_make_command], [""],[$2],[$1]) AC_SUBST([ifGNUmake]) AC_SUBST([ifnGNUmake]) ]) aircrack-ng-1.6/build/m4/ax_check_openssl.m4000066400000000000000000000107361361312141100207320ustar00rootroot00000000000000# =========================================================================== # https://www.gnu.org/software/autoconf-archive/ax_check_openssl.html # =========================================================================== # # SYNOPSIS # # AX_CHECK_OPENSSL([action-if-found[, action-if-not-found]]) # # DESCRIPTION # # Look for OpenSSL in a number of default spots, or in a user-selected # spot (via --with-openssl). Sets # # OPENSSL_INCLUDES to the include directives required # OPENSSL_LIBS to the -l directives required # OPENSSL_LDFLAGS to the -L or -R flags required # # and calls ACTION-IF-FOUND or ACTION-IF-NOT-FOUND appropriately # # This macro sets OPENSSL_INCLUDES such that source files should use the # openssl/ directory in include directives: # # #include # # LICENSE # # Copyright (c) 2009,2010 Zmanda Inc. # Copyright (c) 2009,2010 Dustin J. Mitchell # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. #serial 10 AU_ALIAS([CHECK_SSL], [AX_CHECK_OPENSSL]) AC_DEFUN([AX_CHECK_OPENSSL], [ found=false AC_ARG_WITH([openssl], [AS_HELP_STRING([--with-openssl=DIR], [root of the OpenSSL directory])], [ case "$withval" in "" | y | ye | yes | n | no) AC_MSG_ERROR([Invalid --with-openssl value]) ;; *) ssldirs="$withval" ;; esac ], [ AC_CHECK_LIB([crypto], [OPENSSL_init], [ OPENSSL_LIBS="-lssl -lcrypto" OPENSSL_LDFLAGS="" AC_CHECK_HEADERS([openssl/crypto.h], [ OPENSSL_INCLUDES="" found=true ]) ]) if ! $found; then # if pkg-config is installed and openssl has installed a .pc file, # then use that information and don't search ssldirs AC_CHECK_TOOL([PKG_CONFIG], [pkg-config]) if test x"$PKG_CONFIG" != x""; then OPENSSL_LDFLAGS=`$PKG_CONFIG openssl --libs-only-L 2>/dev/null` if test $? = 0; then OPENSSL_LIBS=`$PKG_CONFIG openssl --libs-only-l 2>/dev/null` OPENSSL_INCLUDES=`$PKG_CONFIG openssl --cflags-only-I 2>/dev/null` found=true fi fi fi # no such luck; use some default ssldirs if ! $found; then ssldirs="/usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr" fi ] ) # note that we #include , so the OpenSSL headers have to be in # an 'openssl' subdirectory if ! $found; then OPENSSL_INCLUDES= for ssldir in $ssldirs; do AC_MSG_CHECKING([for openssl/ssl.h in $ssldir]) if test -f "$ssldir/include/openssl/ssl.h"; then OPENSSL_INCLUDES="-I$ssldir/include" OPENSSL_LDFLAGS="-L$ssldir/lib" OPENSSL_LIBS="-lssl -lcrypto" found=true AC_MSG_RESULT([yes]) break else AC_MSG_RESULT([no]) fi done # if the file wasn't found, well, go ahead and try the link anyway -- maybe # it will just work! fi # try the preprocessor and linker with our new flags, # being careful not to pollute the global LIBS, LDFLAGS, and CPPFLAGS AC_MSG_CHECKING([whether compiling and linking against OpenSSL works]) echo "Trying link with OPENSSL_LDFLAGS=$OPENSSL_LDFLAGS;" \ "OPENSSL_LIBS=$OPENSSL_LIBS; OPENSSL_INCLUDES=$OPENSSL_INCLUDES" >&AS_MESSAGE_LOG_FD save_LIBS="$LIBS" save_LDFLAGS="$LDFLAGS" save_CPPFLAGS="$CPPFLAGS" LDFLAGS="$LDFLAGS $OPENSSL_LDFLAGS" LIBS="$OPENSSL_LIBS $LIBS" CPPFLAGS="$OPENSSL_INCLUDES $CPPFLAGS" AC_LINK_IFELSE( [AC_LANG_PROGRAM([#include ], [SSL_new(NULL)])], [ AC_MSG_RESULT([yes]) $1 ], [ AC_MSG_RESULT([no]) $2 ]) CPPFLAGS="$save_CPPFLAGS" LDFLAGS="$save_LDFLAGS" LIBS="$save_LIBS" AC_SUBST([OPENSSL_INCLUDES]) AC_SUBST([OPENSSL_LIBS]) AC_SUBST([OPENSSL_LDFLAGS]) ]) aircrack-ng-1.6/build/m4/ax_code_coverage.m4000066400000000000000000000276311361312141100207010ustar00rootroot00000000000000# =========================================================================== # https://www.gnu.org/software/autoconf-archive/ax_code_coverage.html # =========================================================================== # # SYNOPSIS # # AX_CODE_COVERAGE() # # DESCRIPTION # # Defines CODE_COVERAGE_CPPFLAGS, CODE_COVERAGE_CFLAGS, # CODE_COVERAGE_CXXFLAGS and CODE_COVERAGE_LIBS which should be included # in the CPPFLAGS, CFLAGS CXXFLAGS and LIBS/LIBADD variables of every # build target (program or library) which should be built with code # coverage support. Also add rules using AX_ADD_AM_MACRO_STATIC; and # $enable_code_coverage which can be used in subsequent configure output. # CODE_COVERAGE_ENABLED is defined and substituted, and corresponds to the # value of the --enable-code-coverage option, which defaults to being # disabled. # # Test also for gcov program and create GCOV variable that could be # substituted. # # Note that all optimization flags in CFLAGS must be disabled when code # coverage is enabled. # # Usage example: # # configure.ac: # # AX_CODE_COVERAGE # # Makefile.am: # # include $(top_srcdir)/aminclude_static.am # # my_program_LIBS = ... $(CODE_COVERAGE_LIBS) ... # my_program_CPPFLAGS = ... $(CODE_COVERAGE_CPPFLAGS) ... # my_program_CFLAGS = ... $(CODE_COVERAGE_CFLAGS) ... # my_program_CXXFLAGS = ... $(CODE_COVERAGE_CXXFLAGS) ... # # clean-local: code-coverage-clean # distclean-local: code-coverage-dist-clean # # This results in a "check-code-coverage" rule being added to any # Makefile.am which do "include $(top_srcdir)/aminclude_static.am" # (assuming the module has been configured with --enable-code-coverage). # Running `make check-code-coverage` in that directory will run the # module's test suite (`make check`) and build a code coverage report # detailing the code which was touched, then print the URI for the report. # # This code was derived from Makefile.decl in GLib, originally licensed # under LGPLv2.1+. # # LICENSE # # Copyright (c) 2012, 2016 Philip Withnall # Copyright (c) 2012 Xan Lopez # Copyright (c) 2012 Christian Persch # Copyright (c) 2012 Paolo Borelli # Copyright (c) 2012 Dan Winship # Copyright (c) 2015,2018 Bastien ROUCARIES # # This library is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or (at # your option) any later version. # # This library is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser # General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this program. If not, see . #serial 34 m4_define(_AX_CODE_COVERAGE_RULES,[ AX_ADD_AM_MACRO_STATIC([ # Code coverage # # Optional: # - CODE_COVERAGE_DIRECTORY: Top-level directory for code coverage reporting. # Multiple directories may be specified, separated by whitespace. # (Default: \$(top_builddir)) # - CODE_COVERAGE_OUTPUT_FILE: Filename and path for the .info file generated # by lcov for code coverage. (Default: # \$(PACKAGE_NAME)-\$(PACKAGE_VERSION)-coverage.info) # - CODE_COVERAGE_OUTPUT_DIRECTORY: Directory for generated code coverage # reports to be created. (Default: # \$(PACKAGE_NAME)-\$(PACKAGE_VERSION)-coverage) # - CODE_COVERAGE_BRANCH_COVERAGE: Set to 1 to enforce branch coverage, # set to 0 to disable it and leave empty to stay with the default. # (Default: empty) # - CODE_COVERAGE_LCOV_SHOPTS_DEFAULT: Extra options shared between both lcov # instances. (Default: based on $CODE_COVERAGE_BRANCH_COVERAGE) # - CODE_COVERAGE_LCOV_SHOPTS: Extra options to shared between both lcov # instances. (Default: $CODE_COVERAGE_LCOV_SHOPTS_DEFAULT) # - CODE_COVERAGE_LCOV_OPTIONS_GCOVPATH: --gcov-tool pathtogcov # - CODE_COVERAGE_LCOV_OPTIONS_DEFAULT: Extra options to pass to the # collecting lcov instance. (Default: $CODE_COVERAGE_LCOV_OPTIONS_GCOVPATH) # - CODE_COVERAGE_LCOV_OPTIONS: Extra options to pass to the collecting lcov # instance. (Default: $CODE_COVERAGE_LCOV_OPTIONS_DEFAULT) # - CODE_COVERAGE_LCOV_RMOPTS_DEFAULT: Extra options to pass to the filtering # lcov instance. (Default: empty) # - CODE_COVERAGE_LCOV_RMOPTS: Extra options to pass to the filtering lcov # instance. (Default: $CODE_COVERAGE_LCOV_RMOPTS_DEFAULT) # - CODE_COVERAGE_GENHTML_OPTIONS_DEFAULT: Extra options to pass to the # genhtml instance. (Default: based on $CODE_COVERAGE_BRANCH_COVERAGE) # - CODE_COVERAGE_GENHTML_OPTIONS: Extra options to pass to the genhtml # instance. (Default: $CODE_COVERAGE_GENHTML_OPTIONS_DEFAULT) # - CODE_COVERAGE_IGNORE_PATTERN: Extra glob pattern of files to ignore # # The generated report will be titled using the \$(PACKAGE_NAME) and # \$(PACKAGE_VERSION). In order to add the current git hash to the title, # use the git-version-gen script, available online. # Optional variables # run only on top dir if CODE_COVERAGE_ENABLED ifeq (\$(abs_builddir), \$(abs_top_builddir)) CODE_COVERAGE_DIRECTORY ?= \$(top_builddir) CODE_COVERAGE_OUTPUT_FILE ?= \$(abs_builddir)/\$(PACKAGE_NAME)-\$(PACKAGE_VERSION)-coverage.info CODE_COVERAGE_OUTPUT_DIRECTORY ?= \$(PACKAGE_NAME)-\$(PACKAGE_VERSION)-coverage CODE_COVERAGE_BRANCH_COVERAGE ?= 1 CODE_COVERAGE_LCOV_SHOPTS_DEFAULT ?= \$(if \$(CODE_COVERAGE_BRANCH_COVERAGE),\ --rc lcov_branch_coverage=\$(CODE_COVERAGE_BRANCH_COVERAGE)) CODE_COVERAGE_LCOV_SHOPTS ?= \$(CODE_COVERAGE_LCOV_SHOPTS_DEFAULT) CODE_COVERAGE_LCOV_OPTIONS_GCOVPATH ?= --gcov-tool \"\$(GCOV)\" CODE_COVERAGE_LCOV_OPTIONS_DEFAULT ?= \$(CODE_COVERAGE_LCOV_OPTIONS_GCOVPATH) CODE_COVERAGE_LCOV_OPTIONS ?= \$(CODE_COVERAGE_LCOV_OPTIONS_DEFAULT) CODE_COVERAGE_LCOV_RMOPTS_DEFAULT ?= CODE_COVERAGE_LCOV_RMOPTS ?= \$(CODE_COVERAGE_LCOV_RMOPTS_DEFAULT) CODE_COVERAGE_GENHTML_OPTIONS_DEFAULT ?=\ \$(if \$(CODE_COVERAGE_BRANCH_COVERAGE),\ --rc genhtml_branch_coverage=\$(CODE_COVERAGE_BRANCH_COVERAGE)) CODE_COVERAGE_GENHTML_OPTIONS ?= \$(CODE_COVERAGE_GENHTML_OPTIONS_DEFAULT) CODE_COVERAGE_IGNORE_PATTERN ?= GITIGNOREFILES := \$(GITIGNOREFILES) \$(CODE_COVERAGE_OUTPUT_FILE) \$(CODE_COVERAGE_OUTPUT_DIRECTORY) code_coverage_v_lcov_cap = \$(code_coverage_v_lcov_cap_\$(V)) code_coverage_v_lcov_cap_ = \$(code_coverage_v_lcov_cap_\$(AM_DEFAULT_VERBOSITY)) code_coverage_v_lcov_cap_0 = @echo \" LCOV --capture\" \$(CODE_COVERAGE_OUTPUT_FILE); code_coverage_v_lcov_ign = \$(code_coverage_v_lcov_ign_\$(V)) code_coverage_v_lcov_ign_ = \$(code_coverage_v_lcov_ign_\$(AM_DEFAULT_VERBOSITY)) code_coverage_v_lcov_ign_0 = @echo \" LCOV --remove /tmp/*\" \$(CODE_COVERAGE_IGNORE_PATTERN); code_coverage_v_genhtml = \$(code_coverage_v_genhtml_\$(V)) code_coverage_v_genhtml_ = \$(code_coverage_v_genhtml_\$(AM_DEFAULT_VERBOSITY)) code_coverage_v_genhtml_0 = @echo \" GEN \" \"\$(CODE_COVERAGE_OUTPUT_DIRECTORY)\"; code_coverage_quiet = \$(code_coverage_quiet_\$(V)) code_coverage_quiet_ = \$(code_coverage_quiet_\$(AM_DEFAULT_VERBOSITY)) code_coverage_quiet_0 = --quiet # sanitizes the test-name: replaces with underscores: dashes and dots code_coverage_sanitize = \$(subst -,_,\$(subst .,_,\$(1))) # Use recursive makes in order to ignore errors during check check-code-coverage: -\$(AM_V_at)\$(MAKE) \$(AM_MAKEFLAGS) -k check \$(AM_V_at)\$(MAKE) \$(AM_MAKEFLAGS) code-coverage-capture # Capture code coverage data code-coverage-capture: code-coverage-capture-hook \$(code_coverage_v_lcov_cap)\$(LCOV) \$(code_coverage_quiet) \$(addprefix --directory ,\$(CODE_COVERAGE_DIRECTORY)) --capture --output-file \"\$(CODE_COVERAGE_OUTPUT_FILE).tmp\" --test-name \"\$(call code_coverage_sanitize,\$(PACKAGE_NAME)-\$(PACKAGE_VERSION))\" --no-checksum --compat-libtool \$(CODE_COVERAGE_LCOV_SHOPTS) \$(CODE_COVERAGE_LCOV_OPTIONS) \$(code_coverage_v_lcov_ign)\$(LCOV) \$(code_coverage_quiet) \$(addprefix --directory ,\$(CODE_COVERAGE_DIRECTORY)) --remove \"\$(CODE_COVERAGE_OUTPUT_FILE).tmp\" \"/tmp/*\" \$(CODE_COVERAGE_IGNORE_PATTERN) --output-file \"\$(CODE_COVERAGE_OUTPUT_FILE)\" \$(CODE_COVERAGE_LCOV_SHOPTS) \$(CODE_COVERAGE_LCOV_RMOPTS) -@rm -f \"\$(CODE_COVERAGE_OUTPUT_FILE).tmp\" \$(code_coverage_v_genhtml)LANG=C \$(GENHTML) \$(code_coverage_quiet) \$(addprefix --prefix ,\$(CODE_COVERAGE_DIRECTORY)) --output-directory \"\$(CODE_COVERAGE_OUTPUT_DIRECTORY)\" --title \"\$(PACKAGE_NAME)-\$(PACKAGE_VERSION) Code Coverage\" --legend --show-details \"\$(CODE_COVERAGE_OUTPUT_FILE)\" \$(CODE_COVERAGE_GENHTML_OPTIONS) @echo \"file://\$(abs_builddir)/\$(CODE_COVERAGE_OUTPUT_DIRECTORY)/index.html\" code-coverage-clean: -\$(LCOV) --directory \$(top_builddir) -z -rm -rf \"\$(CODE_COVERAGE_OUTPUT_FILE)\" \"\$(CODE_COVERAGE_OUTPUT_FILE).tmp\" \"\$(CODE_COVERAGE_OUTPUT_DIRECTORY)\" -find . \\( -name \"*.gcda\" -o -name \"*.gcno\" -o -name \"*.gcov\" \\) -delete code-coverage-dist-clean: A][M_DISTCHECK_CONFIGURE_FLAGS := \$(A][M_DISTCHECK_CONFIGURE_FLAGS) --disable-code-coverage else # ifneq (\$(abs_builddir), \$(abs_top_builddir)) check-code-coverage: code-coverage-capture: code-coverage-capture-hook code-coverage-clean: code-coverage-dist-clean: endif # ifeq (\$(abs_builddir), \$(abs_top_builddir)) else #! CODE_COVERAGE_ENABLED # Use recursive makes in order to ignore errors during check check-code-coverage: @echo \"Need to reconfigure with --enable-code-coverage\" # Capture code coverage data code-coverage-capture: code-coverage-capture-hook @echo \"Need to reconfigure with --enable-code-coverage\" code-coverage-clean: code-coverage-dist-clean: endif #CODE_COVERAGE_ENABLED # Hook rule executed before code-coverage-capture, overridable by the user code-coverage-capture-hook: .PHONY: check-code-coverage code-coverage-capture code-coverage-dist-clean code-coverage-clean code-coverage-capture-hook ]) ]) AC_DEFUN([_AX_CODE_COVERAGE_ENABLED],[ AX_CHECK_GNU_MAKE([],[AC_MSG_ERROR([not using GNU make that is needed for coverage])]) AC_REQUIRE([AX_ADD_AM_MACRO_STATIC]) # check for gcov AC_CHECK_TOOL([GCOV], [$_AX_CODE_COVERAGE_GCOV_PROG_WITH], [:]) AS_IF([test "X$GCOV" = "X:"], [AC_MSG_ERROR([gcov is needed to do coverage])]) AC_SUBST([GCOV]) dnl Check if gcc is being used AS_IF([ test "$GCC" = "no" ], [ AC_MSG_ERROR([not compiling with gcc, which is required for gcov code coverage]) ]) AC_CHECK_PROG([LCOV], [lcov], [lcov]) AC_CHECK_PROG([GENHTML], [genhtml], [genhtml]) AS_IF([ test x"$LCOV" = x ], [ AC_MSG_ERROR([To enable code coverage reporting you must have lcov installed]) ]) AS_IF([ test x"$GENHTML" = x ], [ AC_MSG_ERROR([Could not find genhtml from the lcov package]) ]) dnl Build the code coverage flags dnl Define CODE_COVERAGE_LDFLAGS for backwards compatibility CODE_COVERAGE_CPPFLAGS="" CODE_COVERAGE_CFLAGS="-O0 -g -fprofile-arcs -ftest-coverage" CODE_COVERAGE_CXXFLAGS="-O0 -g -fprofile-arcs -ftest-coverage" CODE_COVERAGE_LIBS="-lgcov" AC_SUBST([CODE_COVERAGE_CPPFLAGS]) AC_SUBST([CODE_COVERAGE_CFLAGS]) AC_SUBST([CODE_COVERAGE_CXXFLAGS]) AC_SUBST([CODE_COVERAGE_LIBS]) ]) AC_DEFUN([AX_CODE_COVERAGE],[ dnl Check for --enable-code-coverage # allow to override gcov location AC_ARG_WITH([gcov], [AS_HELP_STRING([--with-gcov[=GCOV]], [use given GCOV for coverage (GCOV=gcov).])], [_AX_CODE_COVERAGE_GCOV_PROG_WITH=$with_gcov], [_AX_CODE_COVERAGE_GCOV_PROG_WITH=gcov]) AC_MSG_CHECKING([whether to build with code coverage support]) AC_ARG_ENABLE([code-coverage], AS_HELP_STRING([--enable-code-coverage], [Whether to enable code coverage support]),, enable_code_coverage=no) AM_CONDITIONAL([CODE_COVERAGE_ENABLED], [test "x$enable_code_coverage" = xyes]) AC_SUBST([CODE_COVERAGE_ENABLED], [$enable_code_coverage]) AC_MSG_RESULT($enable_code_coverage) AS_IF([ test "x$enable_code_coverage" = xyes ], [ _AX_CODE_COVERAGE_ENABLED ]) _AX_CODE_COVERAGE_RULES ]) aircrack-ng-1.6/build/m4/ax_compare_version.m4000066400000000000000000000146721361312141100213100ustar00rootroot00000000000000# =========================================================================== # https://www.gnu.org/software/autoconf-archive/ax_compare_version.html # =========================================================================== # # SYNOPSIS # # AX_COMPARE_VERSION(VERSION_A, OP, VERSION_B, [ACTION-IF-TRUE], [ACTION-IF-FALSE]) # # DESCRIPTION # # This macro compares two version strings. Due to the various number of # minor-version numbers that can exist, and the fact that string # comparisons are not compatible with numeric comparisons, this is not # necessarily trivial to do in a autoconf script. This macro makes doing # these comparisons easy. # # The six basic comparisons are available, as well as checking equality # limited to a certain number of minor-version levels. # # The operator OP determines what type of comparison to do, and can be one # of: # # eq - equal (test A == B) # ne - not equal (test A != B) # le - less than or equal (test A <= B) # ge - greater than or equal (test A >= B) # lt - less than (test A < B) # gt - greater than (test A > B) # # Additionally, the eq and ne operator can have a number after it to limit # the test to that number of minor versions. # # eq0 - equal up to the length of the shorter version # ne0 - not equal up to the length of the shorter version # eqN - equal up to N sub-version levels # neN - not equal up to N sub-version levels # # When the condition is true, shell commands ACTION-IF-TRUE are run, # otherwise shell commands ACTION-IF-FALSE are run. The environment # variable 'ax_compare_version' is always set to either 'true' or 'false' # as well. # # Examples: # # AX_COMPARE_VERSION([3.15.7],[lt],[3.15.8]) # AX_COMPARE_VERSION([3.15],[lt],[3.15.8]) # # would both be true. # # AX_COMPARE_VERSION([3.15.7],[eq],[3.15.8]) # AX_COMPARE_VERSION([3.15],[gt],[3.15.8]) # # would both be false. # # AX_COMPARE_VERSION([3.15.7],[eq2],[3.15.8]) # # would be true because it is only comparing two minor versions. # # AX_COMPARE_VERSION([3.15.7],[eq0],[3.15]) # # would be true because it is only comparing the lesser number of minor # versions of the two values. # # Note: The characters that separate the version numbers do not matter. An # empty string is the same as version 0. OP is evaluated by autoconf, not # configure, so must be a string, not a variable. # # The author would like to acknowledge Guido Draheim whose advice about # the m4_case and m4_ifvaln functions make this macro only include the # portions necessary to perform the specific comparison specified by the # OP argument in the final configure script. # # LICENSE # # Copyright (c) 2008 Tim Toolan # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. #serial 13 dnl ######################################################################### AC_DEFUN([AX_COMPARE_VERSION], [ AC_REQUIRE([AC_PROG_AWK]) # Used to indicate true or false condition ax_compare_version=false # Convert the two version strings to be compared into a format that # allows a simple string comparison. The end result is that a version # string of the form 1.12.5-r617 will be converted to the form # 0001001200050617. In other words, each number is zero padded to four # digits, and non digits are removed. AS_VAR_PUSHDEF([A],[ax_compare_version_A]) A=`echo "$1" | sed -e 's/\([[0-9]]*\)/Z\1Z/g' \ -e 's/Z\([[0-9]]\)Z/Z0\1Z/g' \ -e 's/Z\([[0-9]][[0-9]]\)Z/Z0\1Z/g' \ -e 's/Z\([[0-9]][[0-9]][[0-9]]\)Z/Z0\1Z/g' \ -e 's/[[^0-9]]//g'` AS_VAR_PUSHDEF([B],[ax_compare_version_B]) B=`echo "$3" | sed -e 's/\([[0-9]]*\)/Z\1Z/g' \ -e 's/Z\([[0-9]]\)Z/Z0\1Z/g' \ -e 's/Z\([[0-9]][[0-9]]\)Z/Z0\1Z/g' \ -e 's/Z\([[0-9]][[0-9]][[0-9]]\)Z/Z0\1Z/g' \ -e 's/[[^0-9]]//g'` dnl # In the case of le, ge, lt, and gt, the strings are sorted as necessary dnl # then the first line is used to determine if the condition is true. dnl # The sed right after the echo is to remove any indented white space m4_case(m4_tolower($2), [lt],[ ax_compare_version=`echo "x$A x$B" | sed 's/^ *//' | sort -r | sed "s/x${A}/false/;s/x${B}/true/;1q"` ], [gt],[ ax_compare_version=`echo "x$A x$B" | sed 's/^ *//' | sort | sed "s/x${A}/false/;s/x${B}/true/;1q"` ], [le],[ ax_compare_version=`echo "x$A x$B" | sed 's/^ *//' | sort | sed "s/x${A}/true/;s/x${B}/false/;1q"` ], [ge],[ ax_compare_version=`echo "x$A x$B" | sed 's/^ *//' | sort -r | sed "s/x${A}/true/;s/x${B}/false/;1q"` ],[ dnl Split the operator from the subversion count if present. m4_bmatch(m4_substr($2,2), [0],[ # A count of zero means use the length of the shorter version. # Determine the number of characters in A and B. ax_compare_version_len_A=`echo "$A" | $AWK '{print(length)}'` ax_compare_version_len_B=`echo "$B" | $AWK '{print(length)}'` # Set A to no more than B's length and B to no more than A's length. A=`echo "$A" | sed "s/\(.\{$ax_compare_version_len_B\}\).*/\1/"` B=`echo "$B" | sed "s/\(.\{$ax_compare_version_len_A\}\).*/\1/"` ], [[0-9]+],[ # A count greater than zero means use only that many subversions A=`echo "$A" | sed "s/\(\([[0-9]]\{4\}\)\{m4_substr($2,2)\}\).*/\1/"` B=`echo "$B" | sed "s/\(\([[0-9]]\{4\}\)\{m4_substr($2,2)\}\).*/\1/"` ], [.+],[ AC_WARNING( [invalid OP numeric parameter: $2]) ],[]) # Pad zeros at end of numbers to make same length. ax_compare_version_tmp_A="$A`echo $B | sed 's/./0/g'`" B="$B`echo $A | sed 's/./0/g'`" A="$ax_compare_version_tmp_A" # Check for equality or inequality as necessary. m4_case(m4_tolower(m4_substr($2,0,2)), [eq],[ test "x$A" = "x$B" && ax_compare_version=true ], [ne],[ test "x$A" != "x$B" && ax_compare_version=true ], [],[ ],[ AC_WARNING([invalid OP parameter: $2]) ]) ]) AS_VAR_POPDEF([A])dnl AS_VAR_POPDEF([B])dnl dnl # Execute ACTION-IF-TRUE / ACTION-IF-FALSE. if test "$ax_compare_version" = "true" ; then m4_ifvaln([$4],[$4],[:])dnl m4_ifvaln([$5],[else $5])dnl fi ]) dnl AX_COMPARE_VERSION aircrack-ng-1.6/build/m4/ax_compiler_vendor.m4000066400000000000000000000070261361312141100212770ustar00rootroot00000000000000# =========================================================================== # https://www.gnu.org/software/autoconf-archive/ax_compiler_vendor.html # =========================================================================== # # SYNOPSIS # # AX_COMPILER_VENDOR # # DESCRIPTION # # Determine the vendor of the C/C++ compiler, e.g., gnu, intel, ibm, sun, # hp, borland, comeau, dec, cray, kai, lcc, metrowerks, sgi, microsoft, # watcom, etc. The vendor is returned in the cache variable # $ax_cv_c_compiler_vendor for C and $ax_cv_cxx_compiler_vendor for C++. # # LICENSE # # Copyright (c) 2008 Steven G. Johnson # Copyright (c) 2008 Matteo Frigo # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation, either version 3 of the License, or (at your # option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program. If not, see . # # As a special exception, the respective Autoconf Macro's copyright owner # gives unlimited permission to copy, distribute and modify the configure # scripts that are the output of Autoconf when processing the Macro. You # need not follow the terms of the GNU General Public License when using # or distributing such scripts, even though portions of the text of the # Macro appear in them. The GNU General Public License (GPL) does govern # all other use of the material that constitutes the Autoconf Macro. # # This special exception to the GPL applies to versions of the Autoconf # Macro released by the Autoconf Archive. When you make and distribute a # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. #serial 16 AC_DEFUN([AX_COMPILER_VENDOR], [AC_CACHE_CHECK([for _AC_LANG compiler vendor], ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor, dnl Please add if possible support to ax_compiler_version.m4 [# note: don't check for gcc first since some other compilers define __GNUC__ vendors="intel: __ICC,__ECC,__INTEL_COMPILER ibm: __xlc__,__xlC__,__IBMC__,__IBMCPP__ pathscale: __PATHCC__,__PATHSCALE__ clang: __clang__ cray: _CRAYC fujitsu: __FUJITSU gnu: __GNUC__ sun: __SUNPRO_C,__SUNPRO_CC hp: __HP_cc,__HP_aCC dec: __DECC,__DECCXX,__DECC_VER,__DECCXX_VER borland: __BORLANDC__,__CODEGEARC__,__TURBOC__ comeau: __COMO__ kai: __KCC lcc: __LCC__ sgi: __sgi,sgi microsoft: _MSC_VER metrowerks: __MWERKS__ watcom: __WATCOMC__ portland: __PGI tcc: __TINYC__ unknown: UNKNOWN" for ventest in $vendors; do case $ventest in *:) vendor=$ventest; continue ;; *) vencpp="defined("`echo $ventest | sed 's/,/) || defined(/g'`")" ;; esac AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[ #if !($vencpp) thisisanerror; #endif ])], [break]) done ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor=`echo $vendor | cut -d: -f1` ]) ]) aircrack-ng-1.6/build/m4/ax_compiler_version.m4000066400000000000000000000523531361312141100214720ustar00rootroot00000000000000# =========================================================================== # https://www.gnu.org/software/autoconf-archive/ax_compiler_version.html # =========================================================================== # # SYNOPSIS # # AX_COMPILER_VERSION # # DESCRIPTION # # This macro retrieves the compiler version and returns it in the cache # variable $ax_cv_c_compiler_version for C and $ax_cv_cxx_compiler_version # for C++. # # Version is returned as epoch:major.minor.patchversion # # Epoch is used in order to have an increasing version number in case of # marketing change. # # Epoch use: * borland compiler use chronologically 0turboc for turboc # era, # # 1borlanc BORLANDC++ before 5, 2cppbuilder for cppbuilder era, # 3borlancpp for return of BORLANDC++ (after version 5.5), # 4cppbuilder for cppbuilder with year version, # and 5xe for XE era. # # An empty string is returned otherwise. # # LICENSE # # Copyright (c) 2014 Bastien ROUCARIES # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. #serial 9 # for intel AC_DEFUN([_AX_COMPILER_VERSION_INTEL], [ dnl AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, [__INTEL_COMPILER/100],, AC_MSG_FAILURE([[[$0]] unknown intel compiler version])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, [(__INTEL_COMPILER%100)/10],, AC_MSG_FAILURE([[[$0]] unknown intel compiler version])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, [(__INTEL_COMPILER%10)],, AC_MSG_FAILURE([[[$0]] unknown intel compiler version])) ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" ]) # for IBM AC_DEFUN([_AX_COMPILER_VERSION_IBM], [ dnl dnl check between z/OS C/C++ and XL C/C++ AC_COMPILE_IFELSE([ AC_LANG_PROGRAM([], [ #if defined(__COMPILER_VER__) choke me; #endif ])], [ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, [__xlC__/100],, AC_MSG_FAILURE([[[$0]] unknown IBM compiler major version])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, [__xlC__%100],, AC_MSG_FAILURE([[[$0]] unknown IBM compiler minor version])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, [__xlC_ver__/0x100],, AC_MSG_FAILURE([[[$0]] unknown IBM compiler patch version])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_build, [__xlC_ver__%0x100],, AC_MSG_FAILURE([[[$0]] unknown IBM compiler build version])) ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_build" ], [ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, [__xlC__%1000],, AC_MSG_FAILURE([[[$0]] unknown IBM compiler patch version])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, [(__xlC__/10000)%10],, AC_MSG_FAILURE([[[$0]] unknown IBM compiler minor version])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, [(__xlC__/100000)%10],, AC_MSG_FAILURE([[[$0]] unknown IBM compiler major version])) ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" ]) ]) # for pathscale AC_DEFUN([_AX_COMPILER_VERSION_PATHSCALE],[ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, __PATHCC__,, AC_MSG_FAILURE([[[$0]] unknown pathscale major])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, __PATHCC_MINOR__,, AC_MSG_FAILURE([[[$0]] unknown pathscale minor])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, [__PATHCC_PATCHLEVEL__],, AC_MSG_FAILURE([[[$0]] unknown pathscale patch level])) ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" ]) # for clang AC_DEFUN([_AX_COMPILER_VERSION_CLANG],[ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, __clang_major__,, AC_MSG_FAILURE([[[$0]] unknown clang major])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, __clang_minor__,, AC_MSG_FAILURE([[[$0]] unknown clang minor])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, [__clang_patchlevel__],,0) ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" ]) # for crayc AC_DEFUN([_AX_COMPILER_VERSION_CRAY],[ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, _RELEASE,, AC_MSG_FAILURE([[[$0]] unknown crayc release])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, _RELEASE_MINOR,, AC_MSG_FAILURE([[[$0]] unknown crayc minor])) ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor" ]) # for fujitsu AC_DEFUN([_AX_COMPILER_VERSION_FUJITSU],[ AC_COMPUTE_INT(ax_cv_[]_AC_LANG_ABBREV[]_compiler_version, __FCC_VERSION,, AC_MSG_FAILURE([[[$0]]unknown fujitsu release])) ]) # for GNU AC_DEFUN([_AX_COMPILER_VERSION_GNU],[ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, __GNUC__,, AC_MSG_FAILURE([[[$0]] unknown gcc major])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, __GNUC_MINOR__,, AC_MSG_FAILURE([[[$0]] unknown gcc minor])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, [__GNUC_PATCHLEVEL__],, AC_MSG_FAILURE([[[$0]] unknown gcc patch level])) ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" ]) # For sun AC_DEFUN([_AX_COMPILER_VERSION_SUN],[ m4_define([_AX_COMPILER_VERSION_SUN_NUMBER], [ #if defined(__SUNPRO_CC) __SUNPRO_CC #else __SUNPRO_C #endif ]) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_until59, !!(_AX_COMPILER_VERSION_SUN_NUMBER < 0x1000),, AC_MSG_FAILURE([[[$0]] unknown sun release version])) AS_IF([test "X$_ax_[]_AC_LANG_ABBREV[]_compiler_version_until59" = X1], [dnl AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, _AX_COMPILER_VERSION_SUN_NUMBER % 0x10,, AC_MSG_FAILURE([[[$0]] unknown sun patch version])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, (_AX_COMPILER_VERSION_SUN_NUMBER / 0x10) % 0x10,, AC_MSG_FAILURE([[[$0]] unknown sun minor version])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, (_AX_COMPILER_VERSION_SUN_NUMBER / 0x100),, AC_MSG_FAILURE([[[$0]] unknown sun major version])) ], [dnl AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, _AX_COMPILER_VERSION_SUN_NUMBER % 0x10,, AC_MSG_FAILURE([[[$0]] unknown sun patch version])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, (_AX_COMPILER_VERSION_SUN_NUMBER / 0x100) % 0x100,, AC_MSG_FAILURE([[[$0]] unknown sun minor version])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, (_AX_COMPILER_VERSION_SUN_NUMBER / 0x1000),, AC_MSG_FAILURE([[[$0]] unknown sun major version])) ]) ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" ]) AC_DEFUN([_AX_COMPILER_VERSION_HP],[ m4_define([_AX_COMPILER_VERSION_HP_NUMBER], [ #if defined(__HP_cc) __HP_cc #else __HP_aCC #endif ]) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_untilA0121, !!(_AX_COMPILER_VERSION_HP_NUMBER <= 1),, AC_MSG_FAILURE([[[$0]] unknown hp release version])) AS_IF([test "X$_ax_[]_AC_LANG_ABBREV[]_compiler_version_untilA0121" = X1], [dnl By default output last version with this behavior. dnl it is so old ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="01.21.00" ], [dnl AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, (_AX_COMPILER_VERSION_HP_NUMBER % 100),, AC_MSG_FAILURE([[[$0]] unknown hp release version])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, ((_AX_COMPILER_VERSION_HP_NUMBER / 100)%100),, AC_MSG_FAILURE([[[$0]] unknown hp minor version])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, ((_AX_COMPILER_VERSION_HP_NUMBER / 10000)%100),, AC_MSG_FAILURE([[[$0]] unknown hp major version])) ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" ]) ]) AC_DEFUN([_AX_COMPILER_VERSION_DEC],[dnl m4_define([_AX_COMPILER_VERSION_DEC_NUMBER], [ #if defined(__DECC_VER) __DECC_VER #else __DECCXX_VER #endif ]) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, (_AX_COMPILER_VERSION_DEC_NUMBER % 10000),, AC_MSG_FAILURE([[[$0]] unknown dec release version])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, ((_AX_COMPILER_VERSION_DEC_NUMBER / 100000UL)%100),, AC_MSG_FAILURE([[[$0]] unknown dec minor version])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, ((_AX_COMPILER_VERSION_DEC_NUMBER / 10000000UL)%100),, AC_MSG_FAILURE([[[$0]] unknown dec major version])) ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" ]) # borland AC_DEFUN([_AX_COMPILER_VERSION_BORLAND],[dnl m4_define([_AX_COMPILER_VERSION_TURBOC_NUMBER], [ #if defined(__TURBOC__) __TURBOC__ #else choke me #endif ]) m4_define([_AX_COMPILER_VERSION_BORLANDC_NUMBER], [ #if defined(__BORLANDC__) __BORLANDC__ #else __CODEGEARC__ #endif ]) AC_COMPILE_IFELSE( [AC_LANG_PROGRAM(, _AX_COMPILER_VERSION_TURBOC_NUMBER)], [dnl TURBOC AC_COMPUTE_INT( _ax_[]_AC_LANG_ABBREV[]_compiler_version_turboc_raw, _AX_COMPILER_VERSION_TURBOC_NUMBER,, AC_MSG_FAILURE([[[$0]] unknown turboc version])) AS_IF( [test $_ax_[]_AC_LANG_ABBREV[]_compiler_version_turboc_raw -lt 661 || test $_ax_[]_AC_LANG_ABBREV[]_compiler_version_turboc_raw -gt 1023], [dnl compute normal version AC_COMPUTE_INT( _ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, _AX_COMPILER_VERSION_TURBOC_NUMBER % 0x100,, AC_MSG_FAILURE([[[$0]] unknown turboc minor version])) AC_COMPUTE_INT( _ax_[]_AC_LANG_ABBREV[]_compiler_version_major, (_AX_COMPILER_VERSION_TURBOC_NUMBER/0x100)%0x100,, AC_MSG_FAILURE([[[$0]] unknown turboc major version])) ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="0turboc:$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor"], [dnl special version AS_CASE([$_ax_[]_AC_LANG_ABBREV[]_compiler_version_turboc_raw], [661],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="0turboc:1.00"], [662],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="0turboc:1.01"], [663],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="0turboc:2.00"], [ AC_MSG_WARN([[[$0]] unknown turboc version between 0x295 and 0x400 please report bug]) ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="" ]) ]) ], # borlandc [ AC_COMPUTE_INT( _ax_[]_AC_LANG_ABBREV[]_compiler_version_borlandc_raw, _AX_COMPILER_VERSION_BORLANDC_NUMBER,, AC_MSG_FAILURE([[[$0]] unknown borlandc version])) AS_CASE([$_ax_[]_AC_LANG_ABBREV[]_compiler_version_borlandc_raw], dnl BORLANDC++ before 5.5 [512] ,[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="1borlanc:2.00"], [1024],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="1borlanc:3.00"], [1024],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="1borlanc:3.00"], [1040],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="1borlanc:3.1"], [1106],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="1borlanc:4.0"], [1280],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="1borlanc:5.0"], [1312],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="1borlanc:5.02"], dnl C++ Builder era [1328],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="2cppbuilder:3.0"], [1344],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="2cppbuilder:4.0"], dnl BORLANDC++ after 5.5 [1360],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="3borlancpp:5.5"], [1361],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="3borlancpp:5.51"], [1378],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="3borlancpp:5.6.4"], dnl C++ Builder with year number [1392],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="4cppbuilder:2006"], [1424],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="4cppbuilder:2007"], [1555],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="4cppbuilder:2009"], [1569],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="4cppbuilder:2010"], dnl XE version [1584],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="5xe"], [1600],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="5xe:2"], [1616],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="5xe:3"], [1632],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="5xe:4"], [ AC_MSG_WARN([[[$0]] Unknown borlandc compiler version $_ax_[]_AC_LANG_ABBREV[]_compiler_version_borlandc_raw please report bug]) ]) ]) ]) # COMO AC_DEFUN([_AX_COMPILER_VERSION_COMEAU], [ dnl AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, [__COMO_VERSION__%100],, AC_MSG_FAILURE([[[$0]] unknown comeau compiler minor version])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, [(__COMO_VERSION__/100)%10],, AC_MSG_FAILURE([[[$0]] unknown comeau compiler major version])) ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor" ]) # KAI AC_DEFUN([_AX_COMPILER_VERSION_KAI],[ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, [__KCC_VERSION%100],, AC_MSG_FAILURE([[[$0]] unknown kay compiler patch version])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, [(__KCC_VERSION/100)%10],, AC_MSG_FAILURE([[[$0]] unknown kay compiler minor version])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, [(__KCC_VERSION/1000)%10],, AC_MSG_FAILURE([[[$0]] unknown kay compiler major version])) ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" ]) dnl LCC dnl LCC does not output version... # SGI AC_DEFUN([_AX_COMPILER_VERSION_SGI],[ m4_define([_AX_COMPILER_VERSION_SGI_NUMBER], [ #if defined(_COMPILER_VERSION) _COMPILER_VERSION #else _SGI_COMPILER_VERSION #endif ]) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, [_AX_COMPILER_VERSION_SGI_NUMBER%10],, AC_MSG_FAILURE([[[$0]] unknown SGI compiler patch version])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, [(_AX_COMPILER_VERSION_SGI_NUMBER/10)%10],, AC_MSG_FAILURE([[[$0]] unknown SGI compiler minor version])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, [(_AX_COMPILER_VERSION_SGI_NUMBER/100)%10],, AC_MSG_FAILURE([[[$0]] unknown SGI compiler major version])) ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" ]) # microsoft AC_DEFUN([_AX_COMPILER_VERSION_MICROSOFT],[ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, _MSC_VER%100,, AC_MSG_FAILURE([[[$0]] unknown microsoft compiler minor version])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, (_MSC_VER/100)%100,, AC_MSG_FAILURE([[[$0]] unknown microsoft compiler major version])) dnl could be overridden _ax_[]_AC_LANG_ABBREV[]_compiler_version_patch=0 _ax_[]_AC_LANG_ABBREV[]_compiler_version_build=0 # special case for version 6 AS_IF([test "X$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major" = "X12"], [AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, _MSC_FULL_VER%1000,, _ax_[]_AC_LANG_ABBREV[]_compiler_version_patch=0)]) # for version 7 AS_IF([test "X$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major" = "X13"], [AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, _MSC_FULL_VER%1000,, AC_MSG_FAILURE([[[$0]] unknown microsoft compiler patch version])) ]) # for version > 8 AS_IF([test $_ax_[]_AC_LANG_ABBREV[]_compiler_version_major -ge 14], [AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, _MSC_FULL_VER%10000,, AC_MSG_FAILURE([[[$0]] unknown microsoft compiler patch version])) ]) AS_IF([test $_ax_[]_AC_LANG_ABBREV[]_compiler_version_major -ge 15], [AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_build, _MSC_BUILD,, AC_MSG_FAILURE([[[$0]] unknown microsoft compiler build version])) ]) ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_build" ]) # for metrowerks AC_DEFUN([_AX_COMPILER_VERSION_METROWERKS],[dnl AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, __MWERKS__%0x100,, AC_MSG_FAILURE([[[$0]] unknown metrowerks compiler patch version])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, (__MWERKS__/0x100)%0x10,, AC_MSG_FAILURE([[[$0]] unknown metrowerks compiler minor version])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, (__MWERKS__/0x1000)%0x10,, AC_MSG_FAILURE([[[$0]] unknown metrowerks compiler major version])) ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" ]) # for watcom AC_DEFUN([_AX_COMPILER_VERSION_WATCOM],[dnl AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, __WATCOMC__%100,, AC_MSG_FAILURE([[[$0]] unknown watcom compiler minor version])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, (__WATCOMC__/100)%100,, AC_MSG_FAILURE([[[$0]] unknown watcom compiler major version])) ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor" ]) # for PGI AC_DEFUN([_AX_COMPILER_VERSION_PORTLAND],[ AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, __PGIC__,, AC_MSG_FAILURE([[[$0]] unknown pgi major])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, __PGIC_MINOR__,, AC_MSG_FAILURE([[[$0]] unknown pgi minor])) AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, [__PGIC_PATCHLEVEL__],, AC_MSG_FAILURE([[[$0]] unknown pgi patch level])) ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" ]) # tcc AC_DEFUN([_AX_COMPILER_VERSION_TCC],[ ax_cv_[]_AC_LANG_ABBREV[]_compiler_version=[`tcc -v | $SED 's/^[ ]*tcc[ ]\+version[ ]\+\([0-9.]\+\).*/\1/g'`] ]) # main entry point AC_DEFUN([AX_COMPILER_VERSION],[dnl AC_REQUIRE([AX_COMPILER_VENDOR]) AC_REQUIRE([AC_PROG_SED]) AC_CACHE_CHECK([for _AC_LANG compiler version], ax_cv_[]_AC_LANG_ABBREV[]_compiler_version, [ dnl AS_CASE([$ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor], [intel],[_AX_COMPILER_VERSION_INTEL], [ibm],[_AX_COMPILER_VERSION_IBM], [pathscale],[_AX_COMPILER_VERSION_PATHSCALE], [clang],[_AX_COMPILER_VERSION_CLANG], [cray],[_AX_COMPILER_VERSION_CRAY], [fujitsu],[_AX_COMPILER_VERSION_FUJITSU], [gnu],[_AX_COMPILER_VERSION_GNU], [sun],[_AX_COMPILER_VERSION_SUN], [hp],[_AX_COMPILER_VERSION_HP], [dec],[_AX_COMPILER_VERSION_DEC], [borland],[_AX_COMPILER_VERSION_BORLAND], [comeau],[_AX_COMPILER_VERSION_COMEAU], [kai],[_AX_COMPILER_VERSION_KAI], [sgi],[_AX_COMPILER_VERSION_SGI], [microsoft],[_AX_COMPILER_VERSION_MICROSOFT], [metrowerks],[_AX_COMPILER_VERSION_METROWERKS], [watcom],[_AX_COMPILER_VERSION_WATCOM], [portland],[_AX_COMPILER_VERSION_PORTLAND], [tcc],[_AX_COMPILER_VERSION_TCC], [ax_cv_[]_AC_LANG_ABBREV[]_compiler_version=""]) ]) ]) aircrack-ng-1.6/build/m4/ax_ext_have_static_lib.m4000066400000000000000000000117561361312141100221150ustar00rootroot00000000000000# =========================================================================== # # SYNOPSIS # # AX_EXT_HAVE_STATIC_LIB(VARIABLE-PREFIX, SEARCH-PATHS, LIBRARY-NAMES, # FUNCTION-NAME, [EXTRA-LIBRARIES]) # # DESCRIPTION # # Provides a generic test for locating an appropriate static library # to force link against, even when one's application is dynamically # linked. The macro was inspired by the PKG_CHECK_MODULES macro. # # If the library is found, [VARIABLE-PREFIX]_FOUND is defined, and # in all cases [VARIABLE-PREFIX]_LIBS is substituted. # # Example: # # AX_EXT_HAVE_STATIC_LIB_DETECT # AX_EXT_HAVE_STATIC_LIB(ZLIB, [${DEFAULT_STATIC_LIB_SEARCH_PATHS}], # z libz, compress) # # LICENSE # # Copyright (c) 2018 Joseph Benden # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation, either version 3 of the License, or (at your # option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program. If not, see . # # As a special exception, the respective Autoconf Macro's copyright owner # gives unlimited permission to copy, distribute and modify the configure # scripts that are the output of Autoconf when processing the Macro. You # need not follow the terms of the GNU General Public License when using # or distributing such scripts, even though portions of the text of the # Macro appear in them. The GNU General Public License (GPL) does govern # all other use of the material that constitutes the Autoconf Macro. # # This special exception to the GPL applies to versions of the Autoconf # Macro released by the Autoconf Archive. When you make and distribute a # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. #serial 1 AC_DEFUN([AX_EXT_HAVE_STATIC_LIB_DETECT], [ AC_REQUIRE([AC_CANONICAL_HOST]) AC_ARG_VAR([STATIC_HOST_ALIAS], [The alias name for host, default @<:@HOST@:>@.])dnl AC_ARG_VAR([STATIC_LIBDIR_NAME], [The libdir name for host, default @<:@lib@:>@.])dnl AC_CACHE_VAL([ext_cv_static_libdir_name], [ ext_cv_static_libdir_name="${STATIC_LIBDIR_NAME:-lib}" ]) AC_CACHE_VAL([ext_cv_default_static_lib_search_paths], [ AC_MSG_CHECKING([Default static library search path]) static_extpath="" if test -n "${STATIC_HOST_ALIAS}" then static_host="${STATIC_HOST_ALIAS}" else if test "${GCC}" = "yes" then static_host=`${CC} -dumpmachine 2>/dev/null` static_extpath=`${CC} -print-search-dirs 2> /dev/null | grep '^libraries' | sed -e 's/@<:@^=@:>@*=//' -e 's/:/ /g'` else static_host="${host}" fi fi ext_cv_default_static_lib_search_paths=" \ ${static_extpath} \ /opt/${ext_cv_static_libdir_name}/${static_host} \ /opt/${ext_cv_static_libdir_name} \ /usr/local/${ext_cv_static_libdir_name}/${static_host} \ /usr/local/${ext_cv_static_libdir_name} \ /usr/${ext_cv_static_libdir_name}/${static_host} \ /usr/${ext_cv_static_libdir_name} \ /${ext_cv_static_libdir_name} \ /opt/lib/${static_host} \ /opt/lib \ " AC_MSG_RESULT([${ext_cv_default_static_lib_search_paths}]) ]) DEFAULT_STATIC_LIB_SEARCH_PATHS="${ext_cv_default_static_lib_search_paths}" STATIC_LIBDIR_NAME="${ext_cv_static_libdir_name}" ]) AC_DEFUN([AX_EXT_HAVE_STATIC_LIB], [ AC_ARG_VAR([$1][_FOUND], [set if the static library $1 is available, already.])dnl AC_ARG_VAR([$1][_LIBS], [static library linker flags for $1.])dnl for dir in m4_normalize($2) do ext_haslib_cvdir=`echo $dir | $as_tr_sh` ext_haslib_cvname=`echo $3 | $as_tr_sh` AC_CACHE_VAL([ext_cv${ext_haslib_cvdir}_haslib_${ext_haslib_cvname}], [ for name in $3 do dnl Does an archive file exists in our current path? AC_CHECK_FILE("${dir}/${name}.a", [ dnl If so, can we link a simple program with it? ext_func_search_save_LIBS=$LIBS ext_func_save_ldflags=${LDFLAGS} LIBS="${dir}/${name}.a $5 ${ext_func_search_save_LIBS}" LDFLAGS="${ext_func_save_ldflags}" AC_LINK_IFELSE([AC_LANG_CALL([], [$4])], [ eval "ext_cv${ext_haslib_cvdir}_haslib_${ext_haslib_cvname}"="${dir}/${name}.a" AC_MSG_NOTICE([Found static library: ${dir}/${name}.a]) ], [ eval "ext_cv${ext_haslib_cvdir}_haslib_${ext_haslib_cvname}"="" ]) LIBS=$ext_func_search_save_LIBS LDFLAGS=$ext_func_save_ldflags ]) done ]) if eval `echo 'test x${'ext_cv${ext_haslib_cvdir}_haslib_${ext_haslib_cvname}'}' != "x"`; then $1[]_LIBS="`eval echo '\${'ext_cv${ext_haslib_cvdir}_haslib_${ext_haslib_cvname}'}'`" $1[]_FOUND=yes ext_lib_found="yes" AC_SUBST($1[]_LIBS) AC_SUBST($1[]_FOUND) fi done ])aircrack-ng-1.6/build/m4/ax_file_escapes.m4000066400000000000000000000013731361312141100205310ustar00rootroot00000000000000# =========================================================================== # https://www.gnu.org/software/autoconf-archive/ax_file_escapes.html # =========================================================================== # # SYNOPSIS # # AX_FILE_ESCAPES # # DESCRIPTION # # Writes the specified data to the specified file. # # LICENSE # # Copyright (c) 2008 Tom Howard # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. #serial 8 AC_DEFUN([AX_FILE_ESCAPES],[ AX_DOLLAR="\$" AX_SRB="\\135" AX_SLB="\\133" AX_BS="\\\\" AX_DQ="\"" ]) aircrack-ng-1.6/build/m4/ax_gcc_x86_cpu_supports.m4000066400000000000000000000114051361312141100221730ustar00rootroot00000000000000# ============================================================================ # https://www.gnu.org/software/autoconf-archive/ax_gcc_x86_cpu_supports.html # ============================================================================ # # SYNOPSIS # # AX_GCC_X86_CPU_SUPPORTS(X86-INSTRUCTION-SET, # [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND]) # # DESCRIPTION # # Checks if the host cpu supports X86-INSTRUCTION-SET. The instruction set # that can be tested are "mmx, popcnt, sse, sse2, sse3, sse4.1, sse4.2, # sse4a, avx, avx2, avx512f, fma, fma4, bmi, bmi2". If the instruction set # is supported by the host cpu, the C preprocessor macro # HAVE_XXX_INSTRUCTIONS is set to 1. The XXX is up-cased instruction case # with dot replaced by underscore. For example, the test for "sse4.2" # would export HAVE_SSE4_2_INSTRUCTIONS=1. This macro requires gcc # extended builtin function "__builtin_cpu_init" and # "__builtin_cpu_supports" to detect the cpu features. It will error out # if the compiler doesn't has these builtins. # # If the test for the instruction set succeeded, the hook ACTION-IF-FOUND # would run. Otherwise the hook ACTION-IF-NOT-FOUND would run if # specified. # # See also AX_CHECK_X86_FEATURES, which checks all the possible # instruction set and export the corresponding CFLAGS. # # LICENSE # # Copyright (c) 2016 Felix Chern # Copyright (c) 2017 Joseph Benden # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 2 of the License, or (at your # option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program. If not, see . # # As a special exception, the respective Autoconf Macro's copyright owner # gives unlimited permission to copy, distribute and modify the configure # scripts that are the output of Autoconf when processing the Macro. You # need not follow the terms of the GNU General Public License when using # or distributing such scripts, even though portions of the text of the # Macro appear in them. The GNU General Public License (GPL) does govern # all other use of the material that constitutes the Autoconf Macro. # # This special exception to the GPL applies to versions of the Autoconf # Macro released by the Autoconf Archive. When you make and distribute a # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. #serial 4 AC_DEFUN_ONCE([_AX_GCC_X86_CPU_INIT], [AC_LANG_PUSH([C]) AC_CACHE_CHECK([for gcc __builtin_cpu_init function], [ax_cv_gcc_check_x86_cpu_init], [AC_RUN_IFELSE( [AC_LANG_PROGRAM([#include ], [__builtin_cpu_init ();]) ], [ax_cv_gcc_check_x86_cpu_init=yes], [ax_cv_gcc_check_x86_cpu_init=no],[ax_cv_gcc_check_x86_cpu_init=no])]) ]) AC_DEFUN([AX_GCC_X86_CPU_SUPPORTS], [AC_REQUIRE([AC_PROG_CC]) AC_REQUIRE([_AX_GCC_X86_CPU_INIT]) AC_LANG_PUSH([C]) AS_VAR_PUSHDEF([gcc_x86_feature], [AS_TR_SH([ax_cv_gcc_x86_cpu_supports_$1])]) AC_CACHE_CHECK([for x86 $1 instruction support], [gcc_x86_feature], [AC_RUN_IFELSE( [AC_LANG_PROGRAM([ #include #if defined(__INTEL_COMPILER) #include #endif ],[ #if defined(__INTEL_COMPILER) int result = 0; if (!strcmp("$1", "avx2")) result = _may_i_use_cpu_feature(_FEATURE_AVX2); else if (!strcmp("$1", "avx")) result = _may_i_use_cpu_feature(_FEATURE_AVX); else if (!strcmp("$1", "sse2")) result = _may_i_use_cpu_feature(_FEATURE_SSE2); else if (!strcmp("$1", "mmx")) result = _may_i_use_cpu_feature(_FEATURE_MMX); return result ? 0 : 1; #else #if defined(__GNUC__) && !defined(__clang__) __builtin_cpu_init (); #endif if (__builtin_cpu_supports("$1")) return 0; return 1; #endif ])], [gcc_x86_feature=yes], [gcc_x86_feature=no], [gcc_x86_feature=no] )] ) AC_LANG_POP([C]) AS_VAR_IF([gcc_x86_feature],[yes], [AC_DEFINE( AS_TR_CPP([HAVE_$1_INSTRUCTIONS]), [1], [Define if $1 instructions are supported]) $2], [$3] ) AS_VAR_POPDEF([gcc_x86_feature]) ]) aircrack-ng-1.6/build/m4/ax_lib_gcrypt.m4000066400000000000000000000100551361312141100202420ustar00rootroot00000000000000# =========================================================================== # https://www.gnu.org/software/autoconf-archive/ax_lib_gcrypt.html # =========================================================================== # # SYNOPSIS # # AX_LIB_GCRYPT([yes|no|auto]) # # DESCRIPTION # # Searches for the 'gcrypt' library with the --with... option. # # If found, define HAVE_GCRYPT and macro GCRYPT_LIBS and GCRYPT_CFLAGS. # Also defines GCRYPT_WITH_ for the algorithms found available. # Possible algorithms are: AES ARCFOUR BLOWFISH CAST5 DES IDEA RFC2268 # SERPENT TWOFISH CRC HAVAL MD2 MD4 MD5 RMD160 SHA0 SHA1 SHA224 SHA256 # SHA384 SHA512 TIGER WHIRLPOOL DSA ELGAMAL RSA # # The argument is used if no --with...-gcrypt option is set. Value "yes" # requires the configuration by default. Value "no" does not require it by # default. Value "auto" configures the library only if available. # # See also AX_LIB_BEECRYPT and AX_LIB_CRYPTO. # # LICENSE # # Copyright (c) 2009 Fabien Coelho # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. #serial 12 # AX_CHECK_GCRYPT_ALGO([algo]) # generate convenient defines for each algorithm AC_DEFUN([AX_CHECK_GCRYPT_ALGO],[ AC_REQUIRE([AC_PROG_EGREP]) AC_MSG_CHECKING([for $1 in gcrypt]) if echo $gcrypt_algos | $EGREP -i ":.*( $1 | $1$)" > /dev/null ; then AC_DEFINE([GCRYPT_WITH_$1],[1],[Algorithm $1 in gcrypt library]) AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) fi ]) # AX_LIB_GCRYPT([yes|no|auto]) AC_DEFUN([AX_LIB_GCRYPT],[ AC_MSG_CHECKING([whether gcrypt is enabled]) AC_ARG_WITH([gcrypt],[ --with-gcrypt require gcrypt library --without-gcrypt disable gcrypt library],[ AC_MSG_RESULT([$withval]) ac_with_gcrypt=$withval ],[ AC_MSG_RESULT($1) ac_with_gcrypt=$1 ]) if test "$ac_with_gcrypt" = "yes" -o "$ac_with_gcrypt" = "auto" ; then AM_PATH_LIBGCRYPT([1.2.0],[ AC_DEFINE([HAVE_GCRYPT],[1],[Gcrypt library is available]) HAVE_GCRYPT=1 # checking for available algorithms... gcrypt_algos=`$LIBGCRYPT_CONFIG --algorithms` # ciphers # this does not work with a "for" loop: nothing generated in config.h:-( AX_CHECK_GCRYPT_ALGO([AES]) AX_CHECK_GCRYPT_ALGO([ARCFOUR]) AX_CHECK_GCRYPT_ALGO([BLOWFISH]) AX_CHECK_GCRYPT_ALGO([CAST5]) AX_CHECK_GCRYPT_ALGO([DES]) AX_CHECK_GCRYPT_ALGO([IDEA]) AX_CHECK_GCRYPT_ALGO([RFC2268]) AX_CHECK_GCRYPT_ALGO([SERPENT]) AX_CHECK_GCRYPT_ALGO([TWOFISH]) # digests AX_CHECK_GCRYPT_ALGO([CRC]) AX_CHECK_GCRYPT_ALGO([HAVAL]) AX_CHECK_GCRYPT_ALGO([MD2]) AX_CHECK_GCRYPT_ALGO([MD4]) AX_CHECK_GCRYPT_ALGO([MD5]) AX_CHECK_GCRYPT_ALGO([RMD160]) AX_CHECK_GCRYPT_ALGO([SHA0]) AX_CHECK_GCRYPT_ALGO([SHA1]) AX_CHECK_GCRYPT_ALGO([SHA224]) AX_CHECK_GCRYPT_ALGO([SHA256]) AX_CHECK_GCRYPT_ALGO([SHA384]) AX_CHECK_GCRYPT_ALGO([SHA512]) AX_CHECK_GCRYPT_ALGO([TIGER]) AX_CHECK_GCRYPT_ALGO([WHIRLPOOL]) # others AX_CHECK_GCRYPT_ALGO([DSA]) AX_CHECK_GCRYPT_ALGO([ELGAMAL]) AX_CHECK_GCRYPT_ALGO([RSA]) # CMAC support AC_MSG_CHECKING([for CMAC_AES in gcrypt]) AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[ int ok = GCRY_MAC_CMAC_AES; (void)ok; ]])],[ AC_MSG_RESULT([yes]) AC_DEFINE([GCRYPT_WITH_CMAC_AES],[1],[Algorithm CMAC_AES in gcrypt library]) HAVE_CMAC=yes ], [ AC_MSG_RESULT([no]) HAVE_CMAC=no ]) # conclusion GCRYPT_CFLAGS=`$LIBGCRYPT_CONFIG --cflags` GCRYPT_LIBS=`$LIBGCRYPT_CONFIG --libs` AC_SUBST(GCRYPT_CFLAGS) AC_SUBST(GCRYPT_LIBS) ],[ # complain only if explicitly required if test "$ac_with_gcrypt" = "yes" ; then AC_MSG_ERROR([cannot configure required gcrypt library]) fi ]) fi ]) aircrack-ng-1.6/build/m4/ax_lib_socket_nsl.m4000066400000000000000000000025641361312141100211040ustar00rootroot00000000000000# =========================================================================== # https://www.gnu.org/software/autoconf-archive/ax_lib_socket_nsl.html # =========================================================================== # # SYNOPSIS # # AX_LIB_SOCKET_NSL # # DESCRIPTION # # This macro figures out what libraries are required on this platform to # link sockets programs. # # The common cases are not to need any extra libraries, or to need # -lsocket and -lnsl. We need to avoid linking with libnsl unless we need # it, though, since on some OSes where it isn't necessary it will totally # break networking. Unisys also includes gethostbyname() in libsocket but # needs libnsl for socket(). # # LICENSE # # Copyright (c) 2008 Russ Allbery # Copyright (c) 2008 Stepan Kasal # Copyright (c) 2008 Warren Young # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. #serial 7 AU_ALIAS([LIB_SOCKET_NSL], [AX_LIB_SOCKET_NSL]) AC_DEFUN([AX_LIB_SOCKET_NSL], [ AC_SEARCH_LIBS([gethostbyname], [nsl]) AC_SEARCH_LIBS([socket], [socket], [], [ AC_CHECK_LIB([socket], [socket], [LIBS="-lsocket -lnsl $LIBS"], [], [-lnsl])]) ]) aircrack-ng-1.6/build/m4/ax_lib_sqlite3.m4000066400000000000000000000135671361312141100203310ustar00rootroot00000000000000# =========================================================================== # https://www.gnu.org/software/autoconf-archive/ax_lib_sqlite3.html # =========================================================================== # # SYNOPSIS # # AX_LIB_SQLITE3([MINIMUM-VERSION]) # # DESCRIPTION # # Test for the SQLite 3 library of a particular version (or newer) # # This macro takes only one optional argument, required version of SQLite # 3 library. If required version is not passed, 3.0.0 is used in the test # of existence of SQLite 3. # # If no installation prefix to the installed SQLite library is given the # macro searches under /usr, /usr/local, and /opt. # # This macro calls: # # AC_SUBST(SQLITE3_CFLAGS) # AC_SUBST(SQLITE3_LDFLAGS) # AC_SUBST(SQLITE3_VERSION) # # And sets: # # HAVE_SQLITE3 # # LICENSE # # Copyright (c) 2008 Mateusz Loskot # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. #serial 18 AC_DEFUN([AX_LIB_SQLITE3], [ AC_REQUIRE([AX_EXT_HAVE_STATIC_LIB_DETECT]) AC_ARG_WITH([sqlite3], AS_HELP_STRING( [--with-sqlite3=@<:@ARG@:>@], [use SQLite 3 library @<:@default=yes@:>@, optionally specify the prefix for sqlite3 library] ), [ if test "$withval" = "no"; then WANT_SQLITE3="no" elif test "$withval" = "yes"; then WANT_SQLITE3="yes" ac_sqlite3_path="" else WANT_SQLITE3="yes" ac_sqlite3_path="$withval" fi ], [WANT_SQLITE3="yes"] ) SQLITE3_CFLAGS="" SQLITE3_LDFLAGS="" SQLITE3_VERSION="" if test "x$WANT_SQLITE3" = "xyes"; then ac_sqlite3_header="sqlite3.h" sqlite3_version_req=ifelse([$1], [], [3.0.0], [$1]) sqlite3_version_req_shorten=`expr $sqlite3_version_req : '\([[0-9]]*\.[[0-9]]*\)'` sqlite3_version_req_major=`expr $sqlite3_version_req : '\([[0-9]]*\)'` sqlite3_version_req_minor=`expr $sqlite3_version_req : '[[0-9]]*\.\([[0-9]]*\)'` sqlite3_version_req_micro=`expr $sqlite3_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'` if test "x$sqlite3_version_req_micro" = "x" ; then sqlite3_version_req_micro="0" fi sqlite3_version_req_number=`expr $sqlite3_version_req_major \* 1000000 \ \+ $sqlite3_version_req_minor \* 1000 \ \+ $sqlite3_version_req_micro` AC_MSG_CHECKING([for SQLite3 header]) if test "$ac_sqlite3_path" != ""; then ac_sqlite3_ldflags="-L$ac_sqlite3_path/${STATIC_LIBDIR_NAME}" ac_sqlite3_cppflags="-I$ac_sqlite3_path/include" AC_MSG_RESULT([explicitly set; $ac_sqlite3_path]) else for ac_sqlite3_path_tmp in /usr /usr/local /opt ; do if test -f "$ac_sqlite3_path_tmp/include/$ac_sqlite3_header" \ && test -r "$ac_sqlite3_path_tmp/include/$ac_sqlite3_header"; then ac_sqlite3_path=$ac_sqlite3_path_tmp ac_sqlite3_cppflags="-I$ac_sqlite3_path_tmp/include" ac_sqlite3_ldflags="-L$ac_sqlite3_path_tmp/${STATIC_LIBDIR_NAME}" AC_MSG_RESULT([found; $ac_sqlite3_path_tmp/include/$ac_sqlite3_header]) break; fi done if test "$ac_sqlite3_path" = ""; then AC_MSG_RESULT([not found]) fi fi ac_sqlite3_ldflags="$ac_sqlite3_ldflags -lsqlite3" saved_CPPFLAGS="$CPPFLAGS" saved_LDFLAGS="$LDFLAGS" CPPFLAGS="$CPPFLAGS $ac_sqlite3_cppflags" LDFLAGS="$LDFLAGS $ac_sqlite3_ldflags" AC_LANG_PUSH(C) AC_CHECK_HEADERS([sqlite3.h], [HAVE_SQLITE3=yes], [HAVE_SQLITE3=no]) AS_IF([test "$HAVE_SQLITE3" = yes], [ AC_CHECK_LIB([sqlite3], [sqlite3_open], [:], [HAVE_SQLITE3=no]) ]) AS_IF([test "$HAVE_SQLITE3" = yes], [ AC_MSG_CHECKING([for SQLite3 library version >= $sqlite3_version_req]) AC_COMPILE_IFELSE( [ AC_LANG_PROGRAM([[@%:@include ]], [[ #if (SQLITE_VERSION_NUMBER >= $sqlite3_version_req_number) /* Everything is okay */ #else # error SQLite version is too old #endif ]] ) ], [ AC_MSG_RESULT([yes]) ], [ AC_MSG_RESULT([not found]) HAVE_SQLITE3=no ] ) ]) AC_LANG_POP(C) CPPFLAGS="$saved_CPPFLAGS" LDFLAGS="$saved_LDFLAGS" if test "$HAVE_SQLITE3" = "yes"; then SQLITE3_CFLAGS="$ac_sqlite3_cppflags" SQLITE3_LDFLAGS="$ac_sqlite3_ldflags" ac_sqlite3_header_path="$ac_sqlite3_path/include/$ac_sqlite3_header" dnl Retrieve SQLite release version if test "x$ac_sqlite3_header_path" != "x"; then ac_sqlite3_version=`cat $ac_sqlite3_header_path \ | grep '#define.*SQLITE_VERSION.*\"' | sed -e 's/.* "//' \ | sed -e 's/"//'` if test $ac_sqlite3_version != ""; then SQLITE3_VERSION=$ac_sqlite3_version else AC_MSG_WARN([Cannot find SQLITE_VERSION macro in sqlite3.h header to retrieve SQLite version!]) fi fi AC_SUBST(SQLITE3_CFLAGS) AC_SUBST(SQLITE3_LDFLAGS) AC_SUBST(SQLITE3_VERSION) AC_SUBST(HAVE_SQLITE3) AC_DEFINE([HAVE_SQLITE3], [1], [Have the SQLITE3 library]) fi fi ]) aircrack-ng-1.6/build/m4/ax_pthread.m4000066400000000000000000000505331361312141100175400ustar00rootroot00000000000000# =========================================================================== # https://www.gnu.org/software/autoconf-archive/ax_pthread.html # =========================================================================== # # SYNOPSIS # # AX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) # # DESCRIPTION # # This macro figures out how to build C programs using POSIX threads. It # sets the PTHREAD_LIBS output variable to the threads library and linker # flags, and the PTHREAD_CFLAGS output variable to any special C compiler # flags that are needed. (The user can also force certain compiler # flags/libs to be tested by setting these environment variables.) # # Also sets PTHREAD_CC to any special C compiler that is needed for # multi-threaded programs (defaults to the value of CC otherwise). (This # is necessary on AIX to use the special cc_r compiler alias.) # # NOTE: You are assumed to not only compile your program with these flags, # but also to link with them as well. For example, you might link with # $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS # # If you are only building threaded programs, you may wish to use these # variables in your default LIBS, CFLAGS, and CC: # # LIBS="$PTHREAD_LIBS $LIBS" # CFLAGS="$CFLAGS $PTHREAD_CFLAGS" # CC="$PTHREAD_CC" # # In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant # has a nonstandard name, this macro defines PTHREAD_CREATE_JOINABLE to # that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX). # # Also HAVE_PTHREAD_PRIO_INHERIT is defined if pthread is found and the # PTHREAD_PRIO_INHERIT symbol is defined when compiling with # PTHREAD_CFLAGS. # # ACTION-IF-FOUND is a list of shell commands to run if a threads library # is found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it # is not found. If ACTION-IF-FOUND is not specified, the default action # will define HAVE_PTHREAD. # # Please let the authors know if this macro fails on any platform, or if # you have any other suggestions or comments. This macro was based on work # by SGJ on autoconf scripts for FFTW (http://www.fftw.org/) (with help # from M. Frigo), as well as ac_pthread and hb_pthread macros posted by # Alejandro Forero Cuervo to the autoconf macro repository. We are also # grateful for the helpful feedback of numerous users. # # Updated for Autoconf 2.68 by Daniel Richard G. # # LICENSE # # Copyright (c) 2008 Steven G. Johnson # Copyright (c) 2011 Daniel Richard G. # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation, either version 3 of the License, or (at your # option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program. If not, see . # # As a special exception, the respective Autoconf Macro's copyright owner # gives unlimited permission to copy, distribute and modify the configure # scripts that are the output of Autoconf when processing the Macro. You # need not follow the terms of the GNU General Public License when using # or distributing such scripts, even though portions of the text of the # Macro appear in them. The GNU General Public License (GPL) does govern # all other use of the material that constitutes the Autoconf Macro. # # This special exception to the GPL applies to versions of the Autoconf # Macro released by the Autoconf Archive. When you make and distribute a # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. #serial 24 AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD]) AC_DEFUN([AX_PTHREAD], [ AC_REQUIRE([AC_CANONICAL_HOST]) AC_REQUIRE([AC_PROG_CC]) AC_REQUIRE([AC_PROG_SED]) AC_LANG_PUSH([C]) ax_pthread_ok=no # We used to check for pthread.h first, but this fails if pthread.h # requires special compiler flags (e.g. on Tru64 or Sequent). # It gets checked for in the link test anyway. # First of all, check if the user has set any of the PTHREAD_LIBS, # etcetera environment variables, and if threads linking works using # them: if test "x$PTHREAD_CFLAGS$PTHREAD_LIBS" != "x"; then ax_pthread_save_CC="$CC" ax_pthread_save_CFLAGS="$CFLAGS" ax_pthread_save_LIBS="$LIBS" AS_IF([test "x$PTHREAD_CC" != "x"], [CC="$PTHREAD_CC"]) CFLAGS="$CFLAGS $PTHREAD_CFLAGS" LIBS="$PTHREAD_LIBS $LIBS" AC_MSG_CHECKING([for pthread_join using $CC $PTHREAD_CFLAGS $PTHREAD_LIBS]) AC_LINK_IFELSE([AC_LANG_CALL([], [pthread_join])], [ax_pthread_ok=yes]) AC_MSG_RESULT([$ax_pthread_ok]) if test "x$ax_pthread_ok" = "xno"; then PTHREAD_LIBS="" PTHREAD_CFLAGS="" fi CC="$ax_pthread_save_CC" CFLAGS="$ax_pthread_save_CFLAGS" LIBS="$ax_pthread_save_LIBS" fi # We must check for the threads library under a number of different # names; the ordering is very important because some systems # (e.g. DEC) have both -lpthread and -lpthreads, where one of the # libraries is broken (non-POSIX). # Create a list of thread flags to try. Items starting with a "-" are # C compiler flags, and other items are library names, except for "none" # which indicates that we try without any flags at all, and "pthread-config" # which is a program returning the flags for the Pth emulation library. ax_pthread_flags="pthreads none -Kthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config" # The ordering *is* (sometimes) important. Some notes on the # individual items follow: # pthreads: AIX (must check this before -lpthread) # none: in case threads are in libc; should be tried before -Kthread and # other compiler flags to prevent continual compiler warnings # -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) # -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads), Tru64 # (Note: HP C rejects this with "bad form for `-t' option") # -pthreads: Solaris/gcc (Note: HP C also rejects) # -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it # doesn't hurt to check since this sometimes defines pthreads and # -D_REENTRANT too), HP C (must be checked before -lpthread, which # is present but should not be used directly; and before -mthreads, # because the compiler interprets this as "-mt" + "-hreads") # -mthreads: Mingw32/gcc, Lynx/gcc # pthread: Linux, etcetera # --thread-safe: KAI C++ # pthread-config: use pthread-config program (for GNU Pth library) case $host_os in freebsd*) # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) # lthread: LinuxThreads port on FreeBSD (also preferred to -pthread) ax_pthread_flags="-kthread lthread $ax_pthread_flags" ;; hpux*) # From the cc(1) man page: "[-mt] Sets various -D flags to enable # multi-threading and also sets -lpthread." ax_pthread_flags="-mt -pthread pthread $ax_pthread_flags" ;; openedition*) # IBM z/OS requires a feature-test macro to be defined in order to # enable POSIX threads at all, so give the user a hint if this is # not set. (We don't define these ourselves, as they can affect # other portions of the system API in unpredictable ways.) AC_EGREP_CPP([AX_PTHREAD_ZOS_MISSING], [ # if !defined(_OPEN_THREADS) && !defined(_UNIX03_THREADS) AX_PTHREAD_ZOS_MISSING # endif ], [AC_MSG_WARN([IBM z/OS requires -D_OPEN_THREADS or -D_UNIX03_THREADS to enable pthreads support.])]) ;; solaris*) # On Solaris (at least, for some versions), libc contains stubbed # (non-functional) versions of the pthreads routines, so link-based # tests will erroneously succeed. (N.B.: The stubs are missing # pthread_cleanup_push, or rather a function called by this macro, # so we could check for that, but who knows whether they'll stub # that too in a future libc.) So we'll check first for the # standard Solaris way of linking pthreads (-mt -lpthread). ax_pthread_flags="-mt,pthread pthread $ax_pthread_flags" ;; esac # GCC generally uses -pthread, or -pthreads on some platforms (e.g. SPARC) AS_IF([test "x$GCC" = "xyes"], [ax_pthread_flags="-pthread -pthreads $ax_pthread_flags"]) # The presence of a feature test macro requesting re-entrant function # definitions is, on some systems, a strong hint that pthreads support is # correctly enabled case $host_os in darwin* | hpux* | linux* | osf* | solaris*) ax_pthread_check_macro="_REENTRANT" ;; aix*) ax_pthread_check_macro="_THREAD_SAFE" ;; *) ax_pthread_check_macro="--" ;; esac AS_IF([test "x$ax_pthread_check_macro" = "x--"], [ax_pthread_check_cond=0], [ax_pthread_check_cond="!defined($ax_pthread_check_macro)"]) # Are we compiling with Clang? AC_CACHE_CHECK([whether $CC is Clang], [ax_cv_PTHREAD_CLANG], [ax_cv_PTHREAD_CLANG=no # Note that Autoconf sets GCC=yes for Clang as well as GCC if test "x$GCC" = "xyes"; then AC_EGREP_CPP([AX_PTHREAD_CC_IS_CLANG], [/* Note: Clang 2.7 lacks __clang_[a-z]+__ */ # if defined(__clang__) && defined(__llvm__) AX_PTHREAD_CC_IS_CLANG # endif ], [ax_cv_PTHREAD_CLANG=yes]) fi ]) ax_pthread_clang="$ax_cv_PTHREAD_CLANG" ax_pthread_clang_warning=no # Clang needs special handling, because older versions handle the -pthread # option in a rather... idiosyncratic way if test "x$ax_pthread_clang" = "xyes"; then # Clang takes -pthread; it has never supported any other flag # (Note 1: This will need to be revisited if a system that Clang # supports has POSIX threads in a separate library. This tends not # to be the way of modern systems, but it's conceivable.) # (Note 2: On some systems, notably Darwin, -pthread is not needed # to get POSIX threads support; the API is always present and # active. We could reasonably leave PTHREAD_CFLAGS empty. But # -pthread does define _REENTRANT, and while the Darwin headers # ignore this macro, third-party headers might not.) PTHREAD_CFLAGS="-pthread" PTHREAD_LIBS= ax_pthread_ok=yes # However, older versions of Clang make a point of warning the user # that, in an invocation where only linking and no compilation is # taking place, the -pthread option has no effect ("argument unused # during compilation"). They expect -pthread to be passed in only # when source code is being compiled. # # Problem is, this is at odds with the way Automake and most other # C build frameworks function, which is that the same flags used in # compilation (CFLAGS) are also used in linking. Many systems # supported by AX_PTHREAD require exactly this for POSIX threads # support, and in fact it is often not straightforward to specify a # flag that is used only in the compilation phase and not in # linking. Such a scenario is extremely rare in practice. # # Even though use of the -pthread flag in linking would only print # a warning, this can be a nuisance for well-run software projects # that build with -Werror. So if the active version of Clang has # this misfeature, we search for an option to squash it. AC_CACHE_CHECK([whether Clang needs flag to prevent "argument unused" warning when linking with -pthread], [ax_cv_PTHREAD_CLANG_NO_WARN_FLAG], [ax_cv_PTHREAD_CLANG_NO_WARN_FLAG=unknown # Create an alternate version of $ac_link that compiles and # links in two steps (.c -> .o, .o -> exe) instead of one # (.c -> exe), because the warning occurs only in the second # step ax_pthread_save_ac_link="$ac_link" ax_pthread_sed='s/conftest\.\$ac_ext/conftest.$ac_objext/g' ax_pthread_link_step=`$as_echo "$ac_link" | sed "$ax_pthread_sed"` ax_pthread_2step_ac_link="($ac_compile) && (echo ==== >&5) && ($ax_pthread_link_step)" ax_pthread_save_CFLAGS="$CFLAGS" for ax_pthread_try in '' -Qunused-arguments -Wno-unused-command-line-argument unknown; do AS_IF([test "x$ax_pthread_try" = "xunknown"], [break]) CFLAGS="-Werror -Wunknown-warning-option $ax_pthread_try -pthread $ax_pthread_save_CFLAGS" ac_link="$ax_pthread_save_ac_link" AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void){return 0;}]])], [ac_link="$ax_pthread_2step_ac_link" AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void){return 0;}]])], [break]) ]) done ac_link="$ax_pthread_save_ac_link" CFLAGS="$ax_pthread_save_CFLAGS" AS_IF([test "x$ax_pthread_try" = "x"], [ax_pthread_try=no]) ax_cv_PTHREAD_CLANG_NO_WARN_FLAG="$ax_pthread_try" ]) case "$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG" in no | unknown) ;; *) PTHREAD_CFLAGS="$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG $PTHREAD_CFLAGS" ;; esac fi # $ax_pthread_clang = yes if test "x$ax_pthread_ok" = "xno"; then for ax_pthread_try_flag in $ax_pthread_flags; do case $ax_pthread_try_flag in none) AC_MSG_CHECKING([whether pthreads work without any flags]) ;; -mt,pthread) AC_MSG_CHECKING([whether pthreads work with -mt -lpthread]) PTHREAD_CFLAGS="-mt" PTHREAD_LIBS="-lpthread" ;; -*) AC_MSG_CHECKING([whether pthreads work with $ax_pthread_try_flag]) PTHREAD_CFLAGS="$ax_pthread_try_flag" ;; pthread-config) AC_CHECK_PROG([ax_pthread_config], [pthread-config], [yes], [no]) AS_IF([test "x$ax_pthread_config" = "xno"], [continue]) PTHREAD_CFLAGS="`pthread-config --cflags`" PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`" ;; *) AC_MSG_CHECKING([for the pthreads library -l$ax_pthread_try_flag]) PTHREAD_LIBS="-l$ax_pthread_try_flag" ;; esac ax_pthread_save_CFLAGS="$CFLAGS" ax_pthread_save_LIBS="$LIBS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" LIBS="$PTHREAD_LIBS $LIBS" # Check for various functions. We must include pthread.h, # since some functions may be macros. (On the Sequent, we # need a special flag -Kthread to make this header compile.) # We check for pthread_join because it is in -lpthread on IRIX # while pthread_create is in libc. We check for pthread_attr_init # due to DEC craziness with -lpthreads. We check for # pthread_cleanup_push because it is one of the few pthread # functions on Solaris that doesn't have a non-functional libc stub. # We try pthread_create on general principles. AC_LINK_IFELSE([AC_LANG_PROGRAM([#include # if $ax_pthread_check_cond # error "$ax_pthread_check_macro must be defined" # endif static void routine(void *a) { a = 0; (void)a; } static void *start_routine(void *a) { return a; }], [pthread_t th; pthread_attr_t attr; pthread_create(&th, 0, start_routine, 0); pthread_join(th, 0); pthread_attr_init(&attr); pthread_cleanup_push(routine, 0); pthread_cleanup_pop(0) /* ; */])], [ax_pthread_ok=yes], []) CFLAGS="$ax_pthread_save_CFLAGS" LIBS="$ax_pthread_save_LIBS" AC_MSG_RESULT([$ax_pthread_ok]) AS_IF([test "x$ax_pthread_ok" = "xyes"], [break]) PTHREAD_LIBS="" PTHREAD_CFLAGS="" done fi # Various other checks: if test "x$ax_pthread_ok" = "xyes"; then ax_pthread_save_CFLAGS="$CFLAGS" ax_pthread_save_LIBS="$LIBS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" LIBS="$PTHREAD_LIBS $LIBS" # Detect AIX lossage: JOINABLE attribute is called UNDETACHED. AC_CACHE_CHECK([for joinable pthread attribute], [ax_cv_PTHREAD_JOINABLE_ATTR], [ax_cv_PTHREAD_JOINABLE_ATTR=unknown for ax_pthread_attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do AC_LINK_IFELSE([AC_LANG_PROGRAM([#include ], [int attr = $ax_pthread_attr; return attr /* ; */])], [ax_cv_PTHREAD_JOINABLE_ATTR=$ax_pthread_attr; break], []) done ]) AS_IF([test "x$ax_cv_PTHREAD_JOINABLE_ATTR" != "xunknown" && \ test "x$ax_cv_PTHREAD_JOINABLE_ATTR" != "xPTHREAD_CREATE_JOINABLE" && \ test "x$ax_pthread_joinable_attr_defined" != "xyes"], [AC_DEFINE_UNQUOTED([PTHREAD_CREATE_JOINABLE], [$ax_cv_PTHREAD_JOINABLE_ATTR], [Define to necessary symbol if this constant uses a non-standard name on your system.]) ax_pthread_joinable_attr_defined=yes ]) AC_CACHE_CHECK([whether more special flags are required for pthreads], [ax_cv_PTHREAD_SPECIAL_FLAGS], [ax_cv_PTHREAD_SPECIAL_FLAGS=no case $host_os in solaris*) ax_cv_PTHREAD_SPECIAL_FLAGS="-D_POSIX_PTHREAD_SEMANTICS" ;; esac ]) AS_IF([test "x$ax_cv_PTHREAD_SPECIAL_FLAGS" != "xno" && \ test "x$ax_pthread_special_flags_added" != "xyes"], [PTHREAD_CFLAGS="$ax_cv_PTHREAD_SPECIAL_FLAGS $PTHREAD_CFLAGS" ax_pthread_special_flags_added=yes]) AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT], [ax_cv_PTHREAD_PRIO_INHERIT], [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], [[int i = PTHREAD_PRIO_INHERIT;]])], [ax_cv_PTHREAD_PRIO_INHERIT=yes], [ax_cv_PTHREAD_PRIO_INHERIT=no]) ]) AS_IF([test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes" && \ test "x$ax_pthread_prio_inherit_defined" != "xyes"], [AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], [1], [Have PTHREAD_PRIO_INHERIT.]) ax_pthread_prio_inherit_defined=yes ]) CFLAGS="$ax_pthread_save_CFLAGS" LIBS="$ax_pthread_save_LIBS" # More AIX lossage: compile with *_r variant if test "x$GCC" != "xyes"; then case $host_os in aix*) AS_CASE(["x/$CC"], [x*/c89|x*/c89_128|x*/c99|x*/c99_128|x*/cc|x*/cc128|x*/xlc|x*/xlc_v6|x*/xlc128|x*/xlc128_v6], [#handle absolute path differently from PATH based program lookup AS_CASE(["x$CC"], [x/*], [AS_IF([AS_EXECUTABLE_P([${CC}_r])],[PTHREAD_CC="${CC}_r"])], [AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC])])]) ;; esac fi fi test -n "$PTHREAD_CC" || PTHREAD_CC="$CC" AC_SUBST([PTHREAD_LIBS]) AC_SUBST([PTHREAD_CFLAGS]) AC_SUBST([PTHREAD_CC]) # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: if test "x$ax_pthread_ok" = "xyes"; then ifelse([$1],,[AC_DEFINE([HAVE_PTHREAD],[1],[Define if you have POSIX threads libraries and header files.])],[$1]) : else ax_pthread_ok=no $2 fi AC_LANG_POP ])dnl AX_PTHREAD aircrack-ng-1.6/build/m4/ax_require_defined.m4000066400000000000000000000023021361312141100212320ustar00rootroot00000000000000# =========================================================================== # https://www.gnu.org/software/autoconf-archive/ax_require_defined.html # =========================================================================== # # SYNOPSIS # # AX_REQUIRE_DEFINED(MACRO) # # DESCRIPTION # # AX_REQUIRE_DEFINED is a simple helper for making sure other macros have # been defined and thus are available for use. This avoids random issues # where a macro isn't expanded. Instead the configure script emits a # non-fatal: # # ./configure: line 1673: AX_CFLAGS_WARN_ALL: command not found # # It's like AC_REQUIRE except it doesn't expand the required macro. # # Here's an example: # # AX_REQUIRE_DEFINED([AX_CHECK_LINK_FLAG]) # # LICENSE # # Copyright (c) 2014 Mike Frysinger # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. #serial 2 AC_DEFUN([AX_REQUIRE_DEFINED], [dnl m4_ifndef([$1], [m4_fatal([macro ]$1[ is not defined; is a m4 file missing?])]) ])dnl AX_REQUIRE_DEFINED aircrack-ng-1.6/build/m4/ax_valgrind_check.m4000066400000000000000000000171411361312141100210520ustar00rootroot00000000000000# =========================================================================== # http://www.gnu.org/software/autoconf-archive/ax_valgrind_check.html # =========================================================================== # # SYNOPSIS # # AX_VALGRIND_CHECK() # # DESCRIPTION # # Checks whether Valgrind is present and, if so, allows running `make # check` under a variety of Valgrind tools to check for memory and # threading errors. # # Defines VALGRIND_CHECK_RULES which should be substituted in your # Makefile; and $enable_valgrind which can be used in subsequent configure # output. VALGRIND_ENABLED is defined and substituted, and corresponds to # the value of the --enable-valgrind option, which defaults to being # enabled if Valgrind is installed and disabled otherwise. # # If unit tests are written using a shell script and automake's # LOG_COMPILER system, the $(VALGRIND) variable can be used within the # shell scripts to enable Valgrind, as described here: # # https://www.gnu.org/software/gnulib/manual/html_node/Running-self_002dtests-under-valgrind.html # # Usage example: # # configure.ac: # # AX_VALGRIND_CHECK # # Makefile.am: # # @VALGRIND_CHECK_RULES@ # VALGRIND_SUPPRESSIONS_FILES = my-project.supp # EXTRA_DIST = my-project.supp # # This results in a "check-valgrind" rule being added to any Makefile.am # which includes "@VALGRIND_CHECK_RULES@" (assuming the module has been # configured with --enable-valgrind). Running `make check-valgrind` in # that directory will run the module's test suite (`make check`) once for # each of the available Valgrind tools (out of memcheck, helgrind, drd and # sgcheck), and will output results to test-suite-$toolname.log for each. # The target will succeed if there are zero errors and fail otherwise. # # Alternatively, a "check-valgrind-$TOOL" rule will be added, for $TOOL in # memcheck, helgrind, drd and sgcheck. These are useful because often only # some of those tools can be ran cleanly on a codebase. # # The macro supports running with and without libtool. # # LICENSE # # Copyright (c) 2014, 2015, 2016 Philip Withnall # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. #serial 9 AC_DEFUN([AX_VALGRIND_CHECK],[ dnl Check for --enable-valgrind AC_ARG_ENABLE([valgrind], [AS_HELP_STRING([--enable-valgrind], [Whether to enable Valgrind on the unit tests])], [enable_valgrind=$enableval],[enable_valgrind=]) AS_IF([test "$enable_valgrind" != "no"],[ # Check for Valgrind. AC_CHECK_PROG([VALGRIND],[valgrind],[valgrind]) AS_IF([test "$VALGRIND" = ""],[ AS_IF([test "$enable_valgrind" = "yes"],[ AC_MSG_ERROR([Could not find valgrind; either install it or reconfigure with --disable-valgrind]) ],[ enable_valgrind=no ]) ],[ enable_valgrind=yes ]) ]) AM_CONDITIONAL([VALGRIND_ENABLED],[test "$enable_valgrind" = "yes"]) AC_SUBST([VALGRIND_ENABLED],[$enable_valgrind]) # Check for Valgrind tools we care about. m4_define([valgrind_tool_list],[[memcheck], [helgrind], [drd], [exp-sgcheck]]) AS_IF([test "$VALGRIND" != ""],[ m4_foreach([vgtool],[valgrind_tool_list],[ m4_define([vgtooln],AS_TR_SH(vgtool)) m4_define([ax_cv_var],[ax_cv_valgrind_tool_]vgtooln) AC_CACHE_CHECK([for Valgrind tool ]vgtool,ax_cv_var,[ ax_cv_var= AS_IF([`$VALGRIND --tool=vgtool --help >/dev/null 2>&1`],[ ax_cv_var="vgtool" ]) ]) AC_SUBST([VALGRIND_HAVE_TOOL_]vgtooln,[$ax_cv_var]) ]) ]) [VALGRIND_CHECK_RULES=' # Valgrind check # # Optional: # - VALGRIND_SUPPRESSIONS_FILES: Space-separated list of Valgrind suppressions # files to load. (Default: empty) # - VALGRIND_FLAGS: General flags to pass to all Valgrind tools. # (Default: --num-callers=30) # - VALGRIND_$toolname_FLAGS: Flags to pass to Valgrind $toolname (one of: # memcheck, helgrind, drd, sgcheck). (Default: various) # Optional variables VALGRIND_SUPPRESSIONS ?= $(addprefix --suppressions=,$(VALGRIND_SUPPRESSIONS_FILES)) VALGRIND_FLAGS ?= --num-callers=30 VALGRIND_memcheck_FLAGS ?= --leak-check=full --show-reachable=no VALGRIND_helgrind_FLAGS ?= --history-level=approx VALGRIND_drd_FLAGS ?= VALGRIND_sgcheck_FLAGS ?= # Internal use valgrind_tools = memcheck helgrind drd sgcheck valgrind_log_files = $(addprefix test-suite-,$(addsuffix .log,$(valgrind_tools))) valgrind_memcheck_flags = --tool=memcheck $(VALGRIND_memcheck_FLAGS) valgrind_helgrind_flags = --tool=helgrind $(VALGRIND_helgrind_FLAGS) valgrind_drd_flags = --tool=drd $(VALGRIND_drd_FLAGS) valgrind_sgcheck_flags = --tool=exp-sgcheck $(VALGRIND_sgcheck_FLAGS) valgrind_quiet = $(valgrind_quiet_$(V)) valgrind_quiet_ = $(valgrind_quiet_$(AM_DEFAULT_VERBOSITY)) valgrind_quiet_0 = --quiet # Support running with and without libtool. ifneq ($(LIBTOOL),) valgrind_lt = $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=execute else valgrind_lt = endif # Use recursive makes in order to ignore errors during check check-valgrind: ifeq ($(VALGRIND_ENABLED),yes) -$(foreach tool,$(valgrind_tools), \ $(if $(VALGRIND_HAVE_TOOL_$(tool))$(VALGRIND_HAVE_TOOL_exp_$(tool)), \ $(MAKE) $(AM_MAKEFLAGS) -k check-valgrind-tool VALGRIND_TOOL=$(tool); \ ) \ ) else @echo "Need to reconfigure with --enable-valgrind" endif # Valgrind running VALGRIND_TESTS_ENVIRONMENT = \ $(TESTS_ENVIRONMENT) \ env VALGRIND=$(VALGRIND) \ G_SLICE=always-malloc,debug-blocks \ G_DEBUG=fatal-warnings,fatal-criticals,gc-friendly VALGRIND_LOG_COMPILER = \ $(valgrind_lt) \ $(VALGRIND) $(VALGRIND_SUPPRESSIONS) --error-exitcode=1 $(VALGRIND_FLAGS) check-valgrind-tool: ifeq ($(VALGRIND_ENABLED),yes) $(MAKE) check-TESTS \ TESTS_ENVIRONMENT="$(VALGRIND_TESTS_ENVIRONMENT)" \ LOG_COMPILER="$(VALGRIND_LOG_COMPILER)" \ LOG_FLAGS="$(valgrind_$(VALGRIND_TOOL)_flags)" \ TEST_SUITE_LOG=test-suite-$(VALGRIND_TOOL).log else @echo "Need to reconfigure with --enable-valgrind" endif check-valgrind-memcheck: ifeq ($(VALGRIND_ENABLED),yes) $(MAKE) check-TESTS \ TESTS_ENVIRONMENT="$(VALGRIND_TESTS_ENVIRONMENT)" \ LOG_COMPILER="$(VALGRIND_LOG_COMPILER)" \ LOG_FLAGS="$(valgrind_memcheck_flags)" \ TEST_SUITE_LOG=test-suite-memcheck.log else @echo "Need to reconfigure with --enable-valgrind" endif check-valgrind-helgrind: ifeq ($(VALGRIND_ENABLED),yes) $(MAKE) check-TESTS \ TESTS_ENVIRONMENT="$(VALGRIND_TESTS_ENVIRONMENT)" \ LOG_COMPILER="$(VALGRIND_LOG_COMPILER)" \ LOG_FLAGS="$(valgrind_helgrind_flags)" \ TEST_SUITE_LOG=test-suite-helgrind.log else @echo "Need to reconfigure with --enable-valgrind" endif check-valgrind-drd: ifeq ($(VALGRIND_ENABLED),yes) $(MAKE) check-TESTS \ TESTS_ENVIRONMENT="$(VALGRIND_TESTS_ENVIRONMENT)" \ LOG_COMPILER="$(VALGRIND_LOG_COMPILER)" \ LOG_FLAGS="$(valgrind_drd_flags)" \ TEST_SUITE_LOG=test-suite-drd.log else @echo "Need to reconfigure with --enable-valgrind" endif check-valgrind-sgcheck: ifeq ($(VALGRIND_ENABLED),yes) $(MAKE) check-TESTS \ TESTS_ENVIRONMENT="$(VALGRIND_TESTS_ENVIRONMENT)" \ LOG_COMPILER="$(VALGRIND_LOG_COMPILER)" \ LOG_FLAGS="$(valgrind_sgcheck_flags)" \ TEST_SUITE_LOG=test-suite-sgcheck.log else @echo "Need to reconfigure with --enable-valgrind" endif A''M_DISTCHECK_CONFIGURE_FLAGS ?= A''M_DISTCHECK_CONFIGURE_FLAGS += --disable-valgrind MOSTLYCLEANFILES ?= MOSTLYCLEANFILES += $(valgrind_log_files) .PHONY: check-valgrind check-valgrind-tool '] AC_SUBST([VALGRIND_CHECK_RULES]) m4_ifdef([_AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE([VALGRIND_CHECK_RULES])]) ]) aircrack-ng-1.6/build/m4/libgcrypt.m4000066400000000000000000000124611361312141100174160ustar00rootroot00000000000000# libgcrypt.m4 - Autoconf macros to detect libgcrypt # Copyright (C) 2002, 2003, 2004, 2011, 2014 g10 Code GmbH # # This file is free software; as a special exception the author gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # # This file is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # # Last-changed: 2014-10-02 dnl AM_PATH_LIBGCRYPT([MINIMUM-VERSION, dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]]) dnl Test for libgcrypt and define LIBGCRYPT_CFLAGS and LIBGCRYPT_LIBS. dnl MINIMUN-VERSION is a string with the version number optionalliy prefixed dnl with the API version to also check the API compatibility. Example: dnl a MINIMUN-VERSION of 1:1.2.5 won't pass the test unless the installed dnl version of libgcrypt is at least 1.2.5 *and* the API number is 1. Using dnl this features allows one to prevent build against newer versions of dnl libgcrypt with a changed API. dnl dnl If a prefix option is not used, the config script is first dnl searched in $SYSROOT/bin and then along $PATH. If the used dnl config script does not match the host specification the script dnl is added to the gpg_config_script_warn variable. dnl AC_DEFUN([AM_PATH_LIBGCRYPT], [ AC_REQUIRE([AC_CANONICAL_HOST]) AC_ARG_WITH(libgcrypt-prefix, AC_HELP_STRING([--with-libgcrypt-prefix=PFX], [prefix where LIBGCRYPT is installed (optional)]), libgcrypt_config_prefix="$withval", libgcrypt_config_prefix="") if test x"${LIBGCRYPT_CONFIG}" = x ; then if test x"${libgcrypt_config_prefix}" != x ; then LIBGCRYPT_CONFIG="${libgcrypt_config_prefix}/bin/libgcrypt-config" else case "${SYSROOT}" in /*) if test -x "${SYSROOT}/bin/libgcrypt-config" ; then LIBGCRYPT_CONFIG="${SYSROOT}/bin/libgcrypt-config" fi ;; '') ;; *) AC_MSG_WARN([Ignoring \$SYSROOT as it is not an absolute path.]) ;; esac fi fi AC_PATH_PROG(LIBGCRYPT_CONFIG, libgcrypt-config, no) tmp=ifelse([$1], ,1:1.2.0,$1) if echo "$tmp" | grep ':' >/dev/null 2>/dev/null ; then req_libgcrypt_api=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\1/'` min_libgcrypt_version=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\2/'` else req_libgcrypt_api=0 min_libgcrypt_version="$tmp" fi AC_MSG_CHECKING(for LIBGCRYPT - version >= $min_libgcrypt_version) ok=no if test "$LIBGCRYPT_CONFIG" != "no" ; then req_major=`echo $min_libgcrypt_version | \ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'` req_minor=`echo $min_libgcrypt_version | \ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'` req_micro=`echo $min_libgcrypt_version | \ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'` libgcrypt_config_version=`$LIBGCRYPT_CONFIG --version` major=`echo $libgcrypt_config_version | \ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'` minor=`echo $libgcrypt_config_version | \ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'` micro=`echo $libgcrypt_config_version | \ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'` if test "$major" -gt "$req_major"; then ok=yes else if test "$major" -eq "$req_major"; then if test "$minor" -gt "$req_minor"; then ok=yes else if test "$minor" -eq "$req_minor"; then if test "$micro" -ge "$req_micro"; then ok=yes fi fi fi fi fi fi if test $ok = yes; then AC_MSG_RESULT([yes ($libgcrypt_config_version)]) else AC_MSG_RESULT(no) fi if test $ok = yes; then # If we have a recent libgcrypt, we should also check that the # API is compatible if test "$req_libgcrypt_api" -gt 0 ; then tmp=`$LIBGCRYPT_CONFIG --api-version 2>/dev/null || echo 0` if test "$tmp" -gt 0 ; then AC_MSG_CHECKING([LIBGCRYPT API version]) if test "$req_libgcrypt_api" -eq "$tmp" ; then AC_MSG_RESULT([okay]) else ok=no AC_MSG_RESULT([does not match. want=$req_libgcrypt_api got=$tmp]) fi fi fi fi if test $ok = yes; then LIBGCRYPT_CFLAGS=`$LIBGCRYPT_CONFIG --cflags` LIBGCRYPT_LIBS=`$LIBGCRYPT_CONFIG --libs` ifelse([$2], , :, [$2]) libgcrypt_config_host=`$LIBGCRYPT_CONFIG --host 2>/dev/null || echo none` if test x"$libgcrypt_config_host" != xnone ; then if test x"$libgcrypt_config_host" != x"$host" ; then AC_MSG_WARN([[ *** *** The config script $LIBGCRYPT_CONFIG was *** built for $libgcrypt_config_host and thus may not match the *** used host $host. *** You may want to use the configure option --with-libgcrypt-prefix *** to specify a matching config script or use \$SYSROOT. ***]]) gpg_config_script_warn="$gpg_config_script_warn libgcrypt" fi fi else LIBGCRYPT_CFLAGS="" LIBGCRYPT_LIBS="" ifelse([$3], , :, [$3]) fi AC_SUBST(LIBGCRYPT_CFLAGS) AC_SUBST(LIBGCRYPT_LIBS) ]) aircrack-ng-1.6/build/m4/stubs/000077500000000000000000000000001361312141100163115ustar00rootroot00000000000000aircrack-ng-1.6/build/m4/stubs/.gitkeep000066400000000000000000000000001361312141100177300ustar00rootroot00000000000000aircrack-ng-1.6/build/openssl.sh000077500000000000000000000007151361312141100166560ustar00rootroot00000000000000#!/usr/bin/env bash set -e EXTRA= case "${CC:=}" in clang*|llvm*) export CXX=clang++;; *) export CFLAGS="-Werror -Wno-unused-result"; export CXXFLAGS="-Werror -Wno-unused-result";; esac if [ "$TRAVIS_OS_NAME" == "osx" ]; then ./autogen.sh --with-experimental ${EXTRA}; else ./autogen.sh --with-experimental ${EXTRA}; fi || { cat config.log; exit 1; } make make check || { find . -name 'test-suite.log' -exec cat {} ';' && exit 1; } make clean exit 0 aircrack-ng-1.6/build/package-win32.ps1000066400000000000000000000152571361312141100176230ustar00rootroot00000000000000####################################################################### # # Copyright (C) 2018 Joseph Benden # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc. # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA # ####################################################################### # # Requirements: # - Microsoft Visual Studio 2017 Community is installed. # - Cygwin; both 32-bit and 64-bit. # - All Cygwin dependencies are installed in both 32-bit and in # 64-bit versions. # - Airpcap is extracted in the root of the project. # - The working directory is the root of the project. # - Assumes utilities are installed in AppVeyor-specific # locations. (Mostly default installation locations.) # # Running the script: # # powershell -File package-win32.ps1 # ####################################################################### $env:CHERE_INVOKING = 1 $env:AIRPCAP = c:\cygwin\bin\bash.exe -e -l -c "/bin/cygpath -u `'$(Get-Location)`'" $env:MSBUILD = "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild.exe" $REV = c:\cygwin\bin\bash.exe -e -l -c "./evalrev" $env:DIST = "aircrack-ng-$REV-win" Write-Host -ForegroundColor Blue "Creating dist folder: $env:DIST" if ((Test-Path -Path "src\.deps")) { Write-Host -ForegroundColor Blue "Running distclean" c:\cygwin\bin\bash.exe -e -l -c "/bin/make distclean" } if ((Test-Path -Path "$env:DIST")) { Write-Host -ForegroundColor Blue "Removing existing dist folder." Remove-Item -Recurse -Force $env:DIST } Write-Host -ForegroundColor Blue "Creating pristine sources" c:\cygwin\bin\bash.exe -e -l -c "git archive --format=tar --prefix=`"$env:DIST/`" HEAD | /bin/tar xf -" if ($LASTEXITCODE -ne 0) { Write-Host -ForegroundColor Red "Failed to create pristine sources!" Break } Write-Host -ForegroundColor Blue "Running autoreconf" c:\cygwin\bin\bash.exe -e -l -c "/bin/autoreconf -vi" | Out-Null if ($LASTEXITCODE -ne 0) { Write-Host -ForegroundColor Red "Failed to run autoreconf!" Break } Write-Host -ForegroundColor Blue "Building 32-bit binaries" $b32 = @" #!/bin/bash set -eufx [ -d 32bit ] && rm -fr 32bit mkdir 32bit cd 32bit env CFLAGS="-O3 -mtune=i686 -DNDEBUG" LDFLAGS="-Wl,--enable-auto-image-base" ../configure --host=i686-pc-cygwin --target=i686-pc-cygwin --with-experimental --with-airpcap=$env:AIRPCAP --enable-win32-portable /bin/make V=1 "@ $b32.Replace("`r`n","`n") | Set-Content -Path 32build.sh -Force c:\cygwin\bin\bash.exe -e -l -c "/bin/chmod +x 32build.sh && ./32build.sh" if ($LASTEXITCODE -ne 0) { Write-Host -ForegroundColor Red "Failed to build 32-bit binaries!" Break } Write-Host -ForegroundColor Blue "Building 64-bit binaries" $b64 = @" #!/bin/bash set -eufx [ -d 64bit ] && rm -fr 64bit mkdir 64bit cd 64bit env CFLAGS="-O3 -mtune=opteron -DNDEBUG" LDFLAGS="-Wl,--enable-auto-image-base" ../configure --host=x86_64-pc-cygwin --target=x86_64-pc-cygwin --with-experimental --with-airpcap=$env:AIRPCAP --enable-win32-portable /bin/make V=1 "@ $b64.Replace("`r`n","`n") | Set-Content -Path 64build.sh -Force c:\cygwin64\bin\bash.exe -e -l -c "/bin/chmod +x 64build.sh && ./64build.sh" if ($LASTEXITCODE -ne 0) { Write-Host -ForegroundColor Red "Failed to build 64-bit binaries!" Break } Write-Host -ForegroundColor Blue "Cloning GUI tools" if ((Test-Path -Path "gui")) { Write-Host -ForegroundColor Blue "Removing existing gui folder." Remove-Item -Recurse -Force gui } git clone --no-checkout --depth 1 --single-branch --branch Windows https://github.com/aircrack-ng/aircrack-ng.git gui Push-Location gui git reset --hard Pop-Location c:\cygwin\bin\bash.exe -e -l -c "/bin/rsync -a gui/ `"$env:DIST/src`" && /bin/rm -fr `"$env:DIST/src/.git`" `"$env:DIST/.gitignore`" `"$env:DIST/appveyor.yml`" `"$env:DIST/.travis.yml`" `"$env:DIST/README.md`" `"$env:DIST/.github`" `"$env:DIST/patches`" `"$env:DIST/apparmor`"" Push-Location gui/GUI & "$env:MSBUILD" Aircrack-ng.sln /p:Configuration=Release /p:Platform="Any CPU" if ($LASTEXITCODE -ne 0) { Write-Host -ForegroundColor Red "Failed to build GUI!" Pop-Location Break } Pop-Location if ((Test-Path -Path "$env:DIST.zip")) { Write-Host -ForegroundColor Blue "Removing existing ZIP file." Remove-Item -Force "$env:DIST.zip" } $pkg = @" #!/bin/bash set -eufx mkdir "$env:DIST/bin" mkdir "$env:DIST/bin/32bit" mkdir "$env:DIST/bin/64bit" cp -pr "gui/GUI/Aircrack-ng/bin/Release/Aircrack-ng GUI.exe" $env:DIST/bin find 32bit -path "*/.libs" -print0 | xargs -0I [] -n 1 find [] \( -name "*.exe" -o -name "*.dll" \) -exec cp -p {} "$env:DIST/bin/32bit" ';' find 64bit -path "*/.libs" -print0 | xargs -0I [] -n 1 find [] \( -name "*.exe" -o -name "*.dll" \) -exec cp -p {} "$env:DIST/bin/64bit" ';' # AirPcap DLLs cp -p "Airpcap_Devpack/bin/x86/airpcap.dll" "$env:DIST/bin/32bit" cp -p "Airpcap_Devpack/bin/x64/airpcap.dll" "$env:DIST/bin/64bit" # Cygwin License cp /usr/share/doc/Cygwin/CYGWIN_LICENSE "$env:DIST/LICENSE.Cygwin" # gather dependencies of Cygwin FILES="cygcrypto-1.1.dll cyghwloc-15.dll cyggcc_s-1.dll cyggcc_s-seh-1.dll cygpcre-1.dll cygsqlite3-0.dll cygstdc++-6.dll cygwin1.dll cygz.dll cygxml2-2.dll cyglzma-5.dll cygiconv-2.dll" for FILE in `$FILES; do cp -p "/cygdrive/c/cygwin/bin/`$FILE" "$env:DIST/bin/32bit" || : cp -p "/cygdrive/c/cygwin64/bin/`$FILE" "$env:DIST/bin/64bit" || : done "$env:DIST/bin/32bit/aircrack-ng" -u rc=`$("$env:DIST/bin/32bit/aircrack-ng" --simd-list | wc -c) if [ `$rc -ne 22 ]; then echo "The expected number of SIMD engines are NOT present in 32-bit binary." exit 1 fi "$env:DIST/bin/64bit/aircrack-ng" -u rc=`$("$env:DIST/bin/64bit/aircrack-ng" --simd-list | wc -c) if [ `$rc -ne 22 ]; then echo "The expected number of SIMD engines are NOT present in 64-bit binary." exit 1 fi zip -o -v -9 -r "$env:DIST.zip" "$env:DIST" ( cat README; echo; echo . ) | zip -z "$env:DIST.zip" exit 0 # # "@ $pkg.Replace("`r`n","`n") | Set-Content -Path pkg.sh -Force c:\cygwin\bin\bash.exe -e -l -c "/bin/chmod +x pkg.sh && ./pkg.sh" if ($LASTEXITCODE -ne 0) { Write-Host -ForegroundColor Red "Failed to package!" Break } Write-Host -ForegroundColor Green "Packaging successful!" aircrack-ng-1.6/build/pipelines/000077500000000000000000000000001361312141100166215ustar00rootroot00000000000000aircrack-ng-1.6/build/pipelines/package.yaml000066400000000000000000000261521361312141100211060ustar00rootroot00000000000000--- ## # Aircrack-ng Pipeline Definition # # Built with the PyDeployer tool! # # https://github.com/jbenden/deployer ## - name: Packaging Preparations tags: - pkg stage: scope: false tasks: - name: Set package metadata set: artifacts: artifacts/aircrack-ng www: '{% if env.ARTIFACT_WWW_ROOT %}{{ env.ARTIFACT_WWW_ROOT }}{% else %}/tmp/www{% endif %}' description: | Aircrack-ng is a complete suite of tools to assess WiFi network security. It focuses on different areas of WiFi security: - Monitoring: Packet capture and export of data to text files for further processing by third party tools. - Attacking: Replay attacks, deauthentication, fake access points and others via packet injection. - Testing: Checking WiFi cards and driver capabilities (capture and injection). - Cracking: WEP and WPA PSK (WPA 1 and 2). All tools are command line which allows for heavy scripting. A lot of GUIs have taken advantage of this feature. It works primarily with Linux but also Windows, OS X, FreeBSD, OpenBSD, NetBSD, as well as Solaris and even the eComStation 2. fpm: | [ -e "{{ item.pkg }}" ] && rm -f "{{ item.pkg }}" fpm -s dir \ -t "{{ item.pkg_type }}" \ -n "{{ item.pkg_name }}" \ -v "{{ item.pkg_version }}" \ --epoch 1 \ -C "{{ destdir }}" \ --license GPLv2 \ -m "info@aircrack-ng.org" \ --vendor 'The Aircrack-ng Project' \ --url 'https://aircrack-ng.org/' \ --description "{{ description }}" \ -p "{{ item.pkg_template }}" \ -x *.la \ {{ item.pkg_deps }} \ {{ item.pkg_content }} [ "{{ item.pkg_type }}" = deb ] && dpkg-deb -c "{{ item.pkg }}" || : [ "{{ item.pkg_type }}" = deb ] && dpkg-deb -I "{{ item.pkg }}" || : [ "{{ item.pkg_type }}" = rpm ] && rpm -qp "{{ item.pkg }}" --info || : pkg: - pkg: "aircrack-ng_{{ pkg_deb_revision }}_amd64.deb" pkg_name: aircrack-ng pkg_type: deb pkg_template: "aircrack-ng_VERSION_ARCH.deb" pkg_deps: "--category net --deb-priority optional -d iw -d wireless-tools -d ethtool -d usbutils -d rfkill -d libc6 -d libgcc1 -d libltdl7 -d libnl-3-200 -d libnl-genl-3-200 -d libstdc++6" pkg_content: "usr/bin usr/include usr/lib usr/sbin usr/share/man" pkg_version: "{{ pkg_deb_revision }}" - pkg: "aircrack-ng-{{ pkg_rpm_revision }}.x86_64.rpm" pkg_name: aircrack-ng pkg_type: rpm pkg_template: "aircrack-ng-VERSION.ARCH.rpm" pkg_deps: "-d iw -d wireless-tools -d ethtool -d usbutils -d rfkill -d glibc -d libgcc -d libtool-ltdl -d libnl3 -d libstdc++" pkg_content: "usr/bin usr/include usr/lib usr/sbin usr/share/man" pkg_version: "{{ pkg_rpm_revision }}" - command: mktemp -d register: destdir - shell: script: ./evalrev | sed -e 's/_rev//g' register: revision - command: git rev-parse HEAD register: commit_id - command: git rev-parse --abbrev-ref HEAD register: branch - shell: script: 'git describe --abbrev=0 --tags 2>/dev/null || echo unknown' register: closest_tag - shell: script: 'git describe --abbrev=0 --tags --exact-match 2>/dev/null || echo' register: exact_tag - command: date -u +%Y%m%d%H%M%S register: pkg_date # Development package naming - name: Calculating the Debian package version command: echo {{ closest_tag }}+git{{ pkg_date }}-1 register: pkg_deb_revision when: "exact_tag | trim | count == 0" - name: Calculating the RPM package version shell: script: echo {{ closest_tag }}.{% print pkg_date.stdout[:8] %}git$(git rev-parse --short HEAD) register: pkg_rpm_revision when: "exact_tag | trim | count == 0" # Stable package naming - name: Calculating the Debian package version command: echo {{ exact_tag }}-1 register: pkg_deb_revision when: "exact_tag | trim | count > 0" - name: Calculating the RPM package version shell: script: echo {{ exact_tag }} register: pkg_rpm_revision when: "exact_tag | trim | count > 0" - name: Metadata Evaluation echo: | destdir : {{ destdir }} revision : {{ revision }} commit : {{ commit_id }} branch : {{ branch }} closest_tag : {{ closest_tag }} exact_tag : {{ exact_tag }} pkg_date : {{ pkg_date }} pkg_deb_revision: {{ pkg_deb_revision }} pkg_rpm_revision: {{ pkg_rpm_revision }} - name: Packaging Build tags: - pkg stage: tasks: - name: Clean build artifacts shell: script: | find . -name '.deps' -a -type d -exec rm -fr {} ';' 2>/dev/null || : find . -name '.libs' -a -type d -exec rm -fr {} ';' 2>/dev/null || : silent: true - name: Ensure configure is present command: autoreconf -vi - name: Configure command: > ./configure --prefix=/usr --with-experimental --enable-static-crypto --enable-static-hwloc --enable-static-sqlite3 --enable-static-pcre --enable-static-pcap - name: Make clean shell: script: make clean silent: true - name: Compile shell: script: make V=1 silent: true - name: Run unit-tests command: make check - name: Staging Installation command: "make install-strip DESTDIR={{ destdir }}" - name: Produce dist artifacts command: make dist - name: Packaging shell: script: "{{ fpm }}" with_items: "{{ pkg }}" - name: Packaging Deployment tags: - deploy stage: tasks: - name: Deploying development packages to the web server tags: - www stage: tasks: - shell: script: | {% set path = "{{ www }}/{{ artifacts }}/development/{{ commit_id }}/{{ item.pkg_type }}" %} {% set prefix = "{{ www }}/{{ artifacts }}" %} mkdir -p "{{ path }}" chmod 777 "{{ www }}/{{ artifacts }}/development/{{ commit_id }}" chmod 777 "{{ path }}" ( cd "{{ prefix }}/development" && ln -sfnd "{{ commit_id }}" "{{ branch }}" ) cp -p "{{ item.pkg }}" "{{ path }}" chmod 664 "{{ path }}/{{ item.pkg }}" with_items: "{{ pkg }}" - shell: script: | {% set path = "{{ www }}/{{ artifacts }}/development/{{ commit_id }}" %} find . -name '*.zip' -o -name '*.tar.*' -print0 | xargs -0 -I {} cp -p {} "{{ path }}" - name: Deploying development package manifest tags: - www shell: script: | mkdir -p "{{ www }}/{{ artifacts }}" cat > "{{ www }}/{{ artifacts }}/development.json" <<-EOF { "build": "development", "commit": "{{ commit_id }}", "tag": "{{ closest_tag }}", "date": "$(date -u)", "url": "https://packages.aircrack-ng.org/artifacts/aircrack-ng/development/{{ commit_id }}" } EOF - name: Deploying stable packages to the web server tags: - www shell: script: | {% set prefix = "{{ www }}/{{ artifacts }}" %} mkdir -p "{{ prefix }}/stable" chmod 777 "{{ prefix }}/stable" ( cd "{{ prefix }}/stable" && ln -sfnd "../development/{{ commit_id }}" "{{ exact_tag }}" ) when: "exact_tag | trim | count > 0" - name: Deploying stable package manifest tags: - www shell: script: | cat > "{{ www }}/{{ artifacts }}/stable.json" <<-EOF { "build": "stable", "commit": "{{ commit_id }}", "tag": "{{ exact_tag }}", "date": "$(date -u)", "url": "https://packages.aircrack-ng.org/artifacts/aircrack-ng/stable/{{ exact_tag }}" } EOF when: "exact_tag | trim | count > 0" - name: Deploying development packages to PackageCloud.io tags: - package_cloud matrix: tags: - deb - rpm tasks: - name: Deploy Debian Packages when: "matrix_tag == 'deb'" matrix: tags: - debian/jessie - debian/stretch - debian/buster - elementaryos/loki - linuxmint/sylvia - linuxmint/tara - linuxmint/tessa - raspbian/buster - ubuntu/xenial - ubuntu/bionic - ubuntu/cosmic tasks: - command: "package_cloud push --yes aircrack-ng/git/{{ matrix_tag }} {{ item.pkg }}" with_items: "{{ pkg | selectattr('pkg_type', 'equalto', 'deb') | list }}" - command: "package_cloud push --yes aircrack-ng/release/{{ matrix_tag }} {{ item.pkg }}" when: "exact_tag | trim | count > 0" with_items: "{{ pkg | selectattr('pkg_type', 'equalto', 'deb') | list }}" - name: Deploy RPM Packages when: "matrix_tag == 'rpm'" matrix: tags: - el/7 - fedora/27 - fedora/28 - fedora/29 - opensuse/42.1 - opensuse/42.2 - opensuse/42.3 - sles/12.0 - sles/12.1 - sles/12.2 - sles/12.3 - sles/15.0 tasks: - command: "package_cloud push --yes aircrack-ng/git/{{ matrix_tag }} {{ item.pkg }}" with_items: "{{ pkg | selectattr('pkg_type', 'equalto', 'rpm') | list }}" - command: "package_cloud push --yes aircrack-ng/release/{{ matrix_tag }} {{ item.pkg }}" when: "exact_tag | trim | count > 0" with_items: "{{ pkg | selectattr('pkg_type', 'equalto', 'rpm') | list }}" aircrack-ng-1.6/build/pvs-studio.sh000077500000000000000000000002331361312141100173030ustar00rootroot00000000000000#!/bin/sh set -euf pvs-studio-analyzer analyze -j8 -o PVS-Studio.log plog-converter -a 'GA:1,2,3;64:1,2,3;OP:1,2,3' -d V1042 -t errorfile PVS-Studio.log aircrack-ng-1.6/build/travis-format.sh000077500000000000000000000031751361312141100177740ustar00rootroot00000000000000#!/usr/bin/env bash # # Copyright (C) 2017 Joseph Benden # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA # Params to script are: # 1st = Short name # 2nd = Long name # 3rd+ = Code/Script under test set -euf SHORTNAME="$1"; shift LONGNAME="$1"; shift # # Begin our fold # echo -e 'travis_fold:start:'"${SHORTNAME}"'\n\e[0K\e[33;1m'"${LONGNAME}"'\e[0m' # # Begin a timed block # if [ "$TRAVIS_OS_NAME" == "osx" ]; then SHA256SUM="shasum -a 256" else SHA256SUM="sha256sum" fi START=$(python -c 'import time; print "%.9f" % time.time()' | tr -d '.') TOKEN=$(echo "${START}" | $SHA256SUM | cut -c1-7) echo -e "travis_time:start:${TOKEN}" # # Code under test is here! # set +e "$@" rc=$? set -e # # End a timed block # END=$(python -c 'import time; print "%.9f" % time.time()' | tr -d '.') ELAPSED=$(echo "$END - $START" | bc) echo -e "travis_time:end:${TOKEN}:start=${START},finish=${END},duration=${ELAPSED}" # # End our fold # echo -e "travis_fold:end:${SHORTNAME}" exit $rc aircrack-ng-1.6/build/travis-formatting.sh000077500000000000000000000023221361312141100206470ustar00rootroot00000000000000#!/bin/sh # # Bail on OS X for testing this functionality. # if [ "x${TRAVIS_OS_NAME:-}" = "xosx" ]; then exit 0 fi # # Only works with GCC. # case "$CC" in clang*|llvm*) exit 0;; esac sudo add-apt-repository -y 'deb http://apt.llvm.org/precise/ llvm-toolchain-precise-3.8 main' wget -O - http://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - sudo apt-get update -qq sudo apt-get install --allow-unauthenticated -y -qq clang-format-3.8 # check formatting matches clang-format-3.8. Since newer versions can have # changes in formatting even without any rule changes, we have to fix on a # single version. . ./build/clang_format_all.sh git clean -f # Print any diff here, so the error message below is the last thing git diff set -e git diff --quiet || ( echo "***************************************************"; echo "*** The code is not clean against clang-format ***"; echo "*** Please run clang-format-3.8 and fix the ***"; echo "*** differences then rebase/squash them into ***"; echo "*** the relevant commits. Do not add a commit ***"; echo "*** for just formatting fixes. Thanks! ***"; echo "***************************************************"; exit 1; ) exit 0 aircrack-ng-1.6/build/valgrind.supp000066400000000000000000000025221361312141100173510ustar00rootroot00000000000000{ Memcheck:Leak match-leak-kinds: possible fun:calloc fun:allocate_dtv fun:_dl_allocate_tls fun:allocate_stack fun:pthread_create@@GLIBC_2.2.5 fun:main } { Memcheck:Leak match-leak-kinds: definite fun:malloc fun:hwloc_bitmap_dup fun:hwloc_distrib fun:hwloc_distrib fun:hwloc_distrib fun:hwloc_distrib fun:hwloc_distrib fun:hwloc_distrib fun:hwloc_distrib fun:ac_cpuset_distribute fun:main } { Memcheck:Leak match-leak-kinds: indirect fun:malloc fun:hwloc_bitmap_dup fun:hwloc_distrib fun:hwloc_distrib fun:hwloc_distrib fun:hwloc_distrib fun:hwloc_distrib fun:hwloc_distrib fun:hwloc_distrib fun:ac_cpuset_distribute fun:main } { Memcheck:Leak match-leak-kinds: reachable fun:calloc fun:_dlerror_run fun:dlopen@@GLIBC_2.2.5 fun:ac_crypto_engine_loader_load fun:load_aircrack_crypto_dso fun:main } { Memcheck:Leak match-leak-kinds: reachable fun:calloc fun:numa_bitmask_alloc ... } { Memcheck:Leak match-leak-kinds: reachable ... fun:call_init.part.0 fun:call_init fun:_dl_init ... } aircrack-ng-1.6/centos_autotools.sh000077500000000000000000000033021361312141100174730ustar00rootroot00000000000000#!/bin/sh AUTO_INSTALL=0 is_installed() { yum list installed $1 >/dev/null 2>/dev/null if [ $? -eq 1 ]; then if [ ${AUTO_INSTALL} -eq 1 ]; then yum install $1 if [ $? -ne 0 ]; then echo "Failed installing $1, aborting" exit 1 fi else echo "$1 is missing" exit 1 fi fi } is_installed epel-release is_installed tar is_installed wget is_installed glib2-devel is_installed gcc is_installed g++ is_installed make autoconf_version=2.69 automake_version=1.16.1 libtool_version=2.4.6 pkgconf_version=0.29 echo "Installing autoconf ${autoconf_version}" wget http://ftp.gnu.org/gnu/autoconf/autoconf-${autoconf_version}.tar.xz \ && tar xJf autoconf-${autoconf_version}.tar.xz \ && cd autoconf-${autoconf_version} \ && ./configure --prefix=/usr/local \ && make \ && make install \ && cd .. echo "Installing automake ${automake_version}" wget http://ftp.gnu.org/gnu/automake/automake-${automake_version}.tar.xz \ && tar xJf automake-${automake_version}.tar.xz \ && cd automake-${automake_version} \ && ./configure --prefix=/usr/local \ && make \ && make install \ && cd .. echo "Installing libtool ${libtool_version}" wget http://ftp.gnu.org/gnu/libtool/libtool-${libtool_version}.tar.xz \ && tar xJf libtool-${libtool_version}.tar.xz \ && cd libtool-${libtool_version} \ && ./configure --prefix=/usr/local \ && make \ && make install \ && cd .. echo "Installing pkg-config ${pkgconf_version}" wget https://pkg-config.freedesktop.org/releases/pkg-config-${pkgconf_version}.tar.gz \ && tar xzf pkg-config-${pkgconf_version}.tar.gz \ && cd pkg-config-${pkgconf_version} \ && ./configure --prefix=/usr/local --libdir=/usr/lib64 \ && make \ && make install \ && cd .. echo 'Done' aircrack-ng-1.6/configure.ac000066400000000000000000000200751361312141100160240ustar00rootroot00000000000000# Aircrack-ng # # Copyright (C) 2017-2020 Joseph Benden # # Autotool support was written by: Joseph Benden # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA # # In addition, as a special exception, the copyright holders give # permission to link the code of portions of this program with the # OpenSSL library under certain conditions as described in each # individual source file, and distribute linked combinations # including the two. # # You must obey the GNU General Public License in all respects # for all of the code used other than OpenSSL. # # If you modify file(s) with this exception, you may extend this # exception to your # version of the file(s), but you are not obligated # to do so. # # If you # do not wish to do so, delete this exception statement from your # version. # # If you delete this exception statement from all source files in the # program, then also delete it here. m4_define([version_date], "January 2020") m4_define([version_major], 1) m4_define([version_minor], 6) m4_define([version_micro], 0) m4_define([version_beta], 0) m4_define([version_rc], 0) m4_define([version_scm],[m4_translit(m4_esyscmd([$(pwd)/evalrev . scm || echo]),m4_newline)]) m4_define([version_triplet],version_major.version_minor.version_micro) m4_append([version_triplet],version_scm) AC_PREREQ([2.52]) AC_INIT([aircrack-ng], [version_triplet], [https://forum.aircrack-ng.org]) # # Cross-Compilation # AC_CANONICAL_BUILD AC_CANONICAL_HOST AC_CANONICAL_TARGET # # Initialize Automake # AC_CONFIG_AUX_DIR([.]) AC_CONFIG_MACRO_DIR([build/m4/stubs]) AC_CONFIG_HEADERS([config.h]) AM_INIT_AUTOMAKE([1.14 dist-bzip2 dist-zip foreign subdir-objects]) AM_MAINTAINER_MODE([enable]) AC_SUBST([ACLOCAL_AMFLAGS], ["-I build/m4/stubs -I build/m4 \${ACLOCAL_FLAGS}"]) m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) # # Ensure MAKE is GNU compatible # if ! ${MAKE-make} --version /cannot/make/this >/dev/null 2>&1; then AC_MSG_ERROR([you don't seem to have GNU make; it is required]) fi # # Find tooling # AIRCRACK_NG_PROG_CC AIRCRACK_NG_PROG_CXX AC_PROG_INSTALL AM_PROG_AS PKG_PROG_PKG_CONFIG AM_PROG_CC_C_O # # Set versioning detail # AC_SUBST([_MAJ], [version_major]) AC_SUBST([_MIN], [version_minor]) AC_SUBST([_SUB_MIN], [version_micro]) AC_SUBST([_BETA], [version_beta]) AC_SUBST([_RC], [version_rc]) AC_SUBST([_SCM], [version_scm]) AC_SUBST([LT_VER], [version_major.version_minor.version_micro]) AC_SUBST([MAN_RELEASE_DATE], [version_date]) AC_SUBST([MAN_RELEASE_VERSION], ["Version version_triplet"]) AC_DEFINE([_REVISION], ["version_triplet"], [The version information of the project]) AC_DEFINE([LT_CYGWIN_VER], ["-version_major-version_minor-version_micro.dll"], [The Cygwin DLL version string suffix]) # # Initialize libtool # LT_INIT([win32-dll disable-static shared]) # # Operating Systems # AIRCRACK_NG_MAC AIRCRACK_NG_WINDOWS AIRCRACK_NG_OS_DETECT # # Required # AIRCRACK_NG_CRYPTO AIRCRACK_NG_ETHTOOL AIRCRACK_NG_LIBNL # # Optional # AIRCRACK_NG_AIRPCAP AIRCRACK_NG_EXPECT AIRCRACK_NG_EXPERIMENTAL AIRCRACK_NG_EXT_SCRIPTS AIRCRACK_NG_HWLOC AIRCRACK_NG_PCAP AIRCRACK_NG_PCRE AIRCRACK_NG_RFKILL AIRCRACK_NG_SQLITE AIRCRACK_NG_ZLIB PKG_CHECK_MODULES([CMOCKA], [cmocka], [ CMOCKA_FOUND=yes AC_SUBST([CMOCKA_CFLAGS]) AC_SUBST([CMOCKA_LIBS]) ], [CMOCKA_FOUND=no]) # # Extras, but needed # AIRCRACK_NG_LARGEFILE AX_ADD_FORTIFY_SOURCE AIRCRACK_NG_PTHREAD AX_LIB_SOCKET_NSL AC_CHECK_LIB([dl], [dlopen], [ LIBS="$LIBS -ldl" ], [:]) AC_CHECK_LIB([m], [sin], [ LIBS="$LIBS -lm" ], [:]) saved_cflags="$CFLAGS" CFLAGS="" AC_CHECK_FUNCS([posix_memalign aligned_alloc memalign __mingw_aligned_malloc _aligned_malloc], break) CFLAGS="$saved_cflags" # # Code Coverage Support # AIRCRACK_NG_CODE_COVERAGE # # Valgrind Support # AX_VALGRIND_CHECK # # Compiler set-up # AIRCRACK_NG_COMPILER_C AIRCRACK_NG_COMPILER_CXX # # Processor feature selection/detection # AIRCRACK_NG_SIMD_C AIRCRACK_NG_SIMD_CXX # # Optional analyzers # AIRCRACK_NG_ASAN AIRCRACK_NG_DUMA AIRCRACK_NG_JEMALLOC AIRCRACK_NG_TCMALLOC AIRCRACK_NG_TSAN # # Automake # AM_CONDITIONAL([HAVE_AIRPCAP_OR_PCAP], [test "$AIRPCAP" = yes -o "$PCAP_FOUND" = yes]) AM_CONDITIONAL([MULTIBIN], [test "$with_multibin" = yes]) AM_CONDITIONAL([ENABLE_INSTALLED_TESTS], [test "nope" = yes]) # for glib tests AM_CONDITIONAL([CMOCKA], [test "$CMOCKA_FOUND" = yes]) AM_CONDITIONAL([STATIC_BUILD], [test "$enable_static" = yes]) AM_CONDITIONAL([EXPECT], [test "$EXPECT_FOUND" = yes]) # # Save flags for build summary # summary_cflags="$CFLAGS" summary_cxxflags="$CXXFLAGS" summary_cppflags="$CPPFLAGS" summary_libs="$LIBS" # # Set final flags for build # CFLAGS="$opt_cflags $CFLAGS" CPPFLAGS="$opt_cppflags $CPPFLAGS" CXXFLAGS="$opt_cxxflags $CXXFLAGS" LIBS="$opt_libs $LIBS" # # Generate all build files # AC_CONFIG_FILES([ Makefile VERSION include/aircrack-ng/version.h manpages/airbase-ng.8 manpages/aircrack-ng.1 manpages/airdecap-ng.1 manpages/airdecloak-ng.1 manpages/aireplay-ng.8 manpages/airmon-ng.8 manpages/airodump-ng.8 manpages/airodump-ng-oui-update.8 manpages/airolib-ng.1 manpages/airserv-ng.8 manpages/airtun-ng.8 manpages/airventriloquist-ng.8 manpages/besside-ng.8 manpages/besside-ng-crawler.1 manpages/buddy-ng.1 manpages/easside-ng.8 manpages/ivstools.1 manpages/kstats.1 manpages/Makefile manpages/makeivs-ng.1 manpages/packetforge-ng.1 manpages/tkiptun-ng.8 manpages/wesside-ng.8 manpages/wpaclean.1 scripts/Makefile scripts/airdrop-ng/Makefile scripts/airdrop-ng/doc/Makefile scripts/airgraph-ng/Makefile scripts/airgraph-ng/man/Makefile scripts/versuck-ng/Makefile test/test-env.sh ]) AC_OUTPUT # # Output a summary of the build to be performed # cat < #include #include #include #include #include "osdep.h" #include "tap-win32/common.h" static const char * DEFAULT_ADAPT_NAME = "\\\\.\\airpcap00"; static const char * DEVICE_HEADER = "\\\\.\\"; //pcap_t *winpcap_adapter; static PAirpcapHandle airpcap_handle; // Use PPI later #define PPH_PH_VERSION ((u_int8_t)0x00) #define PPI_FIELD_TYPE_802_11_COMMON ((u_int16_t)0x02) typedef struct _PPI_PACKET_HEADER { u_int8_t PphVersion; u_int8_t PphFlags; u_int16_t PphLength; u_int32_t PphDlt; } PPI_PACKET_HEADER, *PPPI_PACKET_HEADER; typedef struct _PPI_FIELD_HEADER { u_int16_t PfhType; u_int16_t PfhLength; } PPI_FIELD_HEADER, *PPPI_FIELD_HEADER; typedef struct _PPI_FIELD_802_11_COMMON { u_int64_t TsfTimer; u_int16_t Flags; u_int16_t Rate; u_int16_t ChannelFrequency; u_int16_t ChannelFlags; u_int8_t FhssHopset; u_int8_t FhssPattern; int8_t DbmAntSignal; int8_t DbmAntNoise; } PPI_FIELD_802_11_COMMON, *PPPI_FIELD_802_11_COMMON; static int ppi_decode(const u_char *p, int caplen, int *hdrlen, int *power) { PPPI_PACKET_HEADER pPpiPacketHeader; PPPI_FIELD_HEADER pFieldHeader; ULONG position = 0; // Sanity checks if (caplen < sizeof(*pPpiPacketHeader)) { // Packet smaller than the PPI fixed header return( 1 ); } pPpiPacketHeader = (PPPI_PACKET_HEADER)p; *hdrlen = pPpiPacketHeader->PphLength; if(caplen < *hdrlen) { // Packet smaller than the PPI fixed header return( 1 ); } position = sizeof(*pPpiPacketHeader); if (pPpiPacketHeader->PphVersion != PPH_PH_VERSION) { fprintf( stderr, "Unknown PPI packet header version (%u)\n", pPpiPacketHeader->PphVersion); return( 1 ); } do { // now we suppose to have an 802.11-Common header if (*hdrlen < sizeof(*pFieldHeader) + position) { break; } pFieldHeader = (PPPI_FIELD_HEADER)(p + position); position += sizeof(*pFieldHeader); switch(pFieldHeader->PfhType) { case PPI_FIELD_TYPE_802_11_COMMON: if (pFieldHeader->PfhLength != sizeof(PPI_FIELD_802_11_COMMON) || caplen - position < sizeof(PPI_FIELD_802_11_COMMON)) { // the header is bogus, just skip it fprintf( stderr, "Bogus 802.11-Common Field. Skipping it.\n"); } else { PPPI_FIELD_802_11_COMMON pField = (PPPI_FIELD_802_11_COMMON)(p + position); if (pField->DbmAntSignal != -128) { *power = (int)pField->DbmAntSignal; } else { *power = 0; } } break; default: // we do not know this field. Just print type and length and skip break; } position += pFieldHeader->PfhLength; } while(TRUE); return( 0 ); } int cygwin_set_mac(unsigned char *mac) { if (*mac) {} return 0; } void cygwin_close(void) { // By default, when plugged in, the adapter is set in monitor mode; // Application may assume it's already in monitor mode and forget to set it // So, do not remove monitor mode. if (airpcap_handle != NULL) { AirpcapClose(airpcap_handle); } } int cygwin_get_mac(unsigned char *mac) { // Don't use the function from Airpcap if (*mac) {} return 0; } // Use PPI headers to obtain the different information for ri // Use AirpcapConvertFrequencyToChannel() to get channel // Add an option to give frequency instead of channel int cygwin_sniff(void *buf, int len, struct rx_info *ri) { UINT BytesReceived = 0; // Wait for the next packet // Maybe add an event packets to read // WaitForSingleObject(ReadEvent, INFINITE); // Read a packet if(AirpcapRead(airpcap_handle, buf, len, &BytesReceived)) return (int)BytesReceived; return -1; } int cygwin_inject(void *buf, int len, struct tx_info *ti) { if (AirpcapWrite (airpcap_handle, buf, len) != 1) return -1; return len; } static int printErrorCloseAndReturn(const char * err, int retValue) { if (err && airpcap_handle) { if (strlen(err)) { if (airpcap_handle) fprintf( stderr, err, AirpcapGetLastError(airpcap_handle)); else fprintf( stderr, err); } } cygwin_close(); return retValue; } int cygwin_init(char *param) { char * iface; char errbuf[AIRPCAP_ERRBUF_SIZE ]; iface = (char *)calloc(1, strlen(param) + strlen(DEVICE_HEADER) +1); strcpy (iface, DEFAULT_ADAPT_NAME); if (param) { // if it's empty, use the default adapter if (strlen(param) > 0) { // Make sure the adapter name contains the '\\.\' at its beginning memset(iface, 0, strlen(param) + strlen(DEVICE_HEADER) +1); if (strstr(param, DEVICE_HEADER) == NULL) { // Not found, add it strcpy(iface, DEVICE_HEADER); strcat(iface, param); } else { // Already contains the adapter header strcpy(iface, param); } } } airpcap_handle = AirpcapOpen(iface, errbuf); if(airpcap_handle == NULL) { fprintf( stderr, "This adapter doesn't have wireless extensions. Quitting\n"); //pcap_close( winpcap_adapter ); return( -1 ); } /* Tell the adapter that the packets we'll send and receive don't include the FCS */ if(!AirpcapSetFcsPresence(airpcap_handle, FALSE)) return printErrorCloseAndReturn("Error setting FCS presence: %s\n", -1); /* Set the link layer to bare 802.11 */ if(!AirpcapSetLinkType(airpcap_handle, AIRPCAP_LT_802_11)) return printErrorCloseAndReturn("Error setting the link type: %s\n", -1); /* Accept correct frames only */ if( !AirpcapSetFcsValidation(airpcap_handle, AIRPCAP_VT_ACCEPT_CORRECT_FRAMES) ) return printErrorCloseAndReturn("Error setting FCS validation: %s\n", -1); /* Set a low mintocopy for better responsiveness */ if(!AirpcapSetMinToCopy(airpcap_handle, 1)) return printErrorCloseAndReturn("Error setting MinToCopy: %s\n", -1); return 0; } int cygwin_set_chan(int chan) { // Make sure a valid channel is given if (chan <= 0) return -1; if(!AirpcapSetDeviceChannel(airpcap_handle, chan)) { printf("Error setting the channel to %d: %s\n", chan, AirpcapGetLastError(airpcap_handle)); return -1; } return 0; } aircrack-ng-1.6/contrib/commview/000077500000000000000000000000001361312141100170205ustar00rootroot00000000000000aircrack-ng-1.6/contrib/commview/Makefile000066400000000000000000000004111361312141100204540ustar00rootroot00000000000000ROOT = ../.. include $(ROOT)/common.mak CFLAGS += $(PIC) -I$(ROOT)/src/osdep OBJS = commview.o DLL = commview.dll LIBS = -liphlpapi -lsetupapi -luuid -lpthread all: $(DLL) $(DLL): $(OBJS) $(CC) -shared -o $(DLL) $(OBJS) $(LIBS) clean: rm -f $(DLL) $(OBJS) aircrack-ng-1.6/contrib/commview/commview.c000066400000000000000000000315211361312141100210140ustar00rootroot00000000000000#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "osdep.h" #include "tap-win32/common.h" #define BUFSIZE 0x3E8000 struct CV_Header { unsigned int TickCount; // GetTickCount() / 1000 at time of packet unsigned int Micros; // Microsecond counter at time of packet /* The following might be backwards, unsure */ int PacketSize; // Full packet size? int SliceSize; // Truncated packet size? int Unknown; // Not sure what this is. }; struct CV_Header2 { char ErrorFlag; // ErrorFlag & 1 = CRC error char Unknown2[6]; // Unknown char Power; // Power char Unknown3[6]; // Unknown }; struct cstate { char cs_param[256]; int cs_ioctls; struct ifreq cs_ifreq; char cs_guid[256]; HKEY cs_key; int cs_chan; volatile int cs_restarting; void *cs_lib; pthread_mutex_t cs_mtx; int cs_debug; char (__cdecl *cs_F1)(int Code); char (__cdecl *cs_F2)(void); char (__cdecl *cs_T1)(int Size, unsigned char *Buffer); char (__cdecl *cs_CC)(int Channel); char (__cdecl *cs_S1)(int Channel); int (__cdecl *cs_S5)(unsigned char *Buffer, int Length); int (__cdecl *cs_GN)(wchar_t *); int (*cs_SC)(int band); } _cs; static struct cstate *get_cs(void) { return &_cs; } static int print_error(char *fmt, ...) { va_list ap; va_start(ap, fmt); vprintf(fmt, ap); va_end(ap); printf("\n"); return -1; } static void print_debug(char *fmt, ...) { struct cstate *cs = get_cs(); va_list ap; if (!cs->cs_debug) return; va_start(ap, fmt); vprintf(fmt, ap); va_end(ap); printf("\n"); } static int do_init_lib(struct cstate *cs) { /* init */ if (!cs->cs_F1(BUFSIZE)) return print_error("F1"); /* start monitor */ if (!cs->cs_S1(cs->cs_chan)) return print_error("S1"); /* change chan */ if (!cs->cs_CC(cs->cs_chan)) return print_error("CC"); return 0; } static int init_lib(struct cstate *cs) { char *lib = "ca2k.dll"; void *ca2k_dll; ca2k_dll = dlopen(lib, RTLD_LAZY); if (!ca2k_dll) return print_error("dlopen(%s)", lib); cs->cs_lib = ca2k_dll; // Initialise cs->cs_F1 = dlsym(ca2k_dll, "F1"); // Transmit cs->cs_T1 = dlsym(ca2k_dll, "T1"); // Change monitoring channel cs->cs_CC = dlsym(ca2k_dll, "CC"); // Start monitoring cs->cs_S1 = dlsym(ca2k_dll, "S1"); // Read packets cs->cs_S5 = dlsym(ca2k_dll, "S5"); // Finalize cs->cs_F2 = dlsym(ca2k_dll, "F2"); // Get Adapter Name cs->cs_GN = dlsym(ca2k_dll, "GN"); if (!(cs->cs_F1 && cs->cs_T1 && cs->cs_CC && cs->cs_S1 && cs->cs_S5 && cs->cs_F2 && cs->cs_GN)) return print_error("Can't find syms"); return do_init_lib(cs); } static int get_name(struct cstate *cs, char *name) { wchar_t wname[1024]; unsigned int i; if (!(cs->cs_GN(wname) & 1)) return print_error("GN()"); /* XXX */ for (i = 0; i < (sizeof(wname)/sizeof(wchar_t)); i++) { if (wname[i] == 0) break; *name++ = (char) ((unsigned char) wname[i]); } *name = 0; return 0; } static int get_guid(struct cstate *cs, char *param) { IP_ADAPTER_INFO ai[16]; DWORD len = sizeof(ai); PIP_ADAPTER_INFO p; char name[1024]; int found; if (get_name(cs, name) == -1) return print_error("get_name()"); print_debug("Name: %s", name); if (GetAdaptersInfo(ai, &len) != ERROR_SUCCESS) return print_error("GetAdaptersInfo()"); p = ai; while (p) { print_debug("get_guid: name: %s desc: %s", p->AdapterName, p->Description); found = (param && strcmp(p->AdapterName, param) == 0) || strstr(p->Description, name); /* XXX */ if (cs->cs_debug) { char yea[512]; printf("Does this look like your card? [y/n]\n"); yea[0] = 0; fgets(yea, sizeof(yea), stdin); if (yea[0] == 'y') found = 1; else found = 0; } if (found) { snprintf(cs->cs_guid, sizeof(cs->cs_guid)-1, "%s", p->AdapterName); return 0; } p = p->Next; } return print_error("Adapter not found"); } static int open_key(struct cstate *cs, char *name) { char key[256]; DWORD dt, len = sizeof(key); /* open key */ snprintf(key, sizeof(key)-1, "%s\\%s", ADAPTER_KEY, name); if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, key, 0, KEY_ALL_ACCESS, &cs->cs_key) != ERROR_SUCCESS) return print_error("RegOpenKeyEx()"); /* check if its our guid */ if ((RegQueryValueEx(cs->cs_key, "NetCfgInstanceId", NULL, &dt, (unsigned char*)key, &len) == ERROR_SUCCESS) && (dt == REG_SZ) && (strcmp(key, cs->cs_guid) == 0)) return 1; /* closekey done by cleanup */ /* nope */ RegCloseKey(cs->cs_key); cs->cs_key = NULL; return 0; } static int open_conf(struct cstate *cs) { HKEY ak47; int rc = -1; int i; char name[256]; DWORD len; if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, ADAPTER_KEY, 0, KEY_READ, &ak47) != ERROR_SUCCESS) return print_error("RegOpenKeyEx()"); for (i = 0;; i++) { len = sizeof(name); if (RegEnumKeyEx(ak47, i, name, &len, NULL, NULL, NULL, NULL) != ERROR_SUCCESS) break; rc = open_key(cs, name); if (rc) break; else rc = -1; } RegCloseKey(ak47); return rc; } static int check_param(struct cstate *cs, char **p) { char *param = *p; /* assume it's ifname */ if (strncmp(param, "eth", 3) == 0) { snprintf(cs->cs_param, sizeof(cs->cs_param), "%s", param); snprintf(cs->cs_ifreq.ifr_name, sizeof(cs->cs_ifreq.ifr_name), "%s", cs->cs_param); cs->cs_ioctls = socket(PF_INET, SOCK_DGRAM, 0); if (cs->cs_ioctls == -1) { cs->cs_ioctls = 0; return print_error("socket()"); } } else if(strcmp(param, "debug") == 0) { cs->cs_debug = 1; *p = NULL; } return 0; } int cygwin_init(char *param) { struct cstate *cs = get_cs(); memset(cs, 0, sizeof(*cs)); cs->cs_chan = 1; if (pthread_mutex_init(&cs->cs_mtx, NULL)) return print_error("pthread_mutex_init()"); if (param) { if (check_param(cs, ¶m)) return -1; } if (init_lib(cs) == -1) return print_error("init_lib()"); if (get_guid(cs, param) == -1) return print_error("get_guid()"); if (open_conf(cs) == -1) return print_error("open_conf()"); return 0; } int cygwin_set_chan(int chan) { struct cstate *cs = get_cs(); if (!cs->cs_CC(chan)) return -1; cs->cs_chan = chan; return 0; } int cygwin_inject(void *buf, int len, struct tx_info *ti) { struct cstate *cs = get_cs(); if (ti) {} /* XXX unused */ if (!cs->cs_T1(len, buf)) return -1; return len; } static int read_single_packet(struct cstate *cs, unsigned char *buf, int len, struct rx_info *ri) { static unsigned char data[BUFSIZE]; static int totlen = 0; static unsigned char *next; struct CV_Header *cvh; struct CV_Header2 *cvh2; unsigned char *hdr; int align, plen; /* read data if necessary */ if (totlen == 0) { /* XXX can't kill iface if we're reading */ if (pthread_mutex_lock(&cs->cs_mtx)) return -1; totlen = cs->cs_S5(data, sizeof(data)); if (pthread_mutex_unlock(&cs->cs_mtx)) return -1; if (totlen < 1) return -1; next = data; } /* copy packet */ cvh = (struct CV_Header*) next; cvh2 = (struct CV_Header2*) (cvh+1); hdr = (unsigned char*) (cvh2+1); plen = cvh->SliceSize - sizeof(*cvh2); assert(plen > 0); if (plen < len) len = plen; memcpy(buf, hdr, len); if (ri) ri->ri_power = cvh2->Power; /* go to next packet */ next = hdr + plen; align = ((unsigned long)next - (unsigned long)cvh ) % 4; if (align) align = 4 - align; next += align; totlen -= sizeof(*cvh) + cvh->SliceSize; assert(totlen >= 0); if (totlen > 0) totlen -= align; assert(totlen >= 0); return (cvh2->ErrorFlag & 1) ? 0 : len; } int cygwin_sniff(void *buf, int len, struct rx_info *ri) { struct cstate *cs = get_cs(); int rc; int tries = 60; while ((rc = read_single_packet(cs, buf, len, ri)) == 0); if (rc != -1) return rc; /* check if we're restarting */ while (cs->cs_restarting && tries--) { /* try again */ if (cs->cs_restarting == 2) { cs->cs_restarting = 0; return cygwin_sniff(buf, len, ri); } sleep(1); } return rc; } static int do_get_mac_win(struct cstate *cs, unsigned char *mac) { IP_ADAPTER_INFO ai[16]; DWORD len = sizeof(ai); PIP_ADAPTER_INFO p; if (GetAdaptersInfo(ai, &len) != ERROR_SUCCESS) return -1; p = ai; while (p) { if (strcmp(cs->cs_guid, p->AdapterName) == 0) { memcpy(mac, p->Address, 6); return 0; } p = p->Next; } return -1; } static int do_get_mac_cygwin(struct cstate *cs, unsigned char *mac) { if (ioctl(cs->cs_ioctls, SIOCGIFHWADDR, &cs->cs_ifreq) == -1) return -1; memcpy(mac, cs->cs_ifreq.ifr_addr.sa_data, 6); return 0; } int cygwin_get_mac(unsigned char *mac) { struct cstate *cs = get_cs(); if (cs->cs_ioctls) return do_get_mac_cygwin(cs, mac); return do_get_mac_win(cs, mac); } static int is_us2(struct cstate *cs, HDEVINFO *hdi, SP_DEVINFO_DATA *did) { char buf[256]; DWORD len = sizeof(buf), dt; if (cs) {} /* XXX unused */ if (!SetupDiGetDeviceRegistryProperty(*hdi, did, SPDRP_DEVICEDESC, &dt, (unsigned char*)buf, len, &len)) return 0; if (dt != REG_SZ) return 0; return strstr(buf, "CommView") != NULL; } static int reset_state(HDEVINFO *hdi, SP_DEVINFO_DATA *did, DWORD state) { SP_PROPCHANGE_PARAMS parm; parm.ClassInstallHeader.cbSize = sizeof(parm.ClassInstallHeader); parm.ClassInstallHeader.InstallFunction = DIF_PROPERTYCHANGE; parm.Scope = DICS_FLAG_GLOBAL; parm.StateChange = state; if (!SetupDiSetClassInstallParams(*hdi, did, (SP_CLASSINSTALL_HEADER*) &parm, sizeof(parm))) return -1; if (!SetupDiCallClassInstaller(DIF_PROPERTYCHANGE, *hdi, did)) return -1; return 0; } static int do_reset(HDEVINFO *hdi, SP_DEVINFO_DATA *did) { int rc; rc = reset_state(hdi, did, DICS_DISABLE); if (rc) return rc; return reset_state(hdi, did, DICS_ENABLE); } static int restart(struct cstate *cs) { int rc; rc = do_init_lib(cs); return rc; } static int reset(struct cstate *cs) { HDEVINFO hdi; SP_DEVINFO_DATA did; int i; int rc = -1; hdi = SetupDiGetClassDevs(&GUID_DEVCLASS_NET, NULL, NULL, DIGCF_PRESENT); if (hdi == INVALID_HANDLE_VALUE) return -1; /* find device */ for (i = 0;; i++) { did.cbSize = sizeof(did); if (!SetupDiEnumDeviceInfo(hdi, i, &did)) break; if (!is_us2(cs, &hdi, &did)) continue; /* XXX we are blocked on reader. */ if (pthread_mutex_lock(&cs->cs_mtx)) break; cs->cs_restarting = 1; /* kill lib */ if (!cs->cs_F2()) break; /* reset NIC */ rc = do_reset(&hdi, &did); if (rc) break; sleep(1); /* XXX seems necessary */ /* reinit lib */ rc = restart(cs); cs->cs_restarting = 2; /* done */ if (pthread_mutex_unlock(&cs->cs_mtx)) break; break; } SetupDiDestroyDeviceInfoList(hdi); return rc; } int cygwin_set_mac(unsigned char *mac) { struct cstate *cs = get_cs(); char str[2*6+1]; char strold[sizeof(str)]; int i; char *key = "NetworkAddress"; DWORD dt, len = sizeof(strold); /* convert */ str[0] = 0; for (i = 0; i < 6; i++) { char tmp[3]; if (sprintf(tmp, "%.2X", *mac++) != 2) return -1; strcat(str, tmp); } /* check old */ if ((RegQueryValueEx(cs->cs_key, key, NULL, &dt, (unsigned char*) strold, &len) == ERROR_SUCCESS) && (dt == REG_SZ)) { if (strcmp(str, strold) == 0) return 0; } /* set */ if (RegSetValueEx(cs->cs_key, key, 0, REG_SZ, (unsigned char *)str, strlen(str)+1) != ERROR_SUCCESS) return -1; if (reset(cs) == -1) return -1; return 0; } void cygwin_close(void) { struct cstate *cs = get_cs(); if (cs->cs_ioctls) close(cs->cs_ioctls); if (cs->cs_key) RegCloseKey(cs->cs_key); if (cs->cs_lib) { cs->cs_F2(); dlclose(cs->cs_lib); } } aircrack-ng-1.6/contrib/peek/000077500000000000000000000000001361312141100161165ustar00rootroot00000000000000aircrack-ng-1.6/contrib/peek/Makefile000066400000000000000000000003601361312141100175550ustar00rootroot00000000000000ROOT = ../.. include $(ROOT)/common.mak CFLAGS += $(PIC) -I$(ROOT)/src/osdep NAME = omnipeek OBJS = $(NAME).o DLL = $(NAME).dll LIBS = all: $(DLL) $(DLL): $(OBJS) $(CC) -shared -o $(DLL) $(OBJS) $(LIBS) clean: rm -f $(DLL) $(OBJS) aircrack-ng-1.6/contrib/peek/omnipeek.c000066400000000000000000000132541361312141100200760ustar00rootroot00000000000000/* ripped from devine's windows airodump */ #include #include #include #include #include #include #include "osdep.h" #include "cygwin.h" #ifdef UNUSED #elif defined(__GNUC__) # define UNUSED(x) UNUSED_ ## x __attribute__((unused)) #elif defined(__LCLINT__) # define UNUSED(x) /*@unused@*/ x #else # define UNUSED(x) x #endif #define MAGIC1 0x3E8000 #define MAGIC2 0x21 #define MAGICCHAN 0xFF636713 struct pstate { void *ps_lib; HANDLE ps_adapter; HANDLE ps_ctx; pthread_cond_t ps_sem; pthread_mutex_t ps_mtx; unsigned char ps_data[4096]; int ps_len; int (*ps_peek_initialize_library)(void); HANDLE (*ps_peek_open_adapter)(LPSTR); int (*ps_peek_start_capture)(HANDLE); int (*ps_peek_request)(HANDLE, void*, void*); int (*ps_peek_stop_capture)(HANDLE); int (*ps_peek_close_adapter)(HANDLE); int (*ps_peek_packet_send)(HANDLE, void*, int, int*, LPOVERLAPPED, int); HANDLE (*ps_peek_create_capture_context)(HANDLE, void*, int, int, void*); } _pstate; static struct pstate *get_ps(void) { return &_pstate; } static int init_lib(struct pstate *ps) { char *libname = "Peek.dll"; void *lib; if (!(lib = dlopen(libname, RTLD_LAZY))) return -1; ps->ps_lib = lib; ps->ps_peek_open_adapter = dlsym(lib, "PeekOpenAdapter"); ps->ps_peek_start_capture = dlsym(lib, "PeekStartCapture"); ps->ps_peek_request = dlsym(lib, "PeekRequest"); ps->ps_peek_stop_capture = dlsym(lib, "PeekStopCapture"); ps->ps_peek_close_adapter = dlsym(lib, "PeekCloseAdapter"); ps->ps_peek_packet_send = dlsym(lib, "PeekPacketSend"); ps->ps_peek_create_capture_context = dlsym(lib, "PeekCreateCaptureContext"); ps->ps_peek_initialize_library = dlsym(lib, "PeekInitializeLibrary"); if (!(ps->ps_peek_open_adapter && ps->ps_peek_start_capture && ps->ps_peek_request && ps->ps_peek_stop_capture && ps->ps_peek_close_adapter && ps->ps_peek_packet_send && ps->ps_peek_create_capture_context && ps->ps_peek_initialize_library )) return -1; return 0; } static void do_cleanup(struct pstate *ps) { if (!ps->ps_lib) return; if (ps->ps_ctx != INVALID_HANDLE_VALUE) ps->ps_peek_stop_capture(ps->ps_ctx); if (ps->ps_adapter != INVALID_HANDLE_VALUE) ps->ps_peek_close_adapter(ps->ps_adapter); dlclose(ps->ps_lib); } static int set_chan(struct pstate *ps, int channel) { unsigned long reqdata[139]; OVERLAPPED iodata; memset(reqdata, 0, sizeof(reqdata)); memset(&iodata, 0, sizeof(iodata)); iodata.hEvent = CreateEvent(0, 0, 0, 0); reqdata[5] = 1; reqdata[6] = MAGICCHAN; reqdata[7] = (unsigned long) &channel; reqdata[8] = 4; return ps->ps_peek_request(ps->ps_adapter, reqdata, &iodata); } static void do_lock(struct pstate *ps) { if (pthread_mutex_lock(&ps->ps_mtx)) err(1, "pthread_mutex_lock()"); } static void do_signal(struct pstate *ps) { do_lock(ps); if (pthread_cond_signal(&ps->ps_sem)) err(1, "pthread_cond_signal()"); } static void do_wait(struct pstate *ps) { do_lock(ps); if (pthread_cond_wait(&ps->ps_sem, &ps->ps_mtx)) err(1, "pthread_cond_wait()"); } static int WINAPI callback(unsigned char *data, int len, int UNUSED(caplen), __int64 UNUSED(timestamp), int flags, int UNUSED(arg7)) { struct pstate *ps = get_ps(); if ((flags & 1) != 0) return 1; assert(len <= (int) sizeof(ps->ps_data)); ps->ps_len = len; memcpy(ps->ps_data, data, ps->ps_len); /* tell him we wrote */ do_signal(ps); /* wait for him to copy */ do_wait(ps); return 1; } static int init_card(struct pstate *ps, char *dev) { int rc, len; char *unicode, *p; if (ps->ps_peek_initialize_library() == 0) return -1; /* convert dev to unicode - i'm sure there's a standard function, but * aingottime. * Format: \Device\{GUID} */ if (!dev) return -1; len = strlen(dev); unicode = p = malloc((len+1)*2); if (!unicode) return -1; for (rc = 0; rc < len; rc++) { *p++ = dev[rc]; *p++ = 0; } *p++ = 0; *p++ = 0; ps->ps_adapter = ps->ps_peek_open_adapter(unicode); free(unicode); if (ps->ps_adapter == INVALID_HANDLE_VALUE) return -1; ps->ps_ctx = ps->ps_peek_create_capture_context(ps->ps_adapter, callback, MAGIC1, MAGIC2, NULL); if ((rc = ps->ps_peek_start_capture(ps->ps_ctx))) return rc; return set_chan(ps, 1); } int CYGWIN_DLL_INIT (char *param) { struct pstate *ps = get_ps(); int rc; memset(ps, 0, sizeof(*ps)); ps->ps_adapter = INVALID_HANDLE_VALUE; ps->ps_ctx = INVALID_HANDLE_VALUE; if ((rc = pthread_cond_init(&ps->ps_sem, NULL))) goto out; if ((rc = pthread_mutex_init(&ps->ps_mtx, NULL))) goto out; if ((rc = init_lib(ps))) goto out; if ((rc = init_card(ps, param))) goto out; return 0; out: do_cleanup(ps); return rc; } int CYGWIN_DLL_SET_CHAN (int chan) { struct pstate *ps = get_ps(); return set_chan(ps, chan) ? -1 : 0; } int CYGWIN_DLL_INJECT (void* buf, int len, struct tx_info* UNUSED(ti)) { struct pstate *ps = get_ps(); int rc; int wrote = 0; OVERLAPPED iodata; memset(&iodata, 0, sizeof(iodata)); iodata.hEvent = CreateEvent(0, 0, 0, 0); rc = ps->ps_peek_packet_send(ps->ps_adapter, buf, len, &wrote, &iodata, 0); if (rc) return rc; return len; } int CYGWIN_DLL_SNIFF (void *buf, int len, struct rx_info* UNUSED(ri)) { struct pstate *ps = get_ps(); /* wait for shit */ do_wait(ps); /* copy it */ if (ps->ps_len < len) len = ps->ps_len; memcpy(buf, ps->ps_data, len); /* tell him we're done */ do_signal(ps); return len; } int CYGWIN_DLL_GET_MAC (unsigned char* UNUSED(mac)) { return -1; } int CYGWIN_DLL_SET_MAC (unsigned char* UNUSED(mac)) { return -1; } void CYGWIN_DLL_CLOSE (void) { struct pstate *ps = get_ps(); do_cleanup(ps); } aircrack-ng-1.6/evalrev000077500000000000000000000030241361312141100151230ustar00rootroot00000000000000#!/bin/sh set -euf DIR=${1:-} CMD=${2:-} SCM="" if [ x$DIR = "x" ] then DIR="." fi if test -d "${DIR}/.git"; then # # Locate the closest annotated tag # REVISION="$(git describe --abbrev=0 --tags 2>/dev/null || echo unknown)" # # Determine if we are a development branch, if so then append the # short SHA1. # EXACTLY="$(git describe --abbrev=0 --tags --exact-match 2>/dev/null || echo)" if test -z "$EXACTLY"; then REVISION="${REVISION}_rev-$(git rev-parse --verify --short HEAD)" SCM="_rev-$(git rev-parse --verify --short HEAD)" fi elif test -d "${DIR}/.svn"; then REVISION="_r$(svnversion $DIR 2> /dev/null | sed 's/[^0-9]*//g')" SCM="_r$(svnversion $DIR 2> /dev/null | sed 's/[^0-9]*//g')" if test x$REVISION = "x"; then REVISION="_r$(svn info $DIR 2> /dev/null | grep -i revision | sed 's/[^0-9]*//g')" SCM="_r$(svn info $DIR 2> /dev/null | grep -i revision | sed 's/[^0-9]*//g')" fi if test x$REVISION = "x"; then if test -f "${DIR}/.svn/entries"; then REVISION="_r$(cat ${DIR}/.svn/entries | grep -i revision | head -n 1 | sed 's/[^0-9]*//g')" SCM="_r$(cat ${DIR}/.svn/entries | grep -i revision | head -n 1 | sed 's/[^0-9]*//g')" fi fi if test x$REVISION = "x"; then REVISION="_r1" SCM="_r1" fi else REVISION="$(cat ${DIR}/VERSION)" fi if test "x$CMD" = "xscm"; then echo $SCM elif test "x$CMD" = "xquoted"; then echo \"$REVISION\" else echo $REVISION fi aircrack-ng-1.6/include/000077500000000000000000000000001361312141100151555ustar00rootroot00000000000000aircrack-ng-1.6/include/Makefile.inc000066400000000000000000000114531361312141100173710ustar00rootroot00000000000000# Aircrack-ng # # Copyright (C) 2019 Joseph Benden # # Autotool support was written by: Joseph Benden # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA # # In addition, as a special exception, the copyright holders give # permission to link the code of portions of this program with the # OpenSSL library under certain conditions as described in each # individual source file, and distribute linked combinations # including the two. # # You must obey the GNU General Public License in all respects # for all of the code used other than OpenSSL. # # If you modify file(s) with this exception, you may extend this # exception to your dnl version of the file(s), but you are not obligated # to do so. # # If you dnl do not wish to do so, delete this exception statement from your # version. # # If you delete this exception statement from all source files in the # program, then also delete it here. aircrackdir = $(includedir)/../ nobase_aircrack_HEADERS = %D%/aircrack-ng/adt/avl_tree.h \ %D%/aircrack-ng/adt/circular_buffer.h \ %D%/aircrack-ng/adt/circular_queue.h \ %D%/aircrack-ng/aircrack-ng.h \ %D%/aircrack-ng/ce-wep/uniqueiv.h \ %D%/aircrack-ng/ce-wpa/wpapsk.h \ %D%/aircrack-ng/ce-wpa/arch.h \ %D%/aircrack-ng/ce-wpa/simd-intrinsics-load-flags.h \ %D%/aircrack-ng/ce-wpa/misc.h \ %D%/aircrack-ng/ce-wpa/simd-intrinsics.h \ %D%/aircrack-ng/ce-wpa/pseudo_intrinsics.h \ %D%/aircrack-ng/ce-wpa/memory.h \ %D%/aircrack-ng/ce-wpa/aligned.h \ %D%/aircrack-ng/ce-wpa/johnswap.h \ %D%/aircrack-ng/ce-wpa/memdbg.h \ %D%/aircrack-ng/ce-wpa/jcommon.h \ %D%/aircrack-ng/ce-wpa/crypto_engine.h \ %D%/aircrack-ng/cowpatty/cowpatty.h \ %D%/aircrack-ng/cpu/cpuset.h \ %D%/aircrack-ng/cpu/simd_cpuid.h \ %D%/aircrack-ng/cpu/trampoline.h \ %D%/aircrack-ng/crypto/crctable.h \ %D%/aircrack-ng/crypto/crypto.h \ %D%/aircrack-ng/crypto/gcrypt-openssl-wrapper.h \ %D%/aircrack-ng/crypto/sha1-git.h \ %D%/aircrack-ng/crypto/sha1-sse2.h \ %D%/aircrack-ng/defs.h \ %D%/aircrack-ng/osdep/byteorder.h \ %D%/aircrack-ng/osdep/channel.h \ %D%/aircrack-ng/osdep/common.h \ %D%/aircrack-ng/osdep/network.h \ %D%/aircrack-ng/osdep/osdep.h \ %D%/aircrack-ng/osdep/packed.h \ %D%/aircrack-ng/ptw/aircrack-ptw-lib.h \ %D%/aircrack-ng/support/common.h \ %D%/aircrack-ng/support/communications.h \ %D%/aircrack-ng/support/crypto_engine_loader.h \ %D%/aircrack-ng/support/fragments.h \ %D%/aircrack-ng/support/mcs_index_rates.h \ %D%/aircrack-ng/support/pcap_local.h \ %D%/aircrack-ng/support/station.h \ %D%/aircrack-ng/third-party/ieee80211.h \ %D%/aircrack-ng/third-party/if_arp.h \ %D%/aircrack-ng/third-party/eapol.h \ %D%/aircrack-ng/third-party/ethernet.h \ %D%/aircrack-ng/third-party/if_llc.h \ %D%/aircrack-ng/third-party/hashcat.h \ %D%/aircrack-ng/tui/console.h \ %D%/aircrack-ng/utf8/verifyssid.h \ %D%/aircrack-ng/version.h EXTRA_DIST += $(nobase_aircrack_HEADERS) aircrack-ng-1.6/include/aircrack-ng/000077500000000000000000000000001361312141100173365ustar00rootroot00000000000000aircrack-ng-1.6/include/aircrack-ng/adt/000077500000000000000000000000001361312141100201065ustar00rootroot00000000000000aircrack-ng-1.6/include/aircrack-ng/adt/avl_tree.h000066400000000000000000000132031361312141100220570ustar00rootroot00000000000000/** * collectd - src/utils_avltree.h * Copyright (C) 2006,2007 Florian octo Forster * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * * Authors: * Florian octo Forster **/ #ifndef UTILS_AVLTREE_H #define UTILS_AVLTREE_H 1 struct c_avl_tree_s; typedef struct c_avl_tree_s c_avl_tree_t; struct c_avl_iterator_s; typedef struct c_avl_iterator_s c_avl_iterator_t; /* * NAME * c_avl_create * * DESCRIPTION * Allocates a new AVL-tree. * * PARAMETERS * `compare' The function-pointer `compare' is used to compare two keys. It * has to return less than zero if its first argument is smaller * then the second argument, more than zero if the first argument * is bigger than the second argument and zero if they are equal. * If your keys are char-pointers, you can use the `strcmp' * function from the libc here. * * RETURN VALUE * A c_avl_tree_t-pointer upon success or NULL upon failure. */ c_avl_tree_t * c_avl_create(int (*compare)(const void *, const void *)); /* * NAME * c_avl_destroy * * DESCRIPTION * Deallocates an AVL-tree. Stored value- and key-pointer are lost, but of * course not freed. */ void c_avl_destroy(c_avl_tree_t * t); /* * NAME * c_avl_insert * * DESCRIPTION * Stores the key-value-pair in the AVL-tree pointed to by `t'. * * PARAMETERS * `t' AVL-tree to store the data in. * `key' Key used to store the value under. This is used to get back to * the value again. The pointer is stored in an internal structure * and _not_ copied. So the memory pointed to may _not_ be freed * before this entry is removed. You can use the `rkey' argument * to `avl_remove' to get the original pointer back and free it. * `value' Value to be stored. * * RETURN VALUE * Zero upon success, non-zero otherwise. It's less than zero if an error * occurred or greater than zero if the key is already stored in the tree. */ int c_avl_insert(c_avl_tree_t * t, void * key, void * value); /* * NAME * c_avl_remove * * DESCRIPTION * Removes a key-value-pair from the tree t. The stored key and value may be * returned in `rkey' and `rvalue'. * * PARAMETERS * `t' AVL-tree to remove key-value-pair from. * `key' Key to identify the entry. * `rkey' Pointer to a pointer in which to store the key. May be NULL. * Since the `key' pointer is not copied when creating an entry, * the pointer may not be available anymore from outside the tree. * You can use this argument to get the actual pointer back and * free the memory pointed to by it. * `rvalue' Pointer to a pointer in which to store the value. May be NULL. * * RETURN VALUE * Zero upon success or non-zero if the key isn't found in the tree. */ int c_avl_remove(c_avl_tree_t * t, const void * key, void ** rkey, void ** rvalue); /* * NAME * c_avl_get * * DESCRIPTION * Retrieve the `value' belonging to `key'. * * PARAMETERS * `t' AVL-tree to get the value from. * `key' Key to identify the entry. * `value' Pointer to a pointer in which to store the value. May be NULL. * * RETURN VALUE * Zero upon success or non-zero if the key isn't found in the tree. */ int c_avl_get(c_avl_tree_t * t, const void * key, void ** value); /* * NAME * c_avl_pick * * DESCRIPTION * Remove a (pseudo-)random element from the tree and return its `key' and * `value'. Entries are not returned in any particular order. This function * is intended for cache-flushes that don't care about the order but simply * want to remove all elements, one at a time. * * PARAMETERS * `t' AVL-tree to get the value from. * `key' Pointer to a pointer in which to store the key. * `value' Pointer to a pointer in which to store the value. * * RETURN VALUE * Zero upon success or non-zero if the tree is empty or key or value is * NULL. */ int c_avl_pick(c_avl_tree_t * t, void ** key, void ** value); c_avl_iterator_t * c_avl_get_iterator(c_avl_tree_t * t); int c_avl_iterator_next(c_avl_iterator_t * iter, void ** key, void ** value); int c_avl_iterator_prev(c_avl_iterator_t * iter, void ** key, void ** value); void c_avl_iterator_destroy(c_avl_iterator_t * iter); /* * NAME * c_avl_size * * DESCRIPTION * Return the size (number of nodes) of the specified tree. * * PARAMETERS * `t' AVL-tree to get the size of. * * RETURN VALUE * Number of nodes in the tree, 0 if the tree is empty or NULL. */ int c_avl_size(c_avl_tree_t * t); #endif /* UTILS_AVLTREE_H */ aircrack-ng-1.6/include/aircrack-ng/adt/circular_buffer.h000066400000000000000000000120351361312141100234150ustar00rootroot00000000000000/** * Copyright (C) 2018-2020 Joseph Benden * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. **/ #ifndef AIRCRACK_UTIL_CIRCULAR_BUFFER_H #define AIRCRACK_UTIL_CIRCULAR_BUFFER_H #include /** * @file circular_buffer.h * * @brief An implementation of a non-thread-safe circular buffer. * * @author Joseph Benden */ #ifdef __cplusplus extern "C" { #endif /// The type representing the internal data structure for a single /// circular buffer; unaccessible to public API consumers. typedef struct circular_buffer_t circular_buffer_t; /// The type representing a handle to a single circular buffer. typedef circular_buffer_t * cbuf_handle_t; /*! * @brief Create a new circular buffer. * @param[in] buffer A region of memory to be used for element storage. * @param[in] bufferSize The number of bytes available at @a buffer. * @param[in] elementSize The number of bytes used by a single entry stored. * @return A brand-new circular buffer handle, else NULL on error. */ API_IMPORT cbuf_handle_t circular_buffer_init(uint8_t * buffer, size_t bufferSize, size_t elementSize); /*! * @brief Release the memory used by the circular buffer. * @param[in] cbuf The circular buffer handle to operate upon. * * @par * The API consumer is expected to release the memory region * given to the @a circular_buffer_init function, by themselves. */ API_IMPORT void circular_buffer_free(cbuf_handle_t cbuf); /*! * @brief Reset the circular buffer back to its' initial state. * @param[in] cbuf The circular buffer handle to operate upon. */ API_IMPORT void circular_buffer_reset(cbuf_handle_t cbuf); /*! * @brief Store an entry to the circular buffer. * @param[in] cbuf The circular buffer handle to operate upon. * @param[in] data A buffer location for which we copy the data in from. * @param[in] size The length of the @a data memory buffer. This is * permitted to be less-than or equal-to the * element size. If less-than, the remaining bytes * of the element store are zeroed. * * @par * The memory location of @a data must not overlap the circular * buffer's memory location. This is because we internally use * the @f memcpy function. */ API_IMPORT void circular_buffer_put(cbuf_handle_t cbuf, void const * const data, size_t size); /*! * @brief Acquire an entry from the circular buffer. * @param[in] cbuf The circular buffer handle to operate upon. * @param[in] data A buffer location to which to copy the data out to. * @param[in] size The length of the @a data memory buffer. This is * permitted to be less-than or equal-to the * element size. * * @par * The memory location of @a data must not overlap the circular * buffer's memory location. This is because we internally use * the @f memcpy function. */ API_IMPORT void circular_buffer_get(cbuf_handle_t cbuf, void * const * data, size_t size); /*! * @brief Returns whether the circular buffer is empty. * @param[in] cbuf The circular buffer handle to operate upon. * @return A boolean representing the emptiness state of the * circular buffer. */ API_IMPORT bool circular_buffer_is_empty(cbuf_handle_t cbuf); /*! * @brief Returns whether the circular buffer is full. * @param[in] cbuf The circular buffer handle to operate upon. * @return A boolean representing the fullness state of the * circular buffer. */ API_IMPORT bool circular_buffer_is_full(cbuf_handle_t cbuf); /*! * @brief Returns the number of storable entries. * @param[in] cbuf The circular buffer handle to operate upon. * @return The number of entries that may be stored within the * circular buffer. */ API_IMPORT size_t circular_buffer_capacity(cbuf_handle_t cbuf); /*! * @brief Returns the number of currently stored entries. * @param[in] cbuf The circular buffer handle to operate upon. * @return The number of entries within the circular buffer. */ API_IMPORT size_t circular_buffer_size(cbuf_handle_t cbuf); #ifdef __cplusplus } #endif #endif aircrack-ng-1.6/include/aircrack-ng/adt/circular_queue.h000066400000000000000000000125471361312141100233000ustar00rootroot00000000000000/* * Copyright (C) 2018-2020 Joseph Benden * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ #ifndef AIRCRACK_UTIL_CIRCULAR_QUEUE_H #define AIRCRACK_UTIL_CIRCULAR_QUEUE_H #include /** * @file circular_queue.h * * @brief An implementation of a multi-threaded, blocking queue; which * internally uses a circular buffer for element storage. * * @author Joseph Benden */ #ifdef __cplusplus extern "C" { #endif /// The type representing the internal data structure for a single /// blocking circular queue; unaccessible to public API consumers. typedef struct circular_queue_t circular_queue_t; /// The type representing a handle to a single blocking circular queue. typedef circular_queue_t * cqueue_handle_t; /*! * @brief Create a new blocking circular queue. * @param[in] buffer A region of memory to be used for element storage. * @param[in] bufferSize The number of bytes available at @a buffer. * @param[in] elementSize The number of bytes used by a single entry stored. * @return A brand-new circular queue handle, else NULL on error. */ API_IMPORT cqueue_handle_t circular_queue_init(uint8_t * buffer, size_t bufferSize, size_t elementSize); /*! * @brief Release the memory used by the circular queue. * @param[in] cq The circular queue handle to operate upon. * * @par * The API consumer is expected to release the memory region * given to the @a circular_queue_init function, by themselves. */ API_IMPORT void circular_queue_free(cqueue_handle_t cq); /*! * @brief Reset the circular queue back to its initial state. * @param[in] cq The circular queue handle to operate upon. */ API_IMPORT void circular_queue_reset(cqueue_handle_t cq); /*! * @brief Store an entry to the circular queue. * @param[in] cq The circular queue handle to operate upon. * @param[in] data A buffer location for which we copy the data in from. * @param[in] size The length of the @a data memory buffer. This is * permitted to be less-than or equal-to the * element size. If less-than, the remaining bytes * of the element stored are zeroed. * * @par * The memory location of @a data must not overlap the circular * queue's memory location. This is because we internally use * the @f memcpy function. */ API_IMPORT void circular_queue_push(cqueue_handle_t cq, void const * const data, size_t size); /*! * @brief Attempts to store an entry to the circular queue, if possible. * @param[in] cq The circular queue handle to operate upon. * @param[in] data A buffer location for which we copy the data in from. * @param[in] size The length of the @a data memory buffer. This is * permitted to be less-than or equal-to the * element size. If less-than, the remaining bytes * of the element stored are zeroed. * @return Result of operation is zero on success. * * @par * The memory location of @a data must not overlap the circular * queue's memory location. This is because we internally use * the @f memcpy function. */ API_IMPORT int circular_queue_try_push(cqueue_handle_t cq, void const * const data, size_t size); /*! * @brief Acquire an entry from the circular queue. * @param[in] cq The circular queue handle to operate upon. * @param[in] data A buffer location to which to copy the data out to. * @param[in] size The length of the @a data memory buffer. This is * permitted to be less-than or equal-to the * element size. * * @par * The memory location of @a data must not overlap the circular * queue's memory location. This is because we internally use * the @f memcpy function. */ API_IMPORT void circular_queue_pop(cqueue_handle_t cq, void * const * data, size_t size); /*! * @brief Returns whether the circular queue is empty. * @param[in] cq The circular queue handle to operate upon. * @return A boolean representing the emptiness state of the * circular queue. */ API_IMPORT bool circular_queue_is_empty(cqueue_handle_t cq); /*! * @brief Returns whether the circular queue is full. * @param[in] cq The circular queue handle to operate upon. * @return A boolean representing the fullness state of the * circular queue. */ API_IMPORT bool circular_queue_is_full(cqueue_handle_t cq); #ifdef __cplusplus } #endif #endif aircrack-ng-1.6/include/aircrack-ng/aircrack-ng.h000066400000000000000000000170021361312141100216700ustar00rootroot00000000000000/* * 802.11 WEP / WPA-PSK Key Cracker * * Copyright (C) 2007-2012 Martin Beck * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. * If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. * If you * do not wish to do so, delete this exception statement from your * version. * If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifndef _AIRCRACK_NG_H #define _AIRCRACK_NG_H #include #include #include #include #include #include #if defined(__FreeBSD__) || defined(__MidnightBSD__) #include #endif #include #include #include #include #include #include #define SUCCESS 0 #define FAILURE 1 #define RESTART 2 #ifndef O_BINARY #define O_BINARY 0 #endif #define MAX_DICTS 128 #define ASCII_LOW_T 0x21 #define ASCII_HIGH_T 0x7E #define ASCII_VOTE_STRENGTH_T 150 #define ASCII_DISREGARD_STRENGTH 1 #define TEST_MIN_IVS 4 #define TEST_MAX_IVS 32 #define PTW_TRY_STEP 5000 #define KEYHSBYTES PTW_KEYHSBYTES #define MAX_THREADS 256 #ifndef WL_CIRCULAR_QUEUE_SIZE #define WL_CIRCULAR_QUEUE_SIZE (32 * 1024) #endif #define CLOSE_IT 100000 #define S_LLC_SNAP "\xAA\xAA\x03\x00\x00\x00" #define S_LLC_SNAP_ARP (S_LLC_SNAP "\x08\x06") #define S_LLC_SNAP_IP (S_LLC_SNAP "\x08\x00") #define IEEE80211_FC1_DIR_FROMDS 0x02 /* AP ->STA */ #define KEYLIMIT 1000000 #define N_ATTACKS 17 enum KoreK_attacks { A_u15, /* semi-stable 15% */ A_s13, /* stable 13% */ A_u13_1, /* unstable 13% */ A_u13_2, /* unstable ? 13% */ A_u13_3, /* unstable ? 13% */ A_s5_1, /* standard 5% (~FMS) */ A_s5_2, /* other stable 5% */ A_s5_3, /* other stable 5% */ A_u5_1, /* unstable 5% no good ? */ A_u5_2, /* unstable 5% */ A_u5_3, /* unstable 5% no good */ A_u5_4, /* unstable 5% */ A_s3, /* stable 3% */ A_4_s13, /* stable 13% on q = 4 */ A_4_u5_1, /* unstable 5% on q = 4 */ A_4_u5_2, /* unstable 5% on q = 4 */ A_neg /* helps reject false positives */ }; struct dictfiles { off_t dictsize; /* Total file size */ off_t dictpos; /* Current position of dictionary */ off_t wordcount; /* Total amount of words in dict file */ int loaded; /* Have finished processing? */ }; struct options { int amode; /* attack mode */ int essid_set; /* essid set flag */ int bssid_set; /* bssid set flag */ char essid[33]; /* target ESSID */ unsigned char bssid[6]; /* target BSSID */ int nbcpu; /* # of cracker threads (= # of CPU) */ int is_quiet; /* quiet mode flag */ unsigned char debug[64]; /* user-defined WEP key */ int debug_row[64]; /* user-defined Row WEP key */ unsigned char maddr[6]; /* MAC address filter */ int keylen; /* WEP key length */ int index; /* WEP key index */ float ffact; /* bruteforce factor */ int korek; /* attack strategy */ int is_fritz; /* use numeric keyspace */ int is_alnum; /* alphanum keyspace */ int is_bcdonly; /* binary coded decimal */ int do_brute; /* bruteforce last 2 KB */ int do_mt_brute; /* bruteforce last 2 KB multithreaded for SMP*/ int do_testy; /* experimental attack */ int do_ptw; /* PTW WEP attack */ char * dicts[MAX_DICTS]; /* dictionary files */ FILE * dict; /* dictionary file */ int nbdict; /* current dict number */ int no_stdin; /* if dict == stdin */ int hexdict[MAX_DICTS]; /* if dict in hex */ long long int wordcount; /* Total wordcount for all dicts*/ struct dictfiles dictidx[MAX_DICTS]; /* Dictionary structure */ int totaldicts; /* total loaded dictionaries */ int dictfinish; /* finished processing all dicts*/ int showASCII; /* Show ASCII version of*/ /* the wepkey */ int l33t; /* no comment */ int stdin_dict; int probability; /* %of correct answers */ int votes[N_ATTACKS]; /* votes for korek attacks */ int brutebytes[64]; /* bytes to bruteforce */ int next_ptw_try; int max_ivs; char * bssidmerge; unsigned char * firstbssid; struct mergeBSSID * bssid_list_1st; struct AP_info * ap; int wep_decloak; int ptw_attack; int visual_inspection; /* Enabling/disabling visual */ /* inspection of the different */ /* keybytes */ int oneshot; /* Do PTW once */ char * logKeyToFile; int forced_amode; /* signals disregarding automatic detection of encryption type */ char * wkp; /* EWSA Project file */ char * hccap; /* Hashcat capture file */ char * hccapx; /* Hashcat X (3.6+) capture file */ }; typedef struct { int idx, val; } vote; struct WEP_data { unsigned char key[64]; /* the current chosen WEP key */ unsigned char * ivbuf; /* buffer holding all the IVs */ int nb_aps; /* number of targeted APs */ long nb_ivs; /* # of unique IVs in buffer */ long nb_ivs_now; /* # of unique IVs available */ int fudge[64]; /* bruteforce level (1 to 256) */ int depth[64]; /* how deep we are in the fudge */ vote poll[64][256]; /* KoreK cryptanalysis results */ }; #include struct mergeBSSID { unsigned char bssid[6]; /* BSSID */ char unused[2]; /* Alignment */ int convert; /* Does this BSSID has to */ /* be converted */ struct mergeBSSID * next; }; #define WPA_DATA_KEY_BUFFER_LENGTH 128 struct WPA_data { int active; ac_crypto_engine_t engine; struct AP_info * ap; /* AP information */ int thread; /* number of this thread */ int threadid; /* id of this thread */ char key[WPA_DATA_KEY_BUFFER_LENGTH]; /* cracked key (0 while not found) */ uint8_t * key_buffer; cqueue_handle_t cqueue; pthread_mutex_t mutex; }; void show_wep_stats(int B, int force, PTW_tableentry table[PTW_KEYHSBYTES][PTW_n], int choices[KEYHSBYTES], int depth[KEYHSBYTES], int prod); static inline int cmp_votes(const void * bs1, const void * bs2) { REQUIRE(bs1 != NULL); REQUIRE(bs2 != NULL); if (((vote *) bs1)->val < ((vote *) bs2)->val) return (1); if (((vote *) bs1)->val > ((vote *) bs2)->val) return (-1); return (0); } #endif /* _AIRCRACK_NG_H */ aircrack-ng-1.6/include/aircrack-ng/ce-wep/000077500000000000000000000000001361312141100205165ustar00rootroot00000000000000aircrack-ng-1.6/include/aircrack-ng/ce-wep/uniqueiv.h000066400000000000000000000043631361312141100225420ustar00rootroot00000000000000/* * 802.11 WEP / WPA-PSK Key Cracker * * Copyright (C) 2007-2012 Martin Beck * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. * If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. * If you * do not wish to do so, delete this exception statement from your * version. * If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifndef _UNIQUEIV_H #define _UNIQUEIV_H #define IV_NOTHERE 0 #define IV_PRESENT 1 /* select byte within which desired bit is located */ #define BITWISE_OFFT(x) ((x) >> 3) /* mask to extract desired bit */ #define BITWISE_MASK(x) (1 << ((x) &7)) unsigned char ** uniqueiv_init(void); int uniqueiv_mark(unsigned char ** uiv_root, unsigned char IV[3]); int uniqueiv_check(unsigned char ** uiv_root, unsigned char IV[3]); void uniqueiv_wipe(unsigned char ** uiv_root); #define NO_CLOAKING 0 #define CLOAKING 1 unsigned char * data_init(void); int data_check(unsigned char * data_root, unsigned char IV[3], unsigned char data[2]); void data_wipe(unsigned char * data); #endif aircrack-ng-1.6/include/aircrack-ng/ce-wpa/000077500000000000000000000000001361312141100205125ustar00rootroot00000000000000aircrack-ng-1.6/include/aircrack-ng/ce-wpa/aligned.h000066400000000000000000000051041361312141100222660ustar00rootroot00000000000000/* * Based on John the Ripper and modified to integrate with aircrack * * John the Ripper copyright and license. * * John the Ripper password cracker, * Copyright (c) 1996-2013 by Solar Designer. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * As a special exception to the GNU General Public License terms, * permission is hereby granted to link the code of this program, with or * without modification, with any version of the OpenSSL library and/or any * version of unRAR, and to distribute such linked combinations. You must * obey the GNU GPL in all respects for all of the code used other than * OpenSSL and unRAR. If you modify this program, you may extend this * exception to your version of the program, but you are not obligated to * do so. (In other words, you may release your derived work under pure * GNU GPL version 2 or later as published by the FSF.) * * (This exception from the GNU GPL is not required for the core tree of * John the Ripper, but arguably it is required for -jumbo.) * * Relaxed terms for certain components. * * In addition or alternatively to the license above, many components are * available to you under more relaxed terms (most commonly under cut-down * BSD license) as specified in the corresponding source files. * * For more information on John the Ripper licensing please visit: * * http://www.openwall.com/john/doc/LICENSE.shtml * * This software was written by JimF jfoug AT cox dot net * in 2013. No copyright is claimed, and the software is hereby * placed in the public domain. In case this attempt to disclaim * copyright and place the software in the public domain is deemed * null and void, then the software is Copyright (c) 2013 JimF * and it is hereby released to the general public under the following * terms: This software may be modified, redistributed, and used for any * purpose, in source and binary forms, with or without modification. */ #ifndef _ALIGNED_H_ #define _ALIGNED_H_ #if defined(__GNUC__) #define JTR_ALIGN(n) __attribute__((aligned(n))) #elif defined(_MSC_VER) #define JTR_ALIGN(n) __declspec(align(n)) #else #define JTR_ALIGN(n) #endif #endif aircrack-ng-1.6/include/aircrack-ng/ce-wpa/arch.h000066400000000000000000000304201361312141100215770ustar00rootroot00000000000000/* * Based on John the Ripper and modified to integrate with aircrack * * John the Ripper copyright and license. * * John the Ripper password cracker, * Copyright (c) 1996-2013 by Solar Designer. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * As a special exception to the GNU General Public License terms, * permission is hereby granted to link the code of this program, with or * without modification, with any version of the OpenSSL library and/or any * version of unRAR, and to distribute such linked combinations. You must * obey the GNU GPL in all respects for all of the code used other than * OpenSSL and unRAR. If you modify this program, you may extend this * exception to your version of the program, but you are not obligated to * do so. (In other words, you may release your derived work under pure * GNU GPL version 2 or later as published by the FSF.) * * (This exception from the GNU GPL is not required for the core tree of * John the Ripper, but arguably it is required for -jumbo.) * * Relaxed terms for certain components. * * In addition or alternatively to the license above, many components are * available to you under more relaxed terms (most commonly under cut-down * BSD license) as specified in the corresponding source files. * * For more information on John the Ripper licensing please visit: * * http://www.openwall.com/john/doc/LICENSE.shtml * * This file is part of John the Ripper password cracker, * Copyright (c) 2003,2006,2008,2010,2011,2015 by Solar Designer * * ...with a trivial change in the jumbo patch, by Alain Espinosa. * * Redistribution and use in source and binary forms, with or without * modification, are permitted. * * There's ABSOLUTELY NO WARRANTY, express or implied. */ /* * Architecture specific parameters for x86-64. */ #ifndef _ARCH_H #define _ARCH_H #if (defined(__ARM_NEON) && !defined(__ARM_NEON__)) || defined(__aarch64) \ || defined(__aarch64__) #define __ARM_NEON__ 1 #endif #if (defined(__ARM_NEON__) && !defined(__ARM_NEON)) || defined(__aarch64) \ || defined(__aarch64__) #define __ARM_NEON 1 #endif #ifdef __ARM_NEON__ #define SHA_BUF_SIZ 16 #define SIMD_COEF_32 4 #define SIMD_COEF_64 2 #ifndef SIMD_PARA_SHA1 #define SIMD_PARA_SHA1 1 #endif #ifndef SIMD_PARA_SHA256 #define SIMD_PARA_SHA256 0 #endif #ifndef SIMD_PARA_SHA512 #define SIMD_PARA_SHA512 0 #endif #endif #if defined(JOHN_ALTIVEC) #define SHA_BUF_SIZ 16 #define SIMD_COEF_32 4 #define SIMD_COEF_64 2 #ifndef SIMD_PARA_SHA1 #define SIMD_PARA_SHA1 1 #endif #ifndef SIMD_PARA_SHA256 #define SIMD_PARA_SHA256 0 #endif #ifndef SIMD_PARA_SHA512 #define SIMD_PARA_SHA512 0 #endif #endif #if AC_BUILT #include "autoconfig.h" #else #if defined(__ILP32__) || defined(_WIN64) || defined(__LLP64__) \ || (defined(__SIZE_OF_LONG__) && __SIZEOF_LONG__ == 4) #define ARCH_WORD long long #else #define ARCH_WORD long #endif #define ARCH_SIZE 8 #define ARCH_BITS 64 #define ARCH_BITS_LOG 6 #define ARCH_BITS_STR "64" #define ARCH_LITTLE_ENDIAN 1 #define ARCH_INT_GT_32 0 #endif #define ARCH_ALLOWS_UNALIGNED 1 #define ARCH_INDEX(x) ((unsigned int) (unsigned char) (x)) #define CPU_DETECT 0 #ifdef __SSE2__ #define CPU_NAME "SSE2" #endif #if __SSSE3__ || JOHN_SSSE3 #undef CPU_DETECT #define CPU_DETECT 1 #define CPU_REQ 1 #define CPU_REQ_SSSE3 1 #undef CPU_NAME #define CPU_NAME "SSSE3" #if CPU_FALLBACK && !defined(CPU_FALLBACK_BINARY) #define CPU_FALLBACK_BINARY "john-non-ssse3" #define CPU_FALLBACK_BINARY_DEFAULT #endif #endif #if __SSE4_1__ || JOHN_SSE4_1 #undef CPU_DETECT #define CPU_DETECT 1 #define CPU_REQ 1 #define CPU_REQ_SSE4_1 1 #undef CPU_NAME #define CPU_NAME "SSE4.1" #if CPU_FALLBACK && !defined(CPU_FALLBACK_BINARY) #define CPU_FALLBACK_BINARY "john-non-sse4.1" #define CPU_FALLBACK_BINARY_DEFAULT #endif #endif #if __AVX512F__ || JOHN_AVX512F #undef CPU_DETECT #define CPU_DETECT 1 #define CPU_REQ 1 #define CPU_REQ_AVX512F 1 #undef CPU_NAME #define CPU_NAME "AVX512F" #if CPU_FALLBACK && !defined(CPU_FALLBACK_BINARY) #define CPU_FALLBACK_BINARY "john-non-avx512f" #define CPU_FALLBACK_BINARY_DEFAULT #endif #endif #if __AVX512BW__ || JOHN_AVX512BW #undef CPU_DETECT #define CPU_DETECT 1 #define CPU_REQ 1 #define CPU_REQ_AVX512BW 1 #undef CPU_NAME #define CPU_NAME "AVX512BW" #if CPU_FALLBACK && !defined(CPU_FALLBACK_BINARY) #define CPU_FALLBACK_BINARY "john-non-avx512bw" #define CPU_FALLBACK_BINARY_DEFAULT #endif #endif #ifdef __XOP__ #define JOHN_XOP 1 #endif #if defined(__AVX__) || defined(JOHN_XOP) || defined(JOHN_AVX2) #define JOHN_AVX 1 #endif #define DES_ASM 0 #define DES_128K 0 #define DES_X2 0 #define DES_MASK 1 #define DES_SCALE 1 #define DES_EXTB 1 #define DES_COPY 0 #define DES_BS 1 #if !defined(__SSE2__) #define DES_BS_VECTOR 0 #define DES_BS_ALGORITHM_NAME "DES 64/64" #elif defined(JOHN_AVX) && (defined(__GNUC__) || defined(_OPENMP)) /* * Require gcc for AVX/XOP because DES_bs_all is aligned in a gcc-specific way, * except in OpenMP-enabled builds, where it's aligned by different means. */ #undef CPU_DETECT #define CPU_DETECT 1 #define CPU_REQ 1 #define CPU_REQ_AVX 1 #undef CPU_NAME #define CPU_NAME "AVX" #if CPU_FALLBACK && !defined(CPU_FALLBACK_BINARY) #define CPU_FALLBACK_BINARY "john-non-avx" #define CPU_FALLBACK_BINARY_DEFAULT #endif #define DES_BS_ASM 0 #if 0 /* 512-bit as 2x256 */ #define DES_BS_VECTOR 8 #if defined(JOHN_XOP) && defined(__GNUC__) /* Require gcc for 256-bit XOP because of __builtin_ia32_vpcmov_v8sf256() */ #undef DES_BS #define DES_BS 3 #define DES_BS_ALGORITHM_NAME "DES 256/256 X2 XOP-16" #else #define DES_BS_ALGORITHM_NAME "DES 256/256 X2 AVX-16" #endif #elif 0 /* 384-bit as 256+128 */ #define DES_BS_VECTOR_SIZE 8 #define DES_BS_VECTOR 6 #if defined(JOHN_XOP) && defined(__GNUC__) /* Require gcc for 256-bit XOP because of __builtin_ia32_vpcmov_v8sf256() */ #undef DES_BS #define DES_BS 3 #define DES_BS_ALGORITHM_NAME "DES 256/256 XOP-16 + 128/128 XOP-16" #else #define DES_BS_ALGORITHM_NAME "DES 256/256 AVX-16 + 128/128 AVX-16" #endif #elif 0 /* 384-bit as 256+64+64 */ #define DES_BS_NO_AVX128 #define DES_BS_VECTOR_SIZE 8 #define DES_BS_VECTOR 6 #define DES_BS_ALGORITHM_NAME "DES 256/256 AVX-16 + 64/64 MMX + 64/64" #elif 0 /* 320-bit as 256+64 MMX */ #define DES_BS_VECTOR_SIZE 8 #define DES_BS_VECTOR 5 #define DES_BS_ALGORITHM_NAME "DES 256/256 AVX-16 + 64/64 MMX" #elif 0 /* 320-bit as 256+64 */ #define DES_BS_NO_MMX #define DES_BS_VECTOR_SIZE 8 #define DES_BS_VECTOR 5 #define DES_BS_ALGORITHM_NAME "DES 256/256 AVX-16 + 64/64" #elif __AVX2__ || JOHN_AVX2 /* 256-bit as 1x256 */ #define DES_BS_VECTOR 4 #undef CPU_NAME #define CPU_NAME "AVX2" #define CPU_DETECT 1 #define CPU_REQ 1 #define CPU_REQ_AVX2 1 #if CPU_FALLBACK && !defined(CPU_FALLBACK_BINARY) #define CPU_FALLBACK_BINARY "john-non-avx2" #define CPU_FALLBACK_BINARY_DEFAULT #endif #define DES_BS_ALGORITHM_NAME "DES 256/256 AVX2-16" #elif 0 /* 256-bit as 2x128 */ #define DES_BS_NO_AVX256 #define DES_BS_VECTOR 4 #ifdef JOHN_XOP #undef DES_BS #define DES_BS 3 #define DES_BS_ALGORITHM_NAME "DES 128/128 X2 XOP-16" #else #define DES_BS_ALGORITHM_NAME "DES 128/128 X2 AVX-16" #endif #else /* 128-bit */ #define DES_BS_VECTOR 2 #ifdef JOHN_XOP #undef DES_BS #define DES_BS 3 #define DES_BS_ALGORITHM_NAME "DES 128/128 XOP-16" #else #define DES_BS_ALGORITHM_NAME "DES 128/128 AVX-16" #endif #endif #elif (defined(__SSE2__) && defined(_OPENMP)) #define DES_BS_ASM 0 #if 1 #define DES_BS_VECTOR 2 #define DES_BS_ALGORITHM_NAME "DES 128/128 SSE2-16" #elif 0 #define DES_BS_VECTOR 3 #define DES_BS_VECTOR_SIZE 4 #define DES_BS_ALGORITHM_NAME "DES 128/128 SSE2-16 + 64/64 MMX" #elif 0 #define DES_BS_NO_MMX #define DES_BS_VECTOR 3 #define DES_BS_VECTOR_SIZE 4 #define DES_BS_ALGORITHM_NAME "DES 128/128 SSE2-16 + 64/64" #elif 0 #define DES_BS_NO_MMX #define DES_BS_VECTOR 4 #define DES_BS_ALGORITHM_NAME "DES 128/128 X2 SSE2-16" #else #define DES_BS_VECTOR 4 #define DES_BS_ALGORITHM_NAME "DES 128/128 SSE2-16 + 64/64 MMX + 64/64" #endif #else #define DES_BS_ASM 1 #define DES_BS_VECTOR 2 #define DES_BS_ALGORITHM_NAME "DES 128/128 SSE2-16" #endif #define DES_BS_EXPAND 1 #if CPU_DETECT && DES_BS == 3 #define CPU_REQ_XOP 1 #undef CPU_NAME #define CPU_NAME "XOP" #ifdef CPU_FALLBACK_BINARY_DEFAULT #undef CPU_FALLBACK_BINARY #define CPU_FALLBACK_BINARY "john-non-xop" #endif #endif #define MD5_ASM 0 #define MD5_X2 1 #define MD5_IMM 1 #ifdef __GNUC__ #define GCC_VERSION \ (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) #endif #ifdef __SSE2__ #if __AVX512F__ #define SIMD_COEF_32 16 #define SIMD_COEF_64 8 #elif __AVX2__ #define SIMD_COEF_32 8 #define SIMD_COEF_64 4 #elif __SSE2__ #define SIMD_COEF_32 4 #define SIMD_COEF_64 2 #endif #ifndef SIMD_PARA_SHA1 #if defined(__INTEL_COMPILER) #define SIMD_PARA_SHA1 1 #elif defined(__clang__) #define SIMD_PARA_SHA1 1 #elif defined(__llvm__) #define SIMD_PARA_SHA1 1 #elif defined(__GNUC__) && GCC_VERSION < 40504 // 4.5.4 #define SIMD_PARA_SHA1 1 #elif !defined(__AVX__) && defined(__GNUC__) && GCC_VERSION > 40700 // 4.7.0 #define SIMD_PARA_SHA1 1 #else #define SIMD_PARA_SHA1 1 #endif #endif #if 0 #ifndef SIMD_PARA_SHA256 #if __XOP__ #define SIMD_PARA_SHA256 2 #else #define SIMD_PARA_SHA256 1 #endif #endif #ifndef SIMD_PARA_SHA512 #define SIMD_PARA_SHA512 1 #endif #endif #ifndef SHA1_SSE_PARA #if defined(__INTEL_COMPILER) || defined(USING_ICC_S_FILE) #define SHA1_SSE_PARA 1 //#define SHA1_N_STR "4x" #elif defined(__clang__) #define SHA1_SSE_PARA 2 //#define SHA1_N_STR "8x" #elif defined(__llvm__) #define SHA_BUF_SIZ 80 #define SHA1_SSE_PARA 2 //#define SHA1_N_STR "8x" #elif defined(__GNUC__) && GCC_VERSION < 40504 // 4.5.4 #define SHA1_SSE_PARA 1 //#define SHA1_N_STR "4x" #elif !defined(JOHN_AVX) && defined(__GNUC__) && GCC_VERSION > 40700 // 4.7.0 #define SHA1_SSE_PARA 1 //#define SHA1_N_STR "4x" #else #define SHA1_SSE_PARA 2 //#define SHA1_N_STR "8x" #endif #endif #define STR_VALUE(arg) #arg #define PARA_TO_N(n) STR_VALUE(n) "x" #define PARA_TO_MxN(m, n) STR_VALUE(m) "x" STR_VALUE(n) #if SIMD_PARA_SHA1 > 1 #define SHA1_N_STR PARA_TO_MxN(SIMD_COEF_32, SIMD_PARA_SHA1) #else #define SHA1_N_STR PARA_TO_N(SIMD_COEF_32) #endif #if SIMD_PARA_SHA256 > 1 #define SHA256_N_STR PARA_TO_MxN(SIMD_COEF_32, SIMD_PARA_SHA256) #else #define SHA256_N_STR PARA_TO_N(SIMD_COEF_32) #endif #if SIMD_PARA_SHA512 > 1 #define SHA512_N_STR PARA_TO_MxN(SIMD_COEF_64, SIMD_PARA_SHA512) #else #define SHA512_N_STR PARA_TO_N(SIMD_COEF_64) #endif #define SHA_BUF_SIZ 16 #define NT_X86_64 #ifndef SIMD_CORE #define MMX_TYPE " SSE2" #define MMX_COEF 4 #define MMX_COEF_SHA256 4 #define MMX_COEF_SHA512 2 #endif #endif /* __SSE2__ */ #define BF_ASM 0 #define BF_SCALE 1 /* * 3x (as opposed to 2x) interleaving provides substantial speedup on Core 2 * CPUs, as well as slight speedup on some other CPUs. Unfortunately, it * results in lower cumulative performance with multiple concurrent threads or * processes on some newer SMT-capable CPUs. While this has nothing to do with * AVX per se, building for AVX implies we do not intend to run on a Core 2 * (which has at most SSE4.1), so checking for AVX here provides an easy way to * avoid this performance regression in AVX-enabled builds. In multi-binary * packages with runtime fallbacks, the AVX-enabled binary would invoke a * non-AVX fallback binary from its john.c if run e.g. on a Core 2. We could * check for SSE4.2 rather than AVX here, as SSE4.2 was introduced along with * SMT-capable Nehalem microarchitecture CPUs, but apparently those CPUs did * not yet exhibit the performance regression with 3x interleaving. Besides, * some newer CPUs capable of SSE4.2 but not AVX happen to lack SMT, so will * likely benefit from the 3x interleaving with no adverse effects for the * multi-threaded case. * * In Jumbo, we may get BF_X2 from autoconf (after testing ht cpuid flag). */ #ifndef BF_X2 #if __AVX__ && HAVE_HT && _OPENMP #define BF_X2 1 #else #define BF_X2 3 #endif #endif #endif aircrack-ng-1.6/include/aircrack-ng/ce-wpa/crypto_engine.h000066400000000000000000000205031361312141100235300ustar00rootroot00000000000000/* * Copyright (C) 2018-2020 Joseph Benden * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * is provided AS IS, WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and * NON-INFRINGEMENT. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, * MA 02110-1301, USA. * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifndef AIRCRACK_NG_CRYPTO_ENGINE_H #define AIRCRACK_NG_CRYPTO_ENGINE_H #include #include #include #include #define MAX_THREADS 256 #if defined(_MSC_VER) // Microsoft #define EXPORT __declspec(dllexport) #define IMPORT __declspec(dllimport) #elif defined(__GNUC__) || defined(__llvm__) || defined(__clang__) \ || defined(__INTEL_COMPILER) #define EXPORT __attribute__((visibility("default"))) #define IMPORT #else // do nothing and hope for the best? #define EXPORT #define IMPORT #pragma warning Unknown dynamic link import / export semantics. #endif #ifdef __cplusplus extern "C" { #endif #define ESSID_LENGTH 32 /* The spec. says 32 maximum. */ #define PLAINTEXT_LENGTH 63 /* We can do 64 but spec. says 63 */ #define MIN_KEYS_PER_CRYPT 1 #if defined(JOHN_AVX512F) #define MAX_KEYS_PER_CRYPT 16 #elif defined(JOHN_AVX2) #define MAX_KEYS_PER_CRYPT 8 #else #define MAX_KEYS_PER_CRYPT 4 #endif #if defined(AVX512F_FOUND) #if defined(__INTEL_COMPILER) #define MAX_KEYS_PER_CRYPT_SUPPORTED 32 #else #define MAX_KEYS_PER_CRYPT_SUPPORTED 16 #endif #else #if defined(__INTEL_COMPILER) #define MAX_KEYS_PER_CRYPT_SUPPORTED 16 #else #define MAX_KEYS_PER_CRYPT_SUPPORTED 8 #endif #endif typedef struct { uint8_t v[PLAINTEXT_LENGTH + 1]; uint32_t length; } wpapsk_password; typedef struct { union { uint32_t v[8]; uint8_t c[32]; }; } wpapsk_hash; #ifndef CACHELINE_SIZE #define CACHELINE_SIZE 64 // CPU L1 cache-line size, in bytes. #endif #define CACHELINE_PADDED_FIELD(T, name, length, cacheline_size) \ T name[(length)]; \ uint8_t name##_padding[(cacheline_size) \ - ((length * sizeof(T)) % (cacheline_size))] #pragma pack(push, 1) /// Per-thread data needed by the crypto cracking engine. struct ac_crypto_engine_perthread { /// Holds the pair-wise master key. CACHELINE_PADDED_FIELD(wpapsk_hash, pmk, MAX_KEYS_PER_CRYPT_SUPPORTED, CACHELINE_SIZE); /// Holds a 64-byte buffer for HMAC SHA1 ipad/opad, plus an extra 20-byte /// buffer for a SHA1 digest. CACHELINE_PADDED_FIELD(uint8_t, hash1, (64 + 20) * MAX_KEYS_PER_CRYPT_SUPPORTED, CACHELINE_SIZE); #ifndef AVX512F_FOUND #define CRYPT_PADDING CACHELINE_SIZE / 2 #else #define CRYPT_PADDING CACHELINE_SIZE #endif /// Holds a 20-byte buffer for a SHA1 digest. Half cache-line size is to /// compact with the next. CACHELINE_PADDED_FIELD(uint8_t, crypt1, 20 * MAX_KEYS_PER_CRYPT_SUPPORTED, CRYPT_PADDING); /// Holds a 20-byte buffer for a SHA1 digest. Half cache-line size is to /// compact with the previous. CACHELINE_PADDED_FIELD(uint8_t, crypt2, 20 * MAX_KEYS_PER_CRYPT_SUPPORTED, CRYPT_PADDING); #undef CRYPT_PADDING /// Holds a 20-byte buffer for a SHA1 digest. Double cache-line size is to /// space the next field futher out. CACHELINE_PADDED_FIELD(uint8_t, ptk, 20 * MAX_KEYS_PER_CRYPT_SUPPORTED, CACHELINE_SIZE * 2); /// Holds a 100-byte buffer for pair-wise key expansion. CACHELINE_PADDED_FIELD(uint8_t, pke, 100 * MAX_KEYS_PER_CRYPT_SUPPORTED, CACHELINE_SIZE); }; #pragma pack(pop) COMPILE_TIME_ASSERT((offsetof(struct ac_crypto_engine_perthread, pmk)) == 0); COMPILE_TIME_ASSERT((offsetof(struct ac_crypto_engine_perthread, hash1) % CACHELINE_SIZE) == 0); COMPILE_TIME_ASSERT((offsetof(struct ac_crypto_engine_perthread, crypt1) % CACHELINE_SIZE) == 0); COMPILE_TIME_ASSERT((offsetof(struct ac_crypto_engine_perthread, crypt2) % (CACHELINE_SIZE / 2)) == 0); COMPILE_TIME_ASSERT((offsetof(struct ac_crypto_engine_perthread, ptk) % CACHELINE_SIZE) == 0); COMPILE_TIME_ASSERT((offsetof(struct ac_crypto_engine_perthread, pke) % CACHELINE_SIZE) == 0); struct ac_crypto_engine { uint8_t ** essid; uint32_t essid_length; struct ac_crypto_engine_perthread * thread_data[MAX_THREADS]; }; typedef struct ac_crypto_engine ac_crypto_engine_t; /// The compiled-in features required to correctly execute on host. IMPORT int ac_crypto_engine_supported_features(void); /// global init. this could initialize threadid 1, but... IMPORT int ac_crypto_engine_init(ac_crypto_engine_t * engine); IMPORT void ac_crypto_engine_destroy(ac_crypto_engine_t * engine); IMPORT void ac_crypto_engine_set_essid(ac_crypto_engine_t * engine, const uint8_t * essid); IMPORT uint8_t * ac_crypto_engine_get_pmk(ac_crypto_engine_t * engine, int threadid, int index); IMPORT uint8_t * ac_crypto_engine_get_ptk(ac_crypto_engine_t * engine, int threadid, int index); IMPORT void ac_crypto_engine_calc_pke(ac_crypto_engine_t * engine, const uint8_t bssid[6], const uint8_t stmac[6], const uint8_t anonce[32], const uint8_t snonce[32], int threadid); IMPORT void ac_crypto_engine_set_pmkid_salt(ac_crypto_engine_t * engine, const uint8_t bssid[6], const uint8_t stmac[6], int threadid); /// per-thread-in-use init. separate to allow (possible) NUMA-local allocation. IMPORT int ac_crypto_engine_thread_init(ac_crypto_engine_t * engine, int threadid); IMPORT void ac_crypto_engine_thread_destroy(ac_crypto_engine_t * engine, int threadid); /// acquire the width of simd we're compiled for. IMPORT int ac_crypto_engine_simd_width(void); IMPORT void ac_crypto_engine_calc_pmk( ac_crypto_engine_t * engine, const wpapsk_password key[MAX_KEYS_PER_CRYPT_SUPPORTED], int nparallel, int threadid); IMPORT void ac_crypto_engine_calc_ptk(ac_crypto_engine_t * engine, const uint8_t keyver, int vectorIdx, int threadid); IMPORT void ac_crypto_engine_calc_mic(ac_crypto_engine_t * engine, const uint8_t eapol[256], uint32_t eapol_size, uint8_t mic[MAX_KEYS_PER_CRYPT_SUPPORTED] [20], uint8_t keyver, int vectorIdx, int threadid); IMPORT int ac_crypto_engine_wpa_crack( ac_crypto_engine_t * engine, const wpapsk_password key[MAX_KEYS_PER_CRYPT_SUPPORTED], const uint8_t eapol[256], uint32_t eapol_size, uint8_t mic[MAX_KEYS_PER_CRYPT_SUPPORTED][20], uint8_t keyver, const uint8_t cmpmic[20], int nparallel, int threadid); IMPORT int ac_crypto_engine_wpa_pmkid_crack( ac_crypto_engine_t * engine, const wpapsk_password key[MAX_KEYS_PER_CRYPT_SUPPORTED], const uint8_t pmkid[32], int nparallel, int threadid); // Quick Utilities. /// Calculate one pairwise master key, from the \a essid and \a key. IMPORT void ac_crypto_engine_calc_one_pmk(const uint8_t * key, const uint8_t * essid, uint32_t essid_length, uint8_t pmk[40]); #ifdef __cplusplus } #endif #endif // AIRCRACK_NG_CRYPTO_ENGINE_H aircrack-ng-1.6/include/aircrack-ng/ce-wpa/jcommon.h000066400000000000000000000102421361312141100223240ustar00rootroot00000000000000/* * Based on John the Ripper and modified to integrate with aircrack * * John the Ripper copyright and license. * * John the Ripper password cracker, * Copyright (c) 1996-2013 by Solar Designer. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * As a special exception to the GNU General Public License terms, * permission is hereby granted to link the code of this program, with or * without modification, with any version of the OpenSSL library and/or any * version of unRAR, and to distribute such linked combinations. You must * obey the GNU GPL in all respects for all of the code used other than * OpenSSL and unRAR. If you modify this program, you may extend this * exception to your version of the program, but you are not obligated to * do so. (In other words, you may release your derived work under pure * GNU GPL version 2 or later as published by the FSF.) * * (This exception from the GNU GPL is not required for the core tree of * John the Ripper, but arguably it is required for -jumbo.) * * Relaxed terms for certain components. * * In addition or alternatively to the license above, many components are * available to you under more relaxed terms (most commonly under cut-down * BSD license) as specified in the corresponding source files. * * For more information on John the Ripper licensing please visit: * * http://www.openwall.com/john/doc/LICENSE.shtml * * This file is part of John the Ripper password cracker, * Copyright (c) 1996-99,2005,2009,2011,2013 by Solar Designer * * Redistribution and use in source and binary forms, with or without * modification, are permitted. * * There's ABSOLUTELY NO WARRANTY, express or implied. */ /* * Things common to many ciphertext formats. */ #ifndef _JCOMMON_H #define _JCOMMON_H #include #include #if ARCH_INT_GT_32 typedef unsigned short ARCH_WORD_32; typedef unsigned int ARCH_WORD_64; #else typedef unsigned int ARCH_WORD_32; typedef unsigned long long ARCH_WORD_64; #endif /* ONLY use this to check alignments of even power of 2 (2, 4, 8, 16, etc) byte counts (CNT). The cast to void* MUST be done, due to C spec. http://stackoverflow.com/a/1898487 */ #define is_aligned(PTR, CNT) \ ((((ARCH_WORD)(const void *) (PTR)) & (CNT - 1)) == 0) #ifdef __GNUC__ #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7) \ || defined(__INTEL_COMPILER) #define MAYBE_INLINE __attribute__((always_inline)) inline #elif __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) #define MAYBE_INLINE __attribute__((always_inline)) #else #define MAYBE_INLINE __inline__ #endif #elif __STDC_VERSION__ >= 199901L #define MAYBE_INLINE inline #else #define MAYBE_INLINE #endif #if ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 7)) || (__GNUC__ > 2) #define CC_CACHE_ALIGN __attribute__((aligned(MEM_ALIGN_CACHE))) #else #define CC_CACHE_ALIGN /* nothing */ #endif /* * This "shift" is the number of bytes that may be inserted between arrays the * size of which would be a multiple of cache line size (some power of two) and * that might be accessed simultaneously. The purpose of the shift is to avoid * cache bank conflicts with such accesses, actually allowing them to proceed * simultaneously. This number should be a multiple of the machine's word size * but smaller than cache line size. */ #define CACHE_BANK_SHIFT ARCH_SIZE /* * ASCII <-> binary conversion tables. */ // extern const char itoa64[64]; /* crypt(3) base64 - not MIME Base64! */ extern char atoi64[0x100]; extern const char itoa16[16]; extern char atoi16[0x100]; extern const char itoa16u[16]; // uppercase /* * Initializes the tables. */ extern void common_init(void); #endif aircrack-ng-1.6/include/aircrack-ng/ce-wpa/johnswap.h000066400000000000000000000122751361312141100225230ustar00rootroot00000000000000/* * Based on John the Ripper and modified to integrate with aircrack * * John the Ripper copyright and license. * * John the Ripper password cracker, * Copyright (c) 1996-2013 by Solar Designer. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * As a special exception to the GNU General Public License terms, * permission is hereby granted to link the code of this program, with or * without modification, with any version of the OpenSSL library and/or any * version of unRAR, and to distribute such linked combinations. You must * obey the GNU GPL in all respects for all of the code used other than * OpenSSL and unRAR. If you modify this program, you may extend this * exception to your version of the program, but you are not obligated to * do so. (In other words, you may release your derived work under pure * GNU GPL version 2 or later as published by the FSF.) * * (This exception from the GNU GPL is not required for the core tree of * John the Ripper, but arguably it is required for -jumbo.) * * Relaxed terms for certain components. * * In addition or alternatively to the license above, many components are * available to you under more relaxed terms (most commonly under cut-down * BSD license) as specified in the corresponding source files. * * For more information on John the Ripper licensing please visit: * * http://www.openwall.com/john/doc/LICENSE.shtml * */ #if !defined __JOHN_SWAP_H__ #define __JOHN_SWAP_H__ /* reqired for the john_bswap_32 ARCH_WORD_32 declaration */ #include /* if x86 compatible cpu */ #if defined(i386) || defined(__i386__) || defined(__i486__) \ || defined(__i586__) || defined(__i686__) || defined(__pentium__) \ || defined(__pentiumpro__) || defined(__pentium4__) || defined(__nocona__) \ || defined(prescott) || defined(__core2__) || defined(__k6__) \ || defined(__k8__) || defined(__athlon__) || defined(__amd64) \ || defined(__amd64__) || defined(__x86_64) || defined(__x86_64__) \ || defined(_M_IX86) || defined(_M_AMD64) || defined(_M_IA64) \ || defined(_M_X64) /* detect if x86-64 instruction set is supported */ #if defined(_LP64) || defined(__LP64__) || defined(__x86_64) \ || defined(__x86_64__) || defined(_M_AMD64) || defined(_M_X64) #undef CPU_X64 #define CPU_X64 1 #else #undef CPU_IA32 #define CPU_IA32 1 #endif #undef CPU_INTEL_LE #define CPU_INTEL_LE 1 #endif #if defined __GNUC__ \ && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 3) || (__GNUC__ > 4)) #define JOHNSWAP(x) __builtin_bswap32((x)) #define JOHNSWAP64(x) __builtin_bswap64((x)) #elif defined(__linux__) #include #define JOHNSWAP(x) bswap_32((x)) #define JOHNSWAP64(x) bswap_64((x)) #elif (_MSC_VER > 1300) \ && (_M_IX86 >= 400 || defined(CPU_IA32) || defined(CPU_X64)) /* MS VC */ #define JOHNSWAP(x) _byteswap_ulong((x)) #define JOHNSWAP64(x) _byteswap_uint64(((unsigned __int64) x)) #elif !defined(__STRICT_ANSI__) #define JOHNSWAP(x) john_bswap_32((x)) #define JOHNSWAP64(x) john_bswap_64((x)) #define ROTATE_LEFT(x, n) \ (x) = (((x) << (n)) | ((ARCH_WORD_32)(x) >> (32 - (n)))) #define ROTATE_LEFT64(x, n) \ (x) = (((x) << (n)) | ((unsigned long long) (x) >> (64 - (n)))) #if defined(__GNUC__) && defined(CPU_IA32) && !defined(__i386__) /* for intel x86 CPU */ static inline ARCH_WORD_32 __attribute__((const)) john_bswap_32(ARCH_WORD_32 val) { register ARCH_WORD_32 res; __asm("bswap\t%0" : "=r"(res) : "0"(val)); return res; } #else /* Note, the name bswap_32 clashed with a less efficient bswap_32 in gcc 3.4. */ /* Thus, we now call it john_bswap_32 to take 'ownership' */ static inline ARCH_WORD_32 john_bswap_32(ARCH_WORD_32 x) { /* Since this is an inline function, we do not have to worry about */ /* multiple reference of x. Even though we are called from a macro */ /* this inline hides problems even with usage like n=SWAP(*cp++); */ ROTATE_LEFT(x, 16); return ((x & 0x00FF00FF) << 8) | ((x >> 8) & 0x00FF00FF); } #endif static inline unsigned long long john_bswap_64(unsigned long long x) { #if ARCH_BITS == 32 union { unsigned long long ll; ARCH_WORD_32 l[2]; } w, r; w.ll = x; r.l[0] = john_bswap_32(w.l[1]); r.l[1] = john_bswap_32(w.l[0]); return r.ll; #else // Someone should write a 'proper' 64 bit bswap, for 64 bit arch // for now, I am using the '32 bit' version I wrote above. union { unsigned long long ll; ARCH_WORD_32 l[2]; } w, r; w.ll = x; r.l[0] = john_bswap_32(w.l[1]); r.l[1] = john_bswap_32(w.l[0]); return r.ll; #endif } #endif #endif // __JOHN_SWAP_H__ aircrack-ng-1.6/include/aircrack-ng/ce-wpa/memdbg.h000066400000000000000000000264111361312141100221220ustar00rootroot00000000000000/* * Based on John the Ripper and modified to integrate with aircrack * * John the Ripper copyright and license. * * John the Ripper password cracker, * Copyright (c) 1996-2013 by Solar Designer. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * As a special exception to the GNU General Public License terms, * permission is hereby granted to link the code of this program, with or * without modification, with any version of the OpenSSL library and/or any * version of unRAR, and to distribute such linked combinations. You must * obey the GNU GPL in all respects for all of the code used other than * OpenSSL and unRAR. If you modify this program, you may extend this * exception to your version of the program, but you are not obligated to * do so. (In other words, you may release your derived work under pure * GNU GPL version 2 or later as published by the FSF.) * * (This exception from the GNU GPL is not required for the core tree of * John the Ripper, but arguably it is required for -jumbo.) * * Relaxed terms for certain components. * * In addition or alternatively to the license above, many components are * available to you under more relaxed terms (most commonly under cut-down * BSD license) as specified in the corresponding source files. * * For more information on John the Ripper licensing please visit: * * http://www.openwall.com/john/doc/LICENSE.shtml * * This header file should be the LAST header file included within every * .c file within the project. If there are .h files that have actual * code in them, then this header should be the last include within that * .h file, and that .h file should be the last one included within the * .c file. * ****** NOTE ***** */ #if !defined(__MEM_DBG_H_) #define __MEM_DBG_H_ // values to use within the MemDbg_Validate() function. #define MEMDBG_VALIDATE_MIN 0 #define MEMDBG_VALIDATE_DEEP 1 #define MEMDBG_VALIDATE_DEEPER 2 #define MEMDBG_VALIDATE_DEEPEST 3 #include #include #if (!AC_BUILT || HAVE_UNISTD_H) && !_MSC_VER #include #endif #include #if defined(MEMDBG_ON) /* * This software was written by Jim Fougeron jfoug AT cox dot net * in 2013. No copyright is claimed, and the software is hereby * placed in the public domain. In case this attempt to disclaim * copyright and place the software in the public domain is deemed * null and void, then the software is Copyright (c) 2013 Jim Fougeron * and it is hereby released to the general public under the following * terms: * * This software may be modified, redistributed, and used for any * purpose, in source and binary forms, with or without modification. */ /* * memdbg.h * Memory management debugging (at runtime) * * memdbg contains routines detect, and report memory * problems, such as double frees, passing bad pointers to * free, most buffer overwrites. Also, tracking of non-freed * data, showing memory leaks, can also be shown. * * Compilation Options (provided from Makefile CFLAGS) * * MEMDBG_ON If this is NOT defined, then memdbg will * get out of your way, and most normal memory functions * will be called with no overhead at all. */ /* these functions can be called by client code. Normally Memdbg_Used() and * MemDbg_Display() would be called at program exit. That will dump a list * of any memory that was not released. The MemDbg_Validate() can be called * pretty much any time. That function will walk the memory allocation linked * lists, and sqwack if there are problems, such as overwrites, freed memory * that * has been written to, etc. It would likely be good to call MemDbg_Validate() * within benchmarking, after every format is tested. * * TODO: Add a handle that can be passed to the MemDbg_Used() and * MemDbg_Display() * and a function to get the 'current' state of memory as a handle. Thus, a * format self test could get a handle BEFORE starting, and then check after, * and * ONLY show leaked memory from the time the handle was obtained, which was at * the * start of the self test. Thus it would only show leaks from that format test. * * These functions are NOT thread safe. Do not call them within OMP blocks of * code. * Normally, these would be called at program exit, or within things like * format * self test code, etc, and not within OMP. But this warning is here, so that * it is known NOT to call within OMP. */ extern size_t MemDbg_Used(int show_freed); extern void MemDbg_Display(FILE *); extern void MemDbg_Validate(int level); extern void MemDbg_Validate_msg(int level, const char * pMsg); extern void MemDbg_Validate_msg2(int level, const char * pMsg, int bShowExData); /* these functions should almost NEVER be called by any client code. They * are listed here, because the macros need to know their names. Client code * should almost ALWAYS call malloc() like normal, vs calling MEMDBG_alloc() * If MEMDBG_alloc() was called, and MEMDBG_ON was not defined, then this * function would not be declared here, AND at link time, the function would * not be found. * NOTE, these functions should be thread safe in OMP builds (using #pragma omp * atomic) * also note, memory allocation within OMP blocks SHOULD be avoided if possible. * It is * very slow, and the thread safety required makes it even slow. This is not * only talking * about these functions here, BUT malloc/free in general in OMP blocks. AVOID * doing that * at almost all costs, and performance will usually go up. */ extern void * MEMDBG_alloc(size_t, char *, int); extern void * MEMDBG_realloc(const void *, size_t, char *, int); extern void MEMDBG_free(const void *, char *, int); extern char * MEMDBG_strdup(const char *, char *, int); #if !defined(__MEMDBG__) /* we get here on every file compiled EXCEPT memdbg.c */ #undef malloc #undef realloc #undef free #undef strdup #undef libc_free #undef libc_calloc #undef libc_malloc #define libc_free(a) \ do \ { \ if (a) MEMDBG_libc_free(a); \ a = 0; \ } while (0) #define libc_malloc(a) MEMDBG_libc_alloc(a) #define libc_calloc(a) MEMDBG_libc_calloc(a) #define malloc(a) MEMDBG_alloc((a), __FILE__, __LINE__) #define calloc(a) MEMDBG_calloc((a), __FILE__, __LINE__) #define realloc(a, b) MEMDBG_realloc((a), (b), __FILE__, __LINE__) /* this code mimics JtR's FREE_MEM(a) but does it for any MEMDBG_free(a,F,L) * call (a hooked free(a) call) */ #define free(a) \ do \ { \ if (a) MEMDBG_free((a), __FILE__, __LINE__); \ a = 0; \ } while (0) #define strdup(a) MEMDBG_strdup((a), __FILE__, __LINE__) #endif /* pass the file handle to write to (normally stderr) */ #define MEMDBG_PROGRAM_EXIT_CHECKS(a) \ do \ { \ if (MemDbg_Used(0) > 0) MemDbg_Display(a); \ MemDbg_Validate_msg2(MEMDBG_VALIDATE_DEEPEST, "At Program Exit", 1); \ } while (0) typedef struct MEMDBG_HANDLE_t { unsigned id; unsigned alloc_cnt; size_t mem_size; } MEMDBG_HANDLE; /* * these functions allow taking a memory snapshot, calling some code, then * validating that memory * is the same after the code. This will help catch memory leaks and other such * problems, within * formats and such. Simply get the snapshot, run self tests (or other), when * it exits, check * the snapshot to make sure nothing leaked. */ /* returning a struct (or passing as params it not super efficient but this is * done so infrequently that this is not an issue. */ MEMDBG_HANDLE MEMDBG_getSnapshot(int id); /* will not exit on leaks. Does exit, on memory overwrite corruption. */ void MEMDBG_checkSnapshot(MEMDBG_HANDLE); /* same as MEMDBG_checkSnapshot() but if exit_on_any_leaks is true, will also * exit if leaks found. */ void MEMDBG_checkSnapshot_possible_exit_on_error(MEMDBG_HANDLE, int exit_on_any_leaks); /* * the allocations from mem_alloc_tiny() must call this function to flag the * memory they allocate * so it is not flagged as a leak, by these HANDLE snapshot functions. 'tiny' * memory is expected * to leak, until program exit. At that time, any that was not freed, will be * shown as leaked. * THIS function is also thread safe. The other checkSnapshot functions are NOT * thread safe. */ void MEMDBG_tag_mem_from_alloc_tiny(void *); #else /* NOTE, we DO keep one special function here. We make free a little * smarter. this function gets used, even when we do NOT compile with * any memory debugging on. This makes free work more like C++ delete, * in that it is valid to call it on a NULL. Also, it sets the pointer * to NULL, so that we can call free(x) on x multiple times, without * causing a crash. NOTE, the multiple frees SHOULD be caught when * someone builds and runs with MEMDBG_ON. But when it is off, we do * try to protect the program. */ #undef libc_free #undef libc_calloc #undef libc_malloc #define libc_free(a) \ do \ { \ if (a) MEMDBG_libc_free(a); \ a = 0; \ } while (0) #define libc_malloc(a) MEMDBG_libc_alloc(a) #define libc_calloc(a) MEMDBG_libc_calloc(a) #if !defined(__MEMDBG__) /* this code mimics JtR's FREE_MEM(a) but does it for any normal free(a) call */ // extern void MEMDBG_off_free(void *a); //#define free(a) do { if(a) MEMDBG_off_free(a); a=0; } while(0) #endif #define MemDbg_Used(a) 0 #define MemDbg_Display(a) #define MemDbg_Validate(a) #define MemDbg_Validate_msg(a, b) #define MemDbg_Validate_msg2(a, b, c) #define MEMDBG_PROGRAM_EXIT_CHECKS(a) #define MEMDBG_tag_mem_from_alloc_tiny(a) #define MEMDBG_HANDLE int #define MEMDBG_getSnapshot(a) 0 #define MEMDBG_checkSnapshot(a) \ if (a) printf(" \b") #define MEMDBG_checkSnapshot_possible_exit_on_error(a, b) \ if (a) printf(" \b") #endif /* MEMDBG_ON */ extern void MEMDBG_libc_free(void *); extern void * MEMDBG_libc_alloc(size_t size); extern void * MEMDBG_libc_calloc(size_t size); #endif /* __MEMDBG_H_ */ aircrack-ng-1.6/include/aircrack-ng/ce-wpa/memory.h000066400000000000000000000413571361312141100222050ustar00rootroot00000000000000/* * Based on John the Ripper and modified to integrate with aircrack * * John the Ripper copyright and license. * * John the Ripper password cracker, * Copyright (c) 1996-2013 by Solar Designer. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * As a special exception to the GNU General Public License terms, * permission is hereby granted to link the code of this program, with or * without modification, with any version of the OpenSSL library and/or any * version of unRAR, and to distribute such linked combinations. You must * obey the GNU GPL in all respects for all of the code used other than * OpenSSL and unRAR. If you modify this program, you may extend this * exception to your version of the program, but you are not obligated to * do so. (In other words, you may release your derived work under pure * GNU GPL version 2 or later as published by the FSF.) * * (This exception from the GNU GPL is not required for the core tree of * John the Ripper, but arguably it is required for -jumbo.) * * Relaxed terms for certain components. * * In addition or alternatively to the license above, many components are * available to you under more relaxed terms (most commonly under cut-down * BSD license) as specified in the corresponding source files. * * For more information on John the Ripper licensing please visit: * * http://www.openwall.com/john/doc/LICENSE.shtml * * This file is part of John the Ripper password cracker, * Copyright (c) 1996-98,2003,2010-2012 by Solar Designer * * Redistribution and use in source and binary forms, with or without * modification, are permitted. * * There's ABSOLUTELY NO WARRANTY, express or implied. */ /* * Memory allocation routines. */ #ifndef _MEMORY_H #define _MEMORY_H #include #include #include #include #if __AVX512F__ #define SIMD_COEF_32 16 #define SIMD_COEF_64 8 #elif __AVX2__ #define SIMD_COEF_32 8 #define SIMD_COEF_64 4 #elif __SSE2__ #define SIMD_COEF_32 4 #define SIMD_COEF_64 2 #endif /* * Standard alignments for mem_alloc_tiny(). */ #define MEM_ALIGN_NONE 1 #define MEM_ALIGN_WORD ARCH_SIZE /* * These are hopefully suitable guesses. They are right for only a subset of * the architectures/CPUs we support, yet our use of them does not require that * they be entirely correct. */ #ifdef _MSC_VER #define MEM_ALIGN_CACHE 64 #else #define MEM_ALIGN_CACHE (ARCH_SIZE * 8) #endif #define MEM_ALIGN_PAGE 0x1000 /* * SIMD buffers need to be aligned to register size */ #if SIMD_COEF_32 #ifdef _MSC_VER #define MEM_ALIGN_SIMD 16 #else #define MEM_ALIGN_SIMD (SIMD_COEF_32 * 4) #endif #else #define MEM_ALIGN_SIMD (16) #endif /* * Block size used by mem_alloc_tiny(). */ #define MEM_ALLOC_SIZE 0x10000 /* * Use mem_alloc() instead of allocating a new block in mem_alloc_tiny() * if more than MEM_ALLOC_MAX_WASTE bytes would be lost. * This shouldn't be set too small, or mem_alloc_tiny() will keep calling * mem_alloc() for many allocations in a row, which might end up wasting even * more memory to malloc() overhead. */ #define MEM_ALLOC_MAX_WASTE 0xff /* * Memory saving level, setting this high enough disables alignments (if the * architecture allows). */ extern unsigned int mem_saving_level; /* * Allocates size bytes and returns a pointer to the allocated memory. * If an error occurs, the function does not return. */ extern void * mem_alloc_func(size_t size #if defined(MEMDBG_ON) , char * file, int line #endif ); /* * this version same as mem_alloc, but initialized the memory * to NULL bytes, like CALLOC(3) function does */ extern void * mem_calloc_func(size_t count, size_t size #if defined(MEMDBG_ON) , char * file, int line #endif ); #if defined(MEMDBG_ON) #define mem_alloc(a) mem_alloc_func(a, __FILE__, __LINE__) #define mem_calloc(a, b) mem_calloc_func(a, b, __FILE__, __LINE__) #define mem_alloc_tiny(a, b) mem_alloc_tiny_func(a, b, __FILE__, __LINE__) #define mem_calloc_tiny(a, b) mem_calloc_tiny_func(a, b, __FILE__, __LINE__) #define mem_alloc_copy(a, b, c) mem_alloc_copy_func(a, b, c, __FILE__, __LINE__) #define str_alloc_copy(a) str_alloc_copy_func(a, __FILE__, __LINE__) #define mem_alloc_align(a, b) mem_alloc_align_func(a, b, __FILE__, __LINE__) #define mem_calloc_align(a, b, c) \ mem_calloc_align_func(a, b, c, __FILE__, __LINE__) #else #define mem_alloc(a) mem_alloc_func(a) #define mem_calloc(a, b) mem_calloc_func(a, b) #define mem_alloc_tiny(a, b) mem_alloc_tiny_func(a, b) #define mem_calloc_tiny(a, b) mem_calloc_tiny_func(a, b) #define mem_alloc_copy(a, b, c) mem_alloc_copy_func(a, b, c) #define str_alloc_copy(a) str_alloc_copy_func(a) #define mem_alloc_align(a, b) mem_alloc_align_func(a, b) #define mem_calloc_align(a, b, c) mem_calloc_align_func(a, b, c) #endif /* These allow alignment and are wrappers to system-specific functions */ void * mem_alloc_align_func(size_t size, size_t align #if defined(MEMDBG_ON) , char * file, int line #endif ); void * mem_calloc_align_func(size_t count, size_t size, size_t align #if defined(MEMDBG_ON) , char * file, int line #endif ); /* * Frees memory allocated with mem_alloc() and sets the pointer to NULL. * Does nothing if the pointer is already NULL. */ #undef MEM_FREE #ifdef _MSC_VER #if !defined(MEMDBG_ON) #define strdup(a) strdup_MSVC(a) char * strdup_MSVC(const char * str); #define MEM_FREE(ptr) \ { \ if ((ptr)) \ { \ _aligned_free((ptr)); \ (ptr) = NULL; \ } \ } #else #define MEM_FREE(ptr) \ { \ if ((ptr)) \ { \ MEMDBG_free(((const void *) ptr), __FILE__, __LINE__); \ (ptr) = NULL; \ } \ } #endif #else #define MEM_FREE(ptr) \ { \ if ((ptr)) \ { \ free((ptr)); \ (ptr) = NULL; \ } \ } #endif /* * Similar to the above function, except the memory can't be freed. * This one is used to reduce the overhead. */ extern void * mem_alloc_tiny_func(size_t size, size_t align #if defined(MEMDBG_ON) , char * file, int line #endif ); /* * this version same as mem_alloc_tiny, but initialized the memory * to NULL bytes, like CALLOC(3) function does */ extern void * mem_calloc_tiny_func(size_t size, size_t align #if defined(MEMDBG_ON) , char * file, int line #endif ); /* * Uses mem_alloc_tiny() to allocate the memory, and copies src in there. */ extern void * mem_alloc_copy_func(void * src, size_t size, size_t align #if defined(MEMDBG_ON) , char * file, int line #endif ); /* * Similar to the above function, but for ASCIIZ strings. */ extern char * str_alloc_copy_func(char * src #if defined(MEMDBG_ON) , char * file, int line #endif ); /* * This will 'cleanup' the memory allocated by mem_alloc_tiny(). All * of that memory was 'blindly' allocated, and not freed up during * the run of john. Now, it is 'cleaned' up. */ extern void cleanup_tiny_memory(void); void dump_text(void * in, int len); void dump_stuff(void * x, unsigned int size); void dump_stuff_msg(const void * msg, void * x, unsigned int size); void dump_stuff_noeol(void * x, unsigned int size); void dump_stuff_msg_sepline(const void * msg, void * x, unsigned int size); void dump_stuff_be(void * x, unsigned int size); void dump_stuff_be_msg(const void * msg, void * x, unsigned int size); void dump_stuff_be_noeol(void * x, unsigned int size); void dump_stuff_be_msg_sepline(const void * msg, void * x, unsigned int size); #if defined(SIMD_COEF_32) || defined(NT_X86_64) || defined(SIMD_PARA_MD5) \ || defined(SIMD_PARA_MD4) || defined(SIMD_PARA_SHA1) void dump_stuff_mmx(void * x, unsigned int size, unsigned int index); void dump_stuff_mmx_noeol(void * x, unsigned int size, unsigned int index); void dump_stuff_mmx_msg(const void * msg, void * buf, unsigned int size, unsigned int index); void dump_stuff_mmx_msg_sepline(const void * msg, void * buf, unsigned int size, unsigned int index); // for flat input, we do want to see SHA512 without byte swapping. void dump_stuff_mmx64(void * buf, unsigned int size, unsigned int index); void dump_stuff_mmx64_msg(const void * msg, void * buf, unsigned int size, unsigned int index); void dump_out_mmx(void * x, unsigned int size, unsigned int index); void dump_out_mmx_noeol(void * x, unsigned int size, unsigned int index); void dump_out_mmx_msg(const void * msg, void * buf, unsigned int size, unsigned int index); void dump_out_mmx_msg_sepline(const void * msg, void * buf, unsigned int size, unsigned int index); void dump_stuff_shammx(void * x, unsigned int size, unsigned int index); void dump_stuff_shammx_msg(const void * msg, void * buf, unsigned int size, unsigned int index); void dump_out_shammx(void * x, unsigned int size, unsigned int index); void dump_out_shammx_msg(const void * msg, void * buf, unsigned int size, unsigned int index); void dump_stuff_shammx64(void * x, unsigned int size, unsigned int index); void dump_stuff_shammx64_msg(const void * msg, void * buf, unsigned int size, unsigned int index); void dump_out_shammx64(void * x, unsigned int size, unsigned int index); void dump_out_shammx64_msg(const void * msg, void * buf, unsigned int size, unsigned int index); #endif #if defined(SIMD_PARA_MD5) // these functions help debug arrays of contiguous MD5 prepared PARA buffers. // Seen in sunmd5 at the current time. void dump_stuff_mpara_mmx(void * x, unsigned int size, unsigned int index); void dump_stuff_mpara_mmx_noeol(void * x, unsigned int size, unsigned int index); void dump_stuff_mpara_mmx_msg(const void * msg, void * buf, unsigned int size, unsigned int index); void dump_stuff_mpara_mmx_msg_sepline(const void * msg, void * buf, unsigned int size, unsigned int index); // a 'getter' to help debugging. Returns a flat buffer, vs printing it out. void getbuf_stuff_mpara_mmx(unsigned char * oBuf, void * buf, unsigned int size, unsigned int index); #endif /* * here, a stack buffer that is at least align-1 bytes LARGER than required, can * be * properly aligned to 'align' bytes. So: char tmpbuf[256+15], * *aligned_buf=mem_align(tmpbuf,16); * will give you a stack buffer, aligned to 16 bytes. There are bugs in some * compilers which cause * JTR_ALIGN(x) to fail properly (such as a bug in bitcoin OMP mode for linux32) * Switched to a define macro for performance. */ #define mem_align(a, b) \ (void *) (((char *) (a)) \ + (((b) -1) - (((size_t)((char *) (a)) - 1) & ((b) -1)))) /* * 32-bit endian-swap a memory buffer in place. Size is in octets (so should * be a multiple of 4). From now on, this function may be used on any arch. */ void alter_endianity(void * x, unsigned int size); /* 32-bit endian-swap a memory buffer in place. Count is in 32-bit words */ void alter_endianity_w(void * x, unsigned int count); /* 64-bit endian-swap a memory buffer in place. Count is in 64-bit words */ void alter_endianity_w64(void * x, unsigned int count); #if ARCH_ALLOWS_UNALIGNED // we can inline these, to always use JOHNSWAP/JOHNSWAP64 // NOTE, more portable to use #defines to inline, than the MAYBE_INLINE within // header files. #if (ARCH_LITTLE_ENDIAN == 0) #define alter_endianity_to_BE(a, b) #define alter_endianity_to_BE64(a, b) #define alter_endianity_to_LE(ptr, word32_cnt) \ do \ { \ int i; \ for (i = 0; i < word32_cnt; i++) \ ((ARCH_WORD_32 *) ptr)[i] = JOHNSWAP(((ARCH_WORD_32 *) ptr)[i]); \ } while (0) #define alter_endianity_to_LE64(ptr, word64_cnt) \ do \ { \ int i; \ for (i = 0; i < word64_cnt; i++) \ ((ARCH_WORD_64 *) ptr)[i] = JOHNSWAP64(((ARCH_WORD_64 *) ptr)[i]); \ } while (0) #else #define alter_endianity_to_LE(a, b) #define alter_endianity_to_LE64(a, b) #define alter_endianity_to_BE(ptr, word32_cnt) \ do \ { \ int i; \ for (i = 0; i < word32_cnt; i++) \ ((ARCH_WORD_32 *) ptr)[i] = JOHNSWAP(((ARCH_WORD_32 *) ptr)[i]); \ } while (0) #define alter_endianity_to_BE64(ptr, word64_cnt) \ do \ { \ int i; \ for (i = 0; i < word64_cnt; i++) \ ((ARCH_WORD_64 *) ptr)[i] = JOHNSWAP64(((ARCH_WORD_64 *) ptr)[i]); \ } while (0) #endif #else #if (ARCH_LITTLE_ENDIAN == 0) #define alter_endianity_to_BE(a, b) #define alter_endianity_to_LE(a, b) \ do \ { \ alter_endianity_w(a, b); \ } while (0) #define alter_endianity_to_BE64(a, b) #define alter_endianity_to_LE64(a, b) \ do \ { \ alter_endianity_w64(a, b); \ } while (0) #else #define alter_endianity_to_BE(a, b) \ do \ { \ alter_endianity_w(a, b); \ } while (0) #define alter_endianity_to_LE(a, b) #define alter_endianity_to_BE64(a, b) \ do \ { \ alter_endianity_w64(a, b); \ } while (0) #define alter_endianity_to_LE64(a, b) #endif #endif #endif aircrack-ng-1.6/include/aircrack-ng/ce-wpa/misc.h000066400000000000000000000141541361312141100216230ustar00rootroot00000000000000/* * Based on John the Ripper and modified to integrate with aircrack * * John the Ripper copyright and license. * * John the Ripper password cracker, * Copyright (c) 1996-2013 by Solar Designer. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * As a special exception to the GNU General Public License terms, * permission is hereby granted to link the code of this program, with or * without modification, with any version of the OpenSSL library and/or any * version of unRAR, and to distribute such linked combinations. You must * obey the GNU GPL in all respects for all of the code used other than * OpenSSL and unRAR. If you modify this program, you may extend this * exception to your version of the program, but you are not obligated to * do so. (In other words, you may release your derived work under pure * GNU GPL version 2 or later as published by the FSF.) * * (This exception from the GNU GPL is not required for the core tree of * John the Ripper, but arguably it is required for -jumbo.) * * Relaxed terms for certain components. * * In addition or alternatively to the license above, many components are * available to you under more relaxed terms (most commonly under cut-down * BSD license) as specified in the corresponding source files. * * For more information on John the Ripper licensing please visit: * * http://www.openwall.com/john/doc/LICENSE.shtml * * This file is part of John the Ripper password cracker, * Copyright (c) 1996-99,2003 by Solar Designer * * ...with changes in the jumbo patch, by JimF and magnum. * * Redistribution and use in source and binary forms, with or without * modification, are permitted. * * There's ABSOLUTELY NO WARRANTY, express or implied. */ /* * Miscellaneous routines. */ #ifndef _MISC_H #define _MISC_H #include #if (__MINGW32__ && !__MINGW64__) || _MSC_VER // Later versions of MSVC can handle %lld but some older // ones can only handle %I64d. Easiest to simply use // %I64d then all versions of MSVC will handle it just fine #define LLu "%I64u" #define LLd "%I64d" #define LLx "%I64x" #define Zu "%u" #define Zd "%d" #else #define LLu "%llu" #define LLd "%lld" #define LLx "%llx" #define Zu "%zu" #define Zd "%zd" #endif #if !AC_BUILT #include #ifndef _MSC_VER #include #endif #else #include "autoconfig.h" #if STRING_WITH_STRINGS #include #include #elif HAVE_STRING_H #include #elif HAVE_STRINGS_H #include #endif #endif /* * Exit on error. Logs the event, closes john.pot and the log file, and * terminates the process with non-zero exit status. */ extern void real_error(char * file, int line) #ifdef __GNUC__ __attribute__((__noreturn__)); #else ; #endif #define error(...) real_error(__FILE__, __LINE__) /* * Exit on error with message. Will call real_error to do * the final exiting, after printing error message. */ extern void real_error_msg(char * file, int line, char * format, ...) #ifdef __GNUC__ __attribute__((__noreturn__)) __attribute__((format(printf, 3, 4))); #else ; #endif #define error_msg(...) perror(__VA_ARGS__) /* * Similar to perror(), but supports formatted output, and calls error(). */ extern void real_pexit(char * file, int line, char * format, ...) #ifdef __GNUC__ __attribute__((__noreturn__)) __attribute__((format(printf, 3, 4))); #else ; #endif #define pexit(...) \ { \ perror(__VA_ARGS__); \ exit(1); \ } /* * Attempts to write all the supplied data. Returns the number of bytes * written, or -1 on error. */ extern int write_loop(int fd, const char * buffer, int count); /* * Similar to fgets(), but doesn't leave the newline character in the buffer, * and skips to the end of long lines. Handles both Unix and DOS style text * files correctly. */ extern char * fgetl(char * s, int size, FILE * stream); /* * Similar to strncpy(), but terminates with only one NUL if there's room * instead of padding to the supplied size like strncpy() does. */ extern char * strnfcpy(char * dst, const char * src, int size); /* * Similar to the above, but always NUL terminates the string. */ extern char * strnzcpy(char * dst, const char * src, int size); /* * Similar to the strnzcpy, but returns the length of the string. */ extern int strnzcpyn(char * dst, const char * src, int size); /* * Similar to strncat(), but total buffer size is supplied, and always NUL * terminates the string. */ extern char * strnzcat(char * dst, const char * src, int size); /* * Similar to atoi(), but properly handles unsigned int. Do not use * atoi() for unsigned data if the data can EVER be over MAX_INT. */ extern unsigned atou(const char * src); /* * Similar to strtok(), but properly handles adjacent delmiters as * empty strings. strtok() in the CRTL merges adjacent delimiters * and sort of 'skips' them. This one also returns 'empty' tokens * for any leading or trailing delims. strtok() strips those off * also. */ char * strtokm(char * s1, const char * delimit); #ifndef __has_feature #define __has_feature(x) 0 #endif #if /* is ASAN enabled? */ \ __has_feature(address_sanitizer) /* Clang */ \ || defined(__SANITIZE_ADDRESS__) /* GCC 4.8.x */ #define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS \ __attribute__((no_address_safety_analysis)) __attribute__((noinline)) #define WITH_ASAN #else #define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS #endif #endif aircrack-ng-1.6/include/aircrack-ng/ce-wpa/pseudo_intrinsics.h000066400000000000000000000735451361312141100244450ustar00rootroot00000000000000/* * Based on John the Ripper and modified to integrate with aircrack * * John the Ripper copyright and license. * * John the Ripper password cracker, * Copyright (c) 1996-2013 by Solar Designer. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * As a special exception to the GNU General Public License terms, * permission is hereby granted to link the code of this program, with or * without modification, with any version of the OpenSSL library and/or any * version of unRAR, and to distribute such linked combinations. You must * obey the GNU GPL in all respects for all of the code used other than * OpenSSL and unRAR. If you modify this program, you may extend this * exception to your version of the program, but you are not obligated to * do so. (In other words, you may release your derived work under pure * GNU GPL version 2 or later as published by the FSF.) * * (This exception from the GNU GPL is not required for the core tree of * John the Ripper, but arguably it is required for -jumbo.) * * Relaxed terms for certain components. * * In addition or alternatively to the license above, many components are * available to you under more relaxed terms (most commonly under cut-down * BSD license) as specified in the corresponding source files. * * For more information on John the Ripper licensing please visit: * * http://www.openwall.com/john/doc/LICENSE.shtml * * Minimalistic pseudo-instrinsics for width-agnostic x86 SIMD code. * * This software is Copyright (c) 2015 magnum, * Copyright (c) 2015 JimF, * Copyright (c) 2015 Lei Zhang, * and it is hereby released to the general public under the following terms: * Redistribution and use in source and binary forms, with or without * modification, are permitted. * * Synopsis: * * SSE2: __m128i a = _mm_add_epi32(b, c); * AVX2: __m256i a = _mm256_add_epi32(b, c); * AVX512: __m512i a = _mm512_add_epi32(b, c); * -> Pseudo: vtype a = vadd_epi32(b, c); * * SSE2: __m128i a = _mm_load_si128(p); * AVX2: __m256i a = _mm256_load_si256(p); * AVX512: __m512i a = _mm512_load_si512(p); * -> Pseudo: vtype a = vload(p); * * intrinsics are emulated where the target does not support them. */ #ifndef _SSE_PSEUDO_H #define _SSE_PSEUDO_H #include #include #if SIMD_COEF_32 #include #include /* for is_aligned() */ /*************************** NEON (ARM) *******************************/ #ifdef __ARM_NEON__ #include typedef uint8x16_t vtype8; typedef uint32x4_t vtype; /* the default one */ typedef uint64x2_t vtype64; #define vadd_epi32 vaddq_u32 #define vadd_epi64(x, y) (vtype) vaddq_u64((vtype64)(x), (vtype64)(y)) #define vand vandq_u32 #define vandnot(x, y) vbicq_u32(y, x) #define vcmov(x, y, z) vbslq_u32(z, x, y) #define vload(m) vld1q_u32((uint32_t *) (m)) #define vloadu vloadu_emu #define VLOADU_EMULATED 1 #define vor vorrq_u32 #define vorn vornq_u32 #define vroti_epi32(x, i) \ (i > 0 ? vsliq_n_u32(vshrq_n_u32(x, 32 - (i)), x, i) \ : vsriq_n_u32(vshlq_n_u32(x, 32 + (i)), x, -(i))) #define vroti_epi64(x, i) \ (i > 0 ? (vtype) vsliq_n_u64( \ vshrq_n_u64((vtype64)(x), 64 - (i)), (vtype64)(x), i) \ : (vtype) vsriq_n_u64( \ vshlq_n_u64((vtype64)(x), 64 + (i)), (vtype64)(x), -(i))) #define vroti16_epi32 vroti_epi32 #define vset1_epi32(x) vdupq_n_u32(x) #define vset1_epi64(x) (vtype) vdupq_n_u64(x) #define vset_epi32(x3, x2, x1, x0) \ vcombine_u32(vcreate_u32(((uint64_t)(x1) << 32) | (x0)), \ vcreate_u32(((uint64_t)(x3) << 32) | (x2))) #define vset_epi64(x1, x0) \ (vtype) vcombine_u64(vcreate_u64(x0), vcreate_u64(x1)) #define vsetzero() vset1_epi32(0) #define vslli_epi32(x, i) vshlq_n_u32(x, i) #define vslli_epi64(x, i) (vtype) vshlq_n_u64((vtype64)(x), i) #define vsrli_epi32(x, i) vshrq_n_u32(x, i) #define vsrli_epi64(x, i) (vtype) vshrq_n_u64((vtype64)(x), i) #define vstore(m, x) vst1q_u32((uint32_t *) (m), x) #define vstoreu vstoreu_emu #define VSTOREU_EMULATED 1 #define vunpackhi_epi32(x, y) (vzipq_u32(x, y)).val[1] #define vunpackhi_epi64(x, y) \ vset_epi64(vgetq_lane_u64((vtype64)(y), 1), vgetq_lane_u64((vtype64)(x), 1)) #define vunpacklo_epi32(x, y) (vzipq_u32(x, y)).val[0] #define vunpacklo_epi64(x, y) \ vset_epi64(vgetq_lane_u64((vtype64)(y), 0), vgetq_lane_u64((vtype64)(x), 0)) #define vxor veorq_u32 static inline int vanyeq_epi32(vtype x, vtype y) { vtype z = vceqq_u32(x, y); return vgetq_lane_u32(z, 0) || vgetq_lane_u32(z, 1) || vgetq_lane_u32(z, 2) || vgetq_lane_u32(z, 3); } #define vswap32(x) (x = (vtype) vrev32q_u8((vtype8) x)) #define vswap64(x) (x = (vtype) vrev64q_u8((vtype8) x)) #define GATHER64(x, y, z) \ { \ x = vset_epi64(y[1][z], y[0][z]); \ } /*************************** AltiVec (Power) **************************/ #elif __ALTIVEC__ #include typedef vector unsigned int vtype32; typedef vector unsigned long vtype64; typedef union { vtype32 v32; vtype64 v64; uint32_t s32[SIMD_COEF_32]; uint64_t s64[SIMD_COEF_64]; } vtype; #define vadd_epi32(x, y) (vtype) vec_add((x).v32, (y).v32) #define vadd_epi64(x, y) (vtype) vec_add((x).v64, (y).v64) #define vand(x, y) (vtype) vec_and((x).v32, (y).v32) #define vandnot(x, y) (vtype) vec_andc((y).v32, (x).v32) #define vcmov(x, y, z) (vtype) vec_sel((y).v32, (x).v32, (z).v32) #define vload(m) (vtype)(vtype32) vec_ld(0, (uint32_t *) (m)) #define vloadu vloadu_emu #define VLOADU_EMULATED 1 #define vor(x, y) (vtype) vec_or((x).v32, (y).v32) #define vroti_epi32(x, i) (vtype) vec_rl((x).v32, (vset1_epi32(i)).v32) #define vroti_epi64(x, i) (vtype) vec_rl((x).v64, (vset1_epi64(i)).v64) #define vroti16_epi32 vroti_epi32 #define vset1_epi32(x) vset_epi32(x, x, x, x) #define vset1_epi64(x) vset_epi64(x, x) #define vset_epi32(x3, x2, x1, x0) \ (vtype)(vtype32) { x0, x1, x2, x3 } #define vset_epi64(x1, x0) \ (vtype)(vtype64) { x0, x1 } #define vsetzero() vset1_epi32(0) #define vslli_epi32(x, i) (vtype) vec_sl((x).v32, (vset1_epi32(i)).v32) #define vslli_epi64(x, i) (vtype) vec_sl((x).v64, (vset1_epi64(i)).v64) #define vsrli_epi32(x, i) (vtype) vec_sr((x).v32, (vset1_epi32(i)).v32) #define vsrli_epi64(x, i) (vtype) vec_sr((x).v64, (vset1_epi64(i)).v64) #define vstore(m, x) vec_st((x).v32, 0, (uint32_t *) (m)) #define vstoreu vstoreu_emu #define VSTOREU_EMULATED 1 #define vunpackhi_epi32(x, y) (vtype) vec_mergel((x).v32, (y).v32) #define vunpackhi_epi64(x, y) \ (vtype)(vtype64) vec_mergel((vector long) (x).v64, (vector long) (y).v64) #define vunpacklo_epi32(x, y) (vtype) vec_mergeh((x).v32, (y).v32) #define vunpacklo_epi64(x, y) \ (vtype)(vtype64) vec_mergeh((vector long) (x).v64, (vector long) (y).v64) #define vxor(x, y) (vtype) vec_xor((x).v32, (y).v32) #define vanyeq_epi32(x, y) vec_any_eq((x).v32, (y).v32) #define vswap32 vswap32_emu #define vswap64 vswap64_emu #define GATHER64(x, y, z) \ { \ x = vset_epi64(y[1][z], y[0][z]); \ } /*************************** AVX512 and MIC ***************************/ #elif __AVX512F__ || __MIC__ #include typedef __m512i vtype; #define vadd_epi32 _mm512_add_epi32 #define vadd_epi64 _mm512_add_epi64 #define vand _mm512_and_si512 #define vandnot _mm512_andnot_si512 #define vcmov vcmov_emu #define VCMOV_EMULATED 1 /* * NOTE: AVX2 has it as (base, index, scale) while MIC and AVX512 are * different. */ #define vgather_epi32(b, i, s) _mm512_i32gather_epi32(i, (void *) (b), s) #define vgather_epi64(b, i, s) _mm512_i64gather_epi64(i, (void *) (b), s) #define vload(x) _mm512_load_si512((void *) (x)) #define vloadu(x) _mm512_loadu_si512((void *) (x)) #define vor _mm512_or_si512 #define vroti_epi32 vroti_epi32_emu #define vroti_epi64 vroti_epi64_emu #define vroti16_epi32 vroti_epi32 #define vscatter_epi32(b, i, v, s) _mm512_i32scatter_epi32((void *) b, i, v, s) #define vscatter_epi64(b, i, v, s) _mm512_i64scatter_epi64((void *) b, i, v, s) #define vset1_epi8 _mm512_set1_epi8 #define vset1_epi32 _mm512_set1_epi32 #define vset1_epi64 _mm512_set1_epi64 #define vset_epi32 _mm512_set_epi32 #define vset_epi64 _mm512_set_epi64 #define vsetzero _mm512_setzero_si512 #define vshuffle_epi32 _mm512_shuffle_epi32 #define vslli_epi32 _mm512_slli_epi32 #define vslli_epi64 _mm512_slli_epi64 #define vsrli_epi32 _mm512_srli_epi32 #define vsrli_epi64 _mm512_srli_epi64 #define vstore(x, y) _mm512_store_si512((void *) (x), y) #define vstoreu(x, y) _mm512_storeu_si512((void *) (x), y) #define vunpackhi_epi32 _mm512_unpackhi_epi32 #define vunpackhi_epi64 _mm512_unpackhi_epi64 #define vunpacklo_epi32 _mm512_unpacklo_epi32 #define vunpacklo_epi64 _mm512_unpacklo_epi64 #define vxor _mm512_xor_si512 #define vanyeq_epi32(x, y) _mm512_cmp_epi32_mask(x, y, _MM_CMPINT_EQ) #define GATHER_4x(x, y, z) \ { \ vtype indices = vset_epi32(15 << 6, \ 14 << 6, \ 13 << 6, \ 12 << 6, \ 11 << 6, \ 10 << 6, \ 9 << 6, \ 8 << 6, \ 7 << 6, \ 6 << 6, \ 5 << 6, \ 4 << 6, \ 3 << 6, \ 2 << 6, \ 1 << 6, \ 0 << 6); \ x = vgather_epi32(&y[z], indices, sizeof(y[z])); \ } #define GATHER_2x(x, y, z) \ { \ vtype indices = vset_epi32(15 << 5, \ 14 << 5, \ 13 << 5, \ 12 << 5, \ 11 << 5, \ 10 << 5, \ 9 << 5, \ 8 << 5, \ 7 << 5, \ 6 << 5, \ 5 << 5, \ 4 << 5, \ 3 << 5, \ 2 << 5, \ 1 << 5, \ 0 << 5); \ x = vgather_epi32(&y[z], indices, sizeof(y[z])); \ } #define GATHER(x, y, z) \ { \ vtype indices = vset_epi32(15 << 4, \ 14 << 4, \ 13 << 4, \ 12 << 4, \ 11 << 4, \ 10 << 4, \ 9 << 4, \ 8 << 4, \ 7 << 4, \ 6 << 4, \ 5 << 4, \ 4 << 4, \ 3 << 4, \ 2 << 4, \ 1 << 4, \ 0 << 4); \ x = vgather_epi32(&y[z], indices, sizeof(y[z])); \ } #define GATHER64(x, y, z) \ { \ uint64_t stride = sizeof(*y); \ vtype indices = vset_epi64(7 * stride, \ 6 * stride, \ 5 * stride, \ 4 * stride, \ 3 * stride, \ 2 * stride, \ 1 * stride, \ 0); \ x = vgather_epi64(&y[0][z], indices, 1); \ } #if __AVX512F__ #undef vcmov #undef VCMOV_EMULATED #define vcmov(x, y, z) vternarylogic(x, y, z, 0xE4) #define vternarylogic _mm512_ternarylogic_epi32 #endif #if __AVX512BW__ #define vcmpeq_epi8_mask (uint64_t) _mm512_cmpeq_epi8_mask #define vshuffle_epi8 _mm512_shuffle_epi8 #define vshufflehi_epi16 _mm512_shufflehi_epi16 #define vshufflelo_epi16 _mm512_shufflelo_epi16 #define vslli_epi16 _mm512_slli_epi16 #define vsrli_epi16 _mm512_srli_epi16 #define vswap32(n) \ n = vshuffle_epi8(n, \ vset_epi32(0x3c3d3e3f, \ 0x38393a3b, \ 0x34353637, \ 0x30313233, \ 0x2c2d2e2f, \ 0x28292a2b, \ 0x24252627, \ 0x20212223, \ 0x1c1d1e1f, \ 0x18191a1b, \ 0x14151617, \ 0x10111213, \ 0x0c0d0e0f, \ 0x08090a0b, \ 0x04050607, \ 0x00010203)) #define vswap64(n) \ n = vshuffle_epi8(n, \ vset_epi64(0x38393a3b3c3d3e3fULL, \ 0x3031323334353637ULL, \ 0x28292a2b2c2d2e2fULL, \ 0x2021222324252627ULL, \ 0x18191a1b1c1d1e1fULL, \ 0x1011121314151617ULL, \ 0x08090a0b0c0d0e0fULL, \ 0x0001020304050607ULL)) #else /* workarounds without AVX512BW */ #define vswap32 vswap32_emu #define vswap64(x) (x = vshuffle_epi32(x, _MM_SHUFFLE(2, 3, 0, 1)), vswap32(x)) #endif /* __AVX512BW__ */ /* MIC lacks some intrinsics in AVX512F, thus needing emulation. */ #if __MIC__ #define _mm512_set1_epi8(x) _mm512_set1_epi32(x | x << 8 | x << 16 | x << 24) static inline __m512i _mm512_loadu_si512(void const * addr) { __m512i indices = _mm512_set_epi64(7, 6, 5, 4, 3, 2, 1, 0); return is_aligned(addr, 64) ? _mm512_load_si512(addr) : _mm512_i64gather_epi64(indices, addr, 8); } static inline void _mm512_storeu_si512(void * addr, vtype d) { __m512i indices = _mm512_set_epi64(7, 6, 5, 4, 3, 2, 1, 0); if (is_aligned(addr, 64)) _mm512_store_si512(addr, d); else _mm512_i64scatter_epi64(addr, indices, d, 8); } #endif /* __MIC__ */ /******************************** AVX2 ********************************/ #elif __AVX2__ #include typedef __m256i vtype; #define vadd_epi32 _mm256_add_epi32 #define vadd_epi64 _mm256_add_epi64 #define vand _mm256_and_si256 #define vandnot _mm256_andnot_si256 #define vcmov vcmov_emu #define VCMOV_EMULATED 1 #define vcmpeq_epi8_mask(a, b) _mm256_movemask_epi8(_mm256_cmpeq_epi8(a, b)) #define vcmpeq_epi32 _mm256_cmpeq_epi32 #define vcvtsi32 _mm256_cvtsi32_si256 #define vgather_epi32(b, i, s) _mm256_i32gather_epi32((void *) (b), i, s) #define vgather_epi64(b, i, s) _mm256_i64gather_epi64((void *) (b), i, s) #define vinsert_epi32 _mm256_insert_epi32 #define vload(x) _mm256_load_si256((void *) (x)) #define vloadu(x) _mm256_loadu_si256((void *) (x)) #define vmovemask_epi8 _mm256_movemask_epi8 #define vor _mm256_or_si256 #define vpermute2x128 _mm256_permute2x128_si256 #define vpermute4x64_epi64 _mm256_permute4x64_epi64 #define vroti_epi32 vroti_epi32_emu #define vroti_epi64 vroti_epi64_emu #define vroti16_epi32 vroti_epi32 #define vset1_epi8 _mm256_set1_epi8 #define vset1_epi32 _mm256_set1_epi32 #define vset1_epi64 _mm256_set1_epi64x #define vset_epi32 _mm256_set_epi32 #define vset_epi64 _mm256_set_epi64x #define vsetzero _mm256_setzero_si256 #define vshuffle_epi8 _mm256_shuffle_epi8 #define vshuffle_epi32 _mm256_shuffle_epi32 #define vshufflehi_epi16 _mm256_shufflehi_epi16 #define vshufflelo_epi16 _mm256_shufflelo_epi16 #define vslli_epi16 _mm256_slli_epi16 #define vslli_epi32 _mm256_slli_epi32 #define vslli_epi64 _mm256_slli_epi64 #define vsrli_epi16 _mm256_srli_epi16 #define vsrli_epi32 _mm256_srli_epi32 #define vsrli_epi64 _mm256_srli_epi64 #define vstore(x, y) _mm256_store_si256((void *) (x), y) #define vstoreu(x, y) _mm256_storeu_si256((void *) (x), y) #define vunpackhi_epi32 _mm256_unpackhi_epi32 #define vunpackhi_epi64 _mm256_unpackhi_epi64 #define vunpacklo_epi32 _mm256_unpacklo_epi32 #define vunpacklo_epi64 _mm256_unpacklo_epi64 #define vxor _mm256_xor_si256 #define vanyeq_epi32(x, y) vmovemask_epi8(vcmpeq_epi32(x, y)) #define swap_endian_mask \ _mm256_set_epi32(0x1c1d1e1f, \ 0x18191a1b, \ 0x14151617, \ 0x10111213, \ 0x0c0d0e0f, \ 0x08090a0b, \ 0x04050607, \ 0x00010203) #define swap_endian64_mask \ vset_epi64(0x18191a1b1c1d1e1fULL, \ 0x1011121314151617ULL, \ 0x08090a0b0c0d0e0fULL, \ 0x0001020304050607ULL) #define vswap32(n) (n = vshuffle_epi8(n, swap_endian_mask)) #define vswap64(n) (n = vshuffle_epi8(n, swap_endian64_mask)) #define GATHER_4x(x, y, z) \ { \ vtype indices = vset_epi32( \ 7 << 6, 6 << 6, 5 << 6, 4 << 6, 3 << 6, 2 << 6, 1 << 6, 0 << 6); \ x = vgather_epi32(&y[z], indices, sizeof(y[z])); \ } #define GATHER_2x(x, y, z) \ { \ vtype indices = vset_epi32( \ 7 << 5, 6 << 5, 5 << 5, 4 << 5, 3 << 5, 2 << 5, 1 << 5, 0 << 5); \ x = vgather_epi32(&y[z], indices, sizeof(y[z])); \ } #define GATHER(x, y, z) \ { \ vtype indices = vset_epi32( \ 7 << 4, 6 << 4, 5 << 4, 4 << 4, 3 << 4, 2 << 4, 1 << 4, 0 << 4); \ x = vgather_epi32(&y[z], indices, sizeof(y[z])); \ } #define GATHER64(x, y, z) \ { \ uint64_t stride = sizeof(*y); \ vtype indices = vset_epi64(3 * stride, 2 * stride, 1 * stride, 0); \ x = vgather_epi64(&y[0][z], indices, 1); \ } /************************* SSE2/3/4/AVX/XOP ***************************/ #elif __SSE2__ #if __XOP__ #include #elif __AVX__ #include #elif __SSE4_1__ #include #elif __SSSE3__ #include #endif #include typedef __m128i vtype; #define vadd_epi32 _mm_add_epi32 #define vadd_epi64 _mm_add_epi64 #define vand _mm_and_si128 #define vandnot _mm_andnot_si128 #if __XOP__ #define vcmov _mm_cmov_si128 #else #define vcmov vcmov_emu #define VCMOV_EMULATED 1 #endif #define vcmpeq_epi8_mask(a, b) _mm_movemask_epi8(_mm_cmpeq_epi8(a, b)) #define vcmpeq_epi32 _mm_cmpeq_epi32 #if __SSE4_1__ #define vcvtsi32 _mm_cvtsi32_si128 #endif #define vinsert_epi32 _mm_insert_epi32 #define vload(x) _mm_load_si128((const vtype *) (x)) #define vloadu(x) _mm_loadu_si128((const vtype *) (x)) #define vmovemask_epi8 _mm_movemask_epi8 #define vor _mm_or_si128 #define vpermute4x64_epi64 _mm_permute4x64_epi64 #define vpermute2x128 _mm_permute2x128_si128 #if __XOP__ #define vroti_epi32 _mm_roti_epi32 #define vroti16_epi32 _mm_roti_epi32 #define vroti_epi64 _mm_roti_epi64 #else #define vroti_epi32 vroti_epi32_emu #define vroti_epi64 vroti_epi64_emu /* Specialized ROTL16 for SSE4.1 and lower (eg. MD5) */ #if __SSSE3__ #define vroti16_epi32(a, s) \ vshuffle_epi8((a), \ vset_epi32(0x0d0c0f0e, 0x09080b0a, 0x05040706, 0x01000302)) #elif __SSE2__ #define vroti16_epi32(a, s) vshufflelo_epi16(vshufflehi_epi16((a), 0xb1), 0xb1) #else #define vroti16_epi32 vroti_epi32 #endif /* __SSSE3__ */ #endif /* __XOP__ */ #define vset_epi32 _mm_set_epi32 #define vset1_epi8 _mm_set1_epi8 #define vset1_epi32 _mm_set1_epi32 #ifndef _MSC_VER #define vset1_epi64 _mm_set1_epi64x #define vset_epi64 _mm_set_epi64x #else #define vset1_epi64 _mm_set1_epi64 #define vset_epi64 _mm_set_epi64 #endif #define vsetzero _mm_setzero_si128 #if __SSSE3__ #define vshuffle_epi8 _mm_shuffle_epi8 #endif #define vshuffle_epi32 _mm_shuffle_epi32 #define vshufflehi_epi16 _mm_shufflehi_epi16 #define vshufflelo_epi16 _mm_shufflelo_epi16 #define vslli_epi16 _mm_slli_epi16 #define vslli_epi32 _mm_slli_epi32 #define vslli_epi64 _mm_slli_epi64 #define vsrli_epi16 _mm_srli_epi16 #define vsrli_epi32 _mm_srli_epi32 #define vsrli_epi64 _mm_srli_epi64 #define vstore(x, y) _mm_store_si128((vtype *) (x), y) #define vstoreu(x, y) _mm_storeu_si128((vtype *) (x), y) #define vunpackhi_epi32 _mm_unpackhi_epi32 #define vunpackhi_epi64 _mm_unpackhi_epi64 #define vunpacklo_epi32 _mm_unpacklo_epi32 #define vunpacklo_epi64 _mm_unpacklo_epi64 #define vxor _mm_xor_si128 #define vanyeq_epi32(x, y) vmovemask_epi8(vcmpeq_epi32(x, y)) #if __SSSE3__ #define swap_endian_mask \ vset_epi32(0x0c0d0e0f, 0x08090a0b, 0x04050607, 0x00010203) #define vswap32(n) (n = vshuffle_epi8(n, swap_endian_mask)) #define swap_endian64_mask \ vset_epi64(0x08090a0b0c0d0e0fULL, 0x0001020304050607ULL) #define vswap64(n) (n = vshuffle_epi8(n, swap_endian64_mask)) #else /* Just basic SSE2 */ #define vswap32(n) \ (n = vxor(vsrli_epi16(vroti16_epi32(n, 16), 8), \ vslli_epi16(vroti16_epi32(n, 16), 8))) #define vswap64(n) \ (n = vshufflehi_epi16(vshufflelo_epi16(n, 0xb1), 0xb1), \ n = vxor(vslli_epi16(n, 8), vsrli_epi16(n, 8)), \ n = vshuffle_epi32(n, 0xb1)) #endif /* __SSSE3__ */ #if __SSE4_1__ #define GATHER_4x(x, y, z) \ { \ x = vcvtsi32(y[z]); \ x = vinsert_epi32(x, y[z + (1 << 6)], 1); \ x = vinsert_epi32(x, y[z + (2 << 6)], 2); \ x = vinsert_epi32(x, y[z + (3 << 6)], 3); \ } #define GATHER_2x(x, y, z) \ { \ x = vcvtsi32(y[z]); \ x = vinsert_epi32(x, y[z + (1 << 5)], 1); \ x = vinsert_epi32(x, y[z + (2 << 5)], 2); \ x = vinsert_epi32(x, y[z + (3 << 5)], 3); \ } #define GATHER(x, y, z) \ { \ x = vcvtsi32(y[z]); \ x = vinsert_epi32(x, y[z + (1 << 4)], 1); \ x = vinsert_epi32(x, y[z + (2 << 4)], 2); \ x = vinsert_epi32(x, y[z + (3 << 4)], 3); \ } #endif /* __SSE4_1__ */ #define GATHER64(x, y, z) \ { \ x = vset_epi64(y[1][z], y[0][z]); \ } #if _MSC_VER && !_M_X64 /* * These are slow, but the F'n 32 bit compiler will not build these intrinsics. * Only the 64-bit (Win64) MSVC compiler has these as intrinsics. These slow * ones let me debug, and develop this code, and work, but use CPU */ #define _mm_set_epi64 __mm_set_epi64 #define _mm_set1_epi64 __mm_set1_epi64 _inline __m128i _mm_set_epi64(long long a, long long b) { __m128i x; x.m128i_i64[0] = b; x.m128i_i64[1] = a; return x; } _inline __m128i _mm_set1_epi64(long long a) { __m128i x; x.m128i_i64[0] = x.m128i_i64[1] = a; return x; } #define vset1_epi64x(x) vset_epi64x(x, x) #define vset_epi64x(x1, x0) \ (vtype)(vtype64) { x0, x1 } #endif #endif /* __SIMD__ elif __SIMD__ elif __SIMD__ */ /************************* COMMON STUFF BELOW *************************/ #ifdef _MSC_VER #define MEM_ALIGN_SIMD 16 #define INLINE _inline #else #define MEM_ALIGN_SIMD (SIMD_COEF_32 * 4) #define INLINE inline #endif #if VLOADU_EMULATED static INLINE vtype vloadu_emu(const void * addr) { if (is_aligned(addr, MEM_ALIGN_SIMD)) return vload(addr); else { JTR_ALIGN(MEM_ALIGN_SIMD) char buf[sizeof(vtype)]; return vload(memcpy(buf, addr, sizeof(vtype))); } } #endif #if VSTOREU_EMULATED static INLINE void vstoreu_emu(void * addr, vtype v) { if (is_aligned(addr, MEM_ALIGN_SIMD)) vstore(addr, v); else { JTR_ALIGN(MEM_ALIGN_SIMD) char buf[sizeof(vtype)]; vstore(buf, v); memcpy(addr, buf, sizeof(vtype)); } } #endif #define vswap32_emu(x) \ (x = vxor(vsrli_epi32(x, 24), \ vxor(vslli_epi32(vsrli_epi32(vslli_epi32(x, 8), 24), 8), \ vxor(vsrli_epi32(vslli_epi32(vsrli_epi32(x, 8), 24), 8), \ vslli_epi32(x, 24))))) #define vswap64_emu(x) \ (x = vxor(vsrli_epi64(x, 32), vslli_epi64(x, 32)), vswap32_emu(x)) #if VCMOV_EMULATED #if VANDNOT_EMULATED /* currently never */ #define vcmov_emu(x, y, z) vxor(y, vand(z, vxor(x, y))) #else #define vcmov_emu(x, y, z) vxor(vand(z, x), vandnot(z, y)) #endif #endif #if __SSE3__ || __MIC__ #define vslli_epi64a(a, s) vslli_epi64(a, s) #else /* Optimization for really old CPUs for << 1 (for vroti -1) (eg. SHA512) */ #define vslli_epi64a(a, s) \ ((s) == 1 ? vadd_epi64((a), (a)) : vslli_epi64((a), (s))) #endif /* __SSE3__ || __MIC__ */ /* * vroti must handle both ROTL and ROTR. If s < 0, then ROTR. Note that * the ternary will normally be optimized away! */ #define vroti_epi32_emu(a, s) \ ((s) < 0 ? vxor(vsrli_epi32((a), ~(s) + 1), vslli_epi32((a), 32 + (s))) \ : vxor(vslli_epi32((a), (s)), vsrli_epi32((a), 32 - (s)))) #define vroti_epi64_emu(a, s) \ ((s) < 0 ? vxor(vsrli_epi64((a), ~(s) + 1), vslli_epi64a((a), 64 + (s))) \ : vxor(vslli_epi64a((a), (s)), vsrli_epi64((a), 64 - (s)))) #endif /* SIMD_COEF_32 */ #endif /* _SSE_PSEUDO_H */ aircrack-ng-1.6/include/aircrack-ng/ce-wpa/simd-intrinsics-load-flags.h000066400000000000000000000131651361312141100260170ustar00rootroot00000000000000/* * Based on John the Ripper and modified to integrate with aircrack * * John the Ripper copyright and license. * * John the Ripper password cracker, * Copyright (c) 1996-2013 by Solar Designer. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * As a special exception to the GNU General Public License terms, * permission is hereby granted to link the code of this program, with or * without modification, with any version of the OpenSSL library and/or any * version of unRAR, and to distribute such linked combinations. You must * obey the GNU GPL in all respects for all of the code used other than * OpenSSL and unRAR. If you modify this program, you may extend this * exception to your version of the program, but you are not obligated to * do so. (In other words, you may release your derived work under pure * GNU GPL version 2 or later as published by the FSF.) * * (This exception from the GNU GPL is not required for the core tree of * John the Ripper, but arguably it is required for -jumbo.) * * Relaxed terms for certain components. * * In addition or alternatively to the license above, many components are * available to you under more relaxed terms (most commonly under cut-down * BSD license) as specified in the corresponding source files. * * For more information on John the Ripper licensing please visit: * * http://www.openwall.com/john/doc/LICENSE.shtml * * This software is * Copyright (c) 2011-2015 JimF, * Copyright (c) 2011-2015 magnum, * and it is hereby released to the general public under the following terms: * Redistribution and use in source and binary forms, with or without * modification, are permitted. */ #ifndef __SSE_INTRINS_LOAD_FLAGS__ #define __SSE_INTRINS_LOAD_FLAGS__ /*************************************************************** * WARNING!!!! any changes to these numbers requires a new * build of simd-intrinsics-32.S and simd-intrinsics-64.S ***************************************************************/ /* * SSEi_MIXED_IN * Input is a ready-to-use array of 16xCOEF ints that are properly SIMD * interleaved, cleaned, appended with 0x80 and has a proper a length word. * The data will be copied to stack workspace. * * SSEi_FLAT_IN * Input is an array of 64xCOEF (128xCOEF_64 for 64 bit crypts) byte 'flat' * values, the hash function has to shuffle it. But 0x80 and length must be * in place. * * SSEi_CSTRING_IN * Input will be just as for OpenSSL: A normal char[COEF][64] array where * each string ends in NULL, with no 0x80 or length prepared. The intrinsics * function needs to take care of that as well as cleaning (after NULL), * shuffling and possibly do endian swapping if applicable. * * SSEi_FLAT_OUT * Output will be just as from OpenSSL. Swapped if applicable, not interleaved. * This should only be used for "final" crypt (and only for slow formats). * * SSEi_RELOAD * No init; state from last crypt is held in output buffer. * * SSEi_RELOAD_INP_FMT * No init; state from last crypt is held in output buffer. However, it is in * 'INPUT' format. This is a no-op unless PARA > 1. * * SSEi_OUTPUT_AS_INP_FMT * Write final output using 'INPUT' format. Will not matter unless PARA > 1 * * SSEi_REVERSE_STEPS * Reverse some steps, at minimum the "a = a + init". Only valid if not doing * reload, and if format does corresponding things in binary() et. al. * * SSEi_2BUF_INPUT * Input array is 2x in size, for a possible max input of 64+55 (119) bytes. * * SSEi_2BUF_INPUT_FIRST_BLK * Input array 2x in size. This is the first block, so we must rotate element * 14/15 if in flat mode. * * SSEi_4BUF_INPUT * Input array is 4x in size (This is seen in the dynamic type, for sha256. We * have 256 byte input buffers there). * * SSEi_4BUF_INPUT_FIRST_BLK * Input array 4x in size. This is the first block, so we must rotate element * 14/15 if in flat mode. * * SSEi_FLAT_RELOAD_SWAPLAST * Can be an issue for flat mode, and reload (i.e. multi buffers.) The last * limb should NEVER have this flag set. This also only 'affects' the SHA1 * and SHA256 formats. Similar to SSEi_4BUF_INPUT_FIRST_BLK, but simply says * we will have more buffers coming after this one. * * SSEi_CRYPT_SHA224 use SHA224 IV. * SSEi_CRYPT_SHA384 use SHA384 IV. * These are specific to SHA2 hashes. Reusing the same bit, since only 1 will * be used (i.e. it is not valid to do SSE_CRYPT_SHA224|SSE_CRYPT_SHA224) * * WARNING, SHA224 requires a FULL SHA256 width output buffer, and SHA384 * requires a full SHA512 width output buffer. This is to allow proper * reloading and doing multi-limb crypts. */ typedef enum { SSEi_MIXED_IN = 0x0, SSEi_FLAT_IN = 0x1, /* SSEi_CSTRING_IN = 0x2, NOT IMPLEMENTED YET*/ SSEi_FLAT_OUT = 0x4, SSEi_RELOAD = 0x8, SSEi_RELOAD_INP_FMT = 0x10 | SSEi_RELOAD, SSEi_OUTPUT_AS_INP_FMT = 0x20, SSEi_REVERSE_STEPS = 0x40, SSEi_2BUF_INPUT = 0x80, SSEi_2BUF_INPUT_FIRST_BLK = 0x100 | SSEi_2BUF_INPUT, SSEi_4BUF_INPUT = 0x200, SSEi_4BUF_INPUT_FIRST_BLK = 0x400 | SSEi_4BUF_INPUT, SSEi_FLAT_RELOAD_SWAPLAST = 0x800, SSEi_CRYPT_SHA224 = 0x1000, SSEi_CRYPT_SHA384 = 0x1000, SSEi_OUTPUT_AS_2BUF_INP_FMT = 0x2000 | SSEi_OUTPUT_AS_INP_FMT } SSEi_FLAGS; #endif /* __SSE_INTRINS_LOAD_FLAGS__ */ aircrack-ng-1.6/include/aircrack-ng/ce-wpa/simd-intrinsics.h000066400000000000000000000136111361312141100240040ustar00rootroot00000000000000/* * Based on John the Ripper and modified to integrate with aircrack * * John the Ripper copyright and license. * * John the Ripper password cracker, * Copyright (c) 1996-2013 by Solar Designer. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * As a special exception to the GNU General Public License terms, * permission is hereby granted to link the code of this program, with or * without modification, with any version of the OpenSSL library and/or any * version of unRAR, and to distribute such linked combinations. You must * obey the GNU GPL in all respects for all of the code used other than * OpenSSL and unRAR. If you modify this program, you may extend this * exception to your version of the program, but you are not obligated to * do so. (In other words, you may release your derived work under pure * GNU GPL version 2 or later as published by the FSF.) * * (This exception from the GNU GPL is not required for the core tree of * John the Ripper, but arguably it is required for -jumbo.) * * Relaxed terms for certain components. * * In addition or alternatively to the license above, many components are * available to you under more relaxed terms (most commonly under cut-down * BSD license) as specified in the corresponding source files. * * For more information on John the Ripper licensing please visit: * * http://www.openwall.com/john/doc/LICENSE.shtml * * This software is Copyright (c) 2010 bartavelle, , * and it is hereby released to the general public under the following terms: * Redistribution and use in source and binary forms, with or without * modification, are permitted. * * Some modifications, Jim Fougeron, 2013. Licensing rights listed in * accompanying simd-intrinsics.c file. */ #if !defined(__JTR_SSE_INTRINSICS_H__) #define __JTR_SSE_INTRINSICS_H__ #if (SIMD_COEF_32 && SIMD_COEF_32 == 2) || !SIMD_COEF_32 #undef SIMD_TYPE #define SIMD_TYPE "" #undef SIMD_COEF_32 #endif #include #include #include #include #ifndef _EMMINTRIN_H_INCLUDED #define __m128i void #endif #define vtype void #define STRINGIZE2(s) #s #define STRINGIZE(s) STRINGIZE2(s) #if __ALTIVEC__ #undef SIMD_TYPE #define SIMD_TYPE "AltiVec" #elif __ARM_NEON__ #undef SIMD_TYPE #define SIMD_TYPE "NEON" #elif __MIC__ #undef SIMD_TYPE #define SIMD_TYPE "MIC" #elif __AVX512F__ #undef SIMD_TYPE #define SIMD_TYPE "AVX512F" #elif __AVX2__ #undef SIMD_TYPE #define SIMD_TYPE "AVX2" #elif __XOP__ #undef SIMD_TYPE #define SIMD_TYPE "XOP" #elif __AVX__ #undef SIMD_TYPE #define SIMD_TYPE "AVX" #elif __SSE4_1__ #undef SIMD_TYPE #define SIMD_TYPE "SSE4.1" #elif __SSSE3__ #undef SIMD_TYPE #define SIMD_TYPE "SSSE3" #elif __SSE2__ #undef SIMD_TYPE #define SIMD_TYPE "SSE2" #elif SIMD_COEF_32 #undef SIMD_TYPE #define SIMD_TYPE "MMX" // not really supported #endif #if SIMD_COEF_32 == 16 #define BITS "512/512" #elif SIMD_COEF_32 == 8 #define BITS "256/256" #elif SIMD_COEF_32 == 4 #define BITS "128/128" #elif SIMD_COEF_32 == 2 #define BITS "64/64" #endif #ifdef SIMD_PARA_MD5 void md5cryptsse(unsigned char * buf, unsigned char * salt, char * out, unsigned int md5_type); void SIMDmd5body(vtype * data, ARCH_WORD_32 * out, ARCH_WORD_32 * reload_state, unsigned SSEi_flags); void md5_reverse(uint32_t * hash); void md5_unreverse(uint32_t * hash); #define MD5_ALGORITHM_NAME BITS " " SIMD_TYPE " " MD5_N_STR #else #define MD5_ALGORITHM_NAME "32/" ARCH_BITS_STR #endif #ifdef SIMD_PARA_MD4 // void SIMDmd4body(__m128i* data, unsigned int *out, int init); void SIMDmd4body(vtype * data, ARCH_WORD_32 * out, ARCH_WORD_32 * reload_state, unsigned SSEi_flags); void md4_reverse(uint32_t * hash); void md4_unreverse(uint32_t * hash); #define MD4_ALGORITHM_NAME BITS " " SIMD_TYPE " " MD4_N_STR #else #define MD4_ALGORITHM_NAME "32/" ARCH_BITS_STR #endif #ifdef SIMD_PARA_SHA1 void SIMDSHA1body(vtype * data, ARCH_WORD_32 * out, ARCH_WORD_32 * reload_state, unsigned SSEi_flags); void sha1_reverse(uint32_t * hash); void sha1_unreverse(uint32_t * hash); #define SHA1_ALGORITHM_NAME BITS " " SIMD_TYPE " " SHA1_N_STR #else #define SHA1_ALGORITHM_NAME "32/" ARCH_BITS_STR #endif // we use the 'outter' SIMD_COEF_32 wrapper, as the flag for SHA256/SHA512. // FIX_ME!! #if SIMD_COEF_32 > 1 #ifdef SIMD_COEF_32 #define SHA256_ALGORITHM_NAME BITS " " SIMD_TYPE " " SHA256_N_STR void SIMDSHA256body(vtype * data, ARCH_WORD_32 * out, ARCH_WORD_32 * reload_state, unsigned SSEi_flags); void sha224_reverse(uint32_t * hash); void sha224_unreverse(uint32_t * hash); void sha256_reverse(uint32_t * hash); void sha256_unreverse(void); #endif #ifdef SIMD_COEF_64 #define SHA512_ALGORITHM_NAME BITS " " SIMD_TYPE " " SHA512_N_STR void SIMDSHA512body(vtype * data, ARCH_WORD_64 * out, ARCH_WORD_64 * reload_state, unsigned SSEi_flags); void sha384_reverse(ARCH_WORD_64 * hash); void sha384_unreverse(ARCH_WORD_64 * hash); void sha512_reverse(ARCH_WORD_64 * hash); void sha512_unreverse(void); #endif #else #if ARCH_BITS >= 64 #define SHA256_ALGORITHM_NAME "64/" ARCH_BITS_STR " " SHA2_LIB #define SHA512_ALGORITHM_NAME "64/" ARCH_BITS_STR " " SHA2_LIB #else #define SHA256_ALGORITHM_NAME "32/" ARCH_BITS_STR " " SHA2_LIB #define SHA512_ALGORITHM_NAME "32/" ARCH_BITS_STR " " SHA2_LIB #endif #endif #undef vtype /* void */ #endif // __JTR_SSE_INTRINSICS_H__ aircrack-ng-1.6/include/aircrack-ng/ce-wpa/wpapsk.h000066400000000000000000000055261361312141100222000ustar00rootroot00000000000000/* * Based on John the Ripper and modified to integrate with aircrack * * John the Ripper copyright and license. * * John the Ripper password cracker, * Copyright (c) 1996-2013 by Solar Designer. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * As a special exception to the GNU General Public License terms, * permission is hereby granted to link the code of this program, with or * without modification, with any version of the OpenSSL library and/or any * version of unRAR, and to distribute such linked combinations. You must * obey the GNU GPL in all respects for all of the code used other than * OpenSSL and unRAR. If you modify this program, you may extend this * exception to your version of the program, but you are not obligated to * do so. (In other words, you may release your derived work under pure * GNU GPL version 2 or later as published by the FSF.) * * (This exception from the GNU GPL is not required for the core tree of * John the Ripper, but arguably it is required for -jumbo.) * * Relaxed terms for certain components. * * In addition or alternatively to the license above, many components are * available to you under more relaxed terms (most commonly under cut-down * BSD license) as specified in the corresponding source files. * * For more information on John the Ripper licensing please visit: * * http://www.openwall.com/john/doc/LICENSE.shtml * * This software is Copyright (c) 2012 Lukas Odzioba * and Copyright (c) 2012-2014 magnum * and it is hereby released to the general public under the following terms: * Redistribution and use in source and binary forms, with or without * modification, are permitted. * * hccap format was introduced by oclHashcat-plus, and it is described here: * http://hashcat.net/wiki/hccap * Code is based on Aircrack-ng source */ #ifndef _WPAPSK_H #define _WPAPSK_H #include #include #include #include #include #include #include #include #ifdef __cplusplus extern "C" { #endif void init_atoi(void); int init_wpapsk(ac_crypto_engine_t * engine, const wpapsk_password key[MAX_KEYS_PER_CRYPT_SUPPORTED], int nparallel, int threadid); #ifdef __cplusplus } #endif #endif /* _WPAPSK_H */ aircrack-ng-1.6/include/aircrack-ng/cowpatty/000077500000000000000000000000001361312141100212105ustar00rootroot00000000000000aircrack-ng-1.6/include/aircrack-ng/cowpatty/cowpatty.h000066400000000000000000000044171361312141100232410ustar00rootroot00000000000000/* * coWPAtty hash DB file format structures and helper functions * * Copyright (C) 2018-2020 Thomas d'Otreppe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. * If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. * If you * do not wish to do so, delete this exception statement from your * version. * If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifndef _COWPATTY_H_ #define _COWPATTY_H_ #include #define MAX_PASSPHRASE_LENGTH 63 #define GENPMKMAGIC 0x43575041 struct hashdb_head { uint32_t magic; uint8_t reserved1[3]; uint8_t ssidlen; uint8_t ssid[32]; }; struct hashdb_rec { uint8_t rec_size; char * word; uint8_t pmk[32]; } __attribute__((packed)); struct cowpatty_file { char ssid[33]; FILE * fp; char error[256 - sizeof(FILE *) - 33]; }; void close_free_cowpatty_hashdb(struct cowpatty_file * cf); struct cowpatty_file * open_cowpatty_hashdb(const char * filename, const char * mode); struct hashdb_rec * read_next_cowpatty_record(struct cowpatty_file * cf); #endif // _COWPATTY_H_ aircrack-ng-1.6/include/aircrack-ng/cpu/000077500000000000000000000000001361312141100201255ustar00rootroot00000000000000aircrack-ng-1.6/include/aircrack-ng/cpu/cpuset.h000066400000000000000000000045151361312141100216060ustar00rootroot00000000000000/* * Copyright (C) 2018-2020 Joseph Benden * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * is provided AS IS, WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and * NON-INFRINGEMENT. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, * MA 02110-1301, USA. * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifndef AIRCRACK_UTIL_CPUSET_H #define AIRCRACK_UTIL_CPUSET_H #include #ifdef __cplusplus extern "C" { #endif struct ac_cpuset; typedef struct ac_cpuset ac_cpuset_t; /// Allocate a new cpuset module handle. ac_cpuset_t * ac_cpuset_new(void); /// Deallocate a cpuset module handle. void ac_cpuset_free(ac_cpuset_t * cpuset); /// Initialize the cpuset module handle. void ac_cpuset_init(ac_cpuset_t * cpuset); /// Destroy the cpuset module handle. void ac_cpuset_destroy(ac_cpuset_t * cpuset); /// Distribute \a count threads over all available CPUs. void ac_cpuset_distribute(ac_cpuset_t * cpuset, size_t count); /// Bind \a tid to the CPU stored at the \a idx index position. void ac_cpuset_bind_thread_at(ac_cpuset_t * cpuset, pthread_t tid, size_t idx); #ifdef __cplusplus } #endif #endif aircrack-ng-1.6/include/aircrack-ng/cpu/simd_cpuid.h000066400000000000000000000053301361312141100224170ustar00rootroot00000000000000/* * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * is provided AS IS, WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and * NON-INFRINGEMENT. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, * MA 02110-1301, USA. * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifndef AIRCRACK_NG_CPUID_H #define AIRCRACK_NG_CPUID_H #ifdef __cplusplus extern "C" { #endif struct _cpuinfo { int simdsize; /* SIMD size */ char * flags; /* Feature Flags */ char * model; /* CPU Model */ int cores; /* Real CPU cores */ int coreperid; /* Max cores per id */ int htt; /* Hyper-Threading */ int maxlogic; /* Max addressible lCPU */ int hv; /* Hypervisor detected */ int cpufreq_cur; /* CPUfreq Current */ int cpufreq_max; /* CPUfreq Maximum */ float coretemp; /* CPU Temperature */ char * cputemppath; /* Linux CPU Sensor Path */ }; /** * Retrieve the number of 32-bit integers able to be packed into a single * vector register. * * This value is dependent on the running machine, and may not reflect what * the source code is able to process. PROGRAMMER BEWARE! * * @return int Number of 32-bit integers able to pack in one vector register. */ extern int cpuid_simdsize(int); /// Populates the \a cpuinfo with detected information about the running /// machine. extern int cpuid_getinfo(void); /// Structure containing information about the running machine. The /// function \a cpuid_getinfo must be called first! extern struct _cpuinfo cpuinfo; #ifdef __cplusplus }; #endif #endif // AIRCRACK_NG_CPUID_H aircrack-ng-1.6/include/aircrack-ng/cpu/trampoline.h000066400000000000000000000025601361312141100224530ustar00rootroot00000000000000/* * Copyright (C) 2018-2020 Joseph Benden * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ #ifndef AIRCRACK_NG_TRAMPOLINE_H #define AIRCRACK_NG_TRAMPOLINE_H #ifdef __cplusplus extern "C" { #endif #define SIMD_SUPPORTS_NONE (1 << 0) #define SIMD_SUPPORTS_MMX (1 << 1) #define SIMD_SUPPORTS_SSE2 (1 << 2) #define SIMD_SUPPORTS_AVX (1 << 3) #define SIMD_SUPPORTS_AVX2 (1 << 4) #define SIMD_SUPPORTS_NEON (1 << 5) #define SIMD_SUPPORTS_ASIMD (1 << 6) #define SIMD_SUPPORTS_ALTIVEC (1 << 7) #define SIMD_SUPPORTS_POWER8 (1 << 8) #define SIMD_SUPPORTS_AVX512F (1 << 9) void simd_init(void); int simd_get_supported_features(void); void simd_destroy(void); #ifdef __cplusplus }; #endif #endif aircrack-ng-1.6/include/aircrack-ng/crypto/000077500000000000000000000000001361312141100206565ustar00rootroot00000000000000aircrack-ng-1.6/include/aircrack-ng/crypto/crctable.h000066400000000000000000000244771361312141100226240ustar00rootroot00000000000000#ifndef _CRCTABLE_H #define _CRCTABLE_H const unsigned long int crc_tbl[256] = {0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5, 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F, 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433, 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01, 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD, 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7, 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79, 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45, 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D}; const unsigned char crc_chop_tbl[256][4] = {{0x26, 0x70, 0x6A, 0x0F}, {0x67, 0x76, 0x1B, 0xD4}, {0xE5, 0x7A, 0xF9, 0x62}, {0xA4, 0x7C, 0x88, 0xB9}, {0xA0, 0x65, 0x4C, 0xD4}, {0xE1, 0x63, 0x3D, 0x0F}, {0x63, 0x6F, 0xDF, 0xB9}, {0x22, 0x69, 0xAE, 0x62}, {0x6B, 0x5D, 0x57, 0x62}, {0x2A, 0x5B, 0x26, 0xB9}, {0xA8, 0x57, 0xC4, 0x0F}, {0xE9, 0x51, 0xB5, 0xD4}, {0xED, 0x48, 0x71, 0xB9}, {0xAC, 0x4E, 0x00, 0x62}, {0x2E, 0x42, 0xE2, 0xD4}, {0x6F, 0x44, 0x93, 0x0F}, {0xBC, 0x2A, 0x10, 0xD5}, {0xFD, 0x2C, 0x61, 0x0E}, {0x7F, 0x20, 0x83, 0xB8}, {0x3E, 0x26, 0xF2, 0x63}, {0x3A, 0x3F, 0x36, 0x0E}, {0x7B, 0x39, 0x47, 0xD5}, {0xF9, 0x35, 0xA5, 0x63}, {0xB8, 0x33, 0xD4, 0xB8}, {0xF1, 0x07, 0x2D, 0xB8}, {0xB0, 0x01, 0x5C, 0x63}, {0x32, 0x0D, 0xBE, 0xD5}, {0x73, 0x0B, 0xCF, 0x0E}, {0x77, 0x12, 0x0B, 0x63}, {0x36, 0x14, 0x7A, 0xB8}, {0xB4, 0x18, 0x98, 0x0E}, {0xF5, 0x1E, 0xE9, 0xD5}, {0x53, 0xC3, 0xEF, 0x60}, {0x12, 0xC5, 0x9E, 0xBB}, {0x90, 0xC9, 0x7C, 0x0D}, {0xD1, 0xCF, 0x0D, 0xD6}, {0xD5, 0xD6, 0xC9, 0xBB}, {0x94, 0xD0, 0xB8, 0x60}, {0x16, 0xDC, 0x5A, 0xD6}, {0x57, 0xDA, 0x2B, 0x0D}, {0x1E, 0xEE, 0xD2, 0x0D}, {0x5F, 0xE8, 0xA3, 0xD6}, {0xDD, 0xE4, 0x41, 0x60}, {0x9C, 0xE2, 0x30, 0xBB}, {0x98, 0xFB, 0xF4, 0xD6}, {0xD9, 0xFD, 0x85, 0x0D}, {0x5B, 0xF1, 0x67, 0xBB}, {0x1A, 0xF7, 0x16, 0x60}, {0xC9, 0x99, 0x95, 0xBA}, {0x88, 0x9F, 0xE4, 0x61}, {0x0A, 0x93, 0x06, 0xD7}, {0x4B, 0x95, 0x77, 0x0C}, {0x4F, 0x8C, 0xB3, 0x61}, {0x0E, 0x8A, 0xC2, 0xBA}, {0x8C, 0x86, 0x20, 0x0C}, {0xCD, 0x80, 0x51, 0xD7}, {0x84, 0xB4, 0xA8, 0xD7}, {0xC5, 0xB2, 0xD9, 0x0C}, {0x47, 0xBE, 0x3B, 0xBA}, {0x06, 0xB8, 0x4A, 0x61}, {0x02, 0xA1, 0x8E, 0x0C}, {0x43, 0xA7, 0xFF, 0xD7}, {0xC1, 0xAB, 0x1D, 0x61}, {0x80, 0xAD, 0x6C, 0xBA}, {0xCC, 0x16, 0x61, 0xD0}, {0x8D, 0x10, 0x10, 0x0B}, {0x0F, 0x1C, 0xF2, 0xBD}, {0x4E, 0x1A, 0x83, 0x66}, {0x4A, 0x03, 0x47, 0x0B}, {0x0B, 0x05, 0x36, 0xD0}, {0x89, 0x09, 0xD4, 0x66}, {0xC8, 0x0F, 0xA5, 0xBD}, {0x81, 0x3B, 0x5C, 0xBD}, {0xC0, 0x3D, 0x2D, 0x66}, {0x42, 0x31, 0xCF, 0xD0}, {0x03, 0x37, 0xBE, 0x0B}, {0x07, 0x2E, 0x7A, 0x66}, {0x46, 0x28, 0x0B, 0xBD}, {0xC4, 0x24, 0xE9, 0x0B}, {0x85, 0x22, 0x98, 0xD0}, {0x56, 0x4C, 0x1B, 0x0A}, {0x17, 0x4A, 0x6A, 0xD1}, {0x95, 0x46, 0x88, 0x67}, {0xD4, 0x40, 0xF9, 0xBC}, {0xD0, 0x59, 0x3D, 0xD1}, {0x91, 0x5F, 0x4C, 0x0A}, {0x13, 0x53, 0xAE, 0xBC}, {0x52, 0x55, 0xDF, 0x67}, {0x1B, 0x61, 0x26, 0x67}, {0x5A, 0x67, 0x57, 0xBC}, {0xD8, 0x6B, 0xB5, 0x0A}, {0x99, 0x6D, 0xC4, 0xD1}, {0x9D, 0x74, 0x00, 0xBC}, {0xDC, 0x72, 0x71, 0x67}, {0x5E, 0x7E, 0x93, 0xD1}, {0x1F, 0x78, 0xE2, 0x0A}, {0xB9, 0xA5, 0xE4, 0xBF}, {0xF8, 0xA3, 0x95, 0x64}, {0x7A, 0xAF, 0x77, 0xD2}, {0x3B, 0xA9, 0x06, 0x09}, {0x3F, 0xB0, 0xC2, 0x64}, {0x7E, 0xB6, 0xB3, 0xBF}, {0xFC, 0xBA, 0x51, 0x09}, {0xBD, 0xBC, 0x20, 0xD2}, {0xF4, 0x88, 0xD9, 0xD2}, {0xB5, 0x8E, 0xA8, 0x09}, {0x37, 0x82, 0x4A, 0xBF}, {0x76, 0x84, 0x3B, 0x64}, {0x72, 0x9D, 0xFF, 0x09}, {0x33, 0x9B, 0x8E, 0xD2}, {0xB1, 0x97, 0x6C, 0x64}, {0xF0, 0x91, 0x1D, 0xBF}, {0x23, 0xFF, 0x9E, 0x65}, {0x62, 0xF9, 0xEF, 0xBE}, {0xE0, 0xF5, 0x0D, 0x08}, {0xA1, 0xF3, 0x7C, 0xD3}, {0xA5, 0xEA, 0xB8, 0xBE}, {0xE4, 0xEC, 0xC9, 0x65}, {0x66, 0xE0, 0x2B, 0xD3}, {0x27, 0xE6, 0x5A, 0x08}, {0x6E, 0xD2, 0xA3, 0x08}, {0x2F, 0xD4, 0xD2, 0xD3}, {0xAD, 0xD8, 0x30, 0x65}, {0xEC, 0xDE, 0x41, 0xBE}, {0xE8, 0xC7, 0x85, 0xD3}, {0xA9, 0xC1, 0xF4, 0x08}, {0x2B, 0xCD, 0x16, 0xBE}, {0x6A, 0xCB, 0x67, 0x65}, {0xB3, 0xBB, 0x0D, 0x6A}, {0xF2, 0xBD, 0x7C, 0xB1}, {0x70, 0xB1, 0x9E, 0x07}, {0x31, 0xB7, 0xEF, 0xDC}, {0x35, 0xAE, 0x2B, 0xB1}, {0x74, 0xA8, 0x5A, 0x6A}, {0xF6, 0xA4, 0xB8, 0xDC}, {0xB7, 0xA2, 0xC9, 0x07}, {0xFE, 0x96, 0x30, 0x07}, {0xBF, 0x90, 0x41, 0xDC}, {0x3D, 0x9C, 0xA3, 0x6A}, {0x7C, 0x9A, 0xD2, 0xB1}, {0x78, 0x83, 0x16, 0xDC}, {0x39, 0x85, 0x67, 0x07}, {0xBB, 0x89, 0x85, 0xB1}, {0xFA, 0x8F, 0xF4, 0x6A}, {0x29, 0xE1, 0x77, 0xB0}, {0x68, 0xE7, 0x06, 0x6B}, {0xEA, 0xEB, 0xE4, 0xDD}, {0xAB, 0xED, 0x95, 0x06}, {0xAF, 0xF4, 0x51, 0x6B}, {0xEE, 0xF2, 0x20, 0xB0}, {0x6C, 0xFE, 0xC2, 0x06}, {0x2D, 0xF8, 0xB3, 0xDD}, {0x64, 0xCC, 0x4A, 0xDD}, {0x25, 0xCA, 0x3B, 0x06}, {0xA7, 0xC6, 0xD9, 0xB0}, {0xE6, 0xC0, 0xA8, 0x6B}, {0xE2, 0xD9, 0x6C, 0x06}, {0xA3, 0xDF, 0x1D, 0xDD}, {0x21, 0xD3, 0xFF, 0x6B}, {0x60, 0xD5, 0x8E, 0xB0}, {0xC6, 0x08, 0x88, 0x05}, {0x87, 0x0E, 0xF9, 0xDE}, {0x05, 0x02, 0x1B, 0x68}, {0x44, 0x04, 0x6A, 0xB3}, {0x40, 0x1D, 0xAE, 0xDE}, {0x01, 0x1B, 0xDF, 0x05}, {0x83, 0x17, 0x3D, 0xB3}, {0xC2, 0x11, 0x4C, 0x68}, {0x8B, 0x25, 0xB5, 0x68}, {0xCA, 0x23, 0xC4, 0xB3}, {0x48, 0x2F, 0x26, 0x05}, {0x09, 0x29, 0x57, 0xDE}, {0x0D, 0x30, 0x93, 0xB3}, {0x4C, 0x36, 0xE2, 0x68}, {0xCE, 0x3A, 0x00, 0xDE}, {0x8F, 0x3C, 0x71, 0x05}, {0x5C, 0x52, 0xF2, 0xDF}, {0x1D, 0x54, 0x83, 0x04}, {0x9F, 0x58, 0x61, 0xB2}, {0xDE, 0x5E, 0x10, 0x69}, {0xDA, 0x47, 0xD4, 0x04}, {0x9B, 0x41, 0xA5, 0xDF}, {0x19, 0x4D, 0x47, 0x69}, {0x58, 0x4B, 0x36, 0xB2}, {0x11, 0x7F, 0xCF, 0xB2}, {0x50, 0x79, 0xBE, 0x69}, {0xD2, 0x75, 0x5C, 0xDF}, {0x93, 0x73, 0x2D, 0x04}, {0x97, 0x6A, 0xE9, 0x69}, {0xD6, 0x6C, 0x98, 0xB2}, {0x54, 0x60, 0x7A, 0x04}, {0x15, 0x66, 0x0B, 0xDF}, {0x59, 0xDD, 0x06, 0xB5}, {0x18, 0xDB, 0x77, 0x6E}, {0x9A, 0xD7, 0x95, 0xD8}, {0xDB, 0xD1, 0xE4, 0x03}, {0xDF, 0xC8, 0x20, 0x6E}, {0x9E, 0xCE, 0x51, 0xB5}, {0x1C, 0xC2, 0xB3, 0x03}, {0x5D, 0xC4, 0xC2, 0xD8}, {0x14, 0xF0, 0x3B, 0xD8}, {0x55, 0xF6, 0x4A, 0x03}, {0xD7, 0xFA, 0xA8, 0xB5}, {0x96, 0xFC, 0xD9, 0x6E}, {0x92, 0xE5, 0x1D, 0x03}, {0xD3, 0xE3, 0x6C, 0xD8}, {0x51, 0xEF, 0x8E, 0x6E}, {0x10, 0xE9, 0xFF, 0xB5}, {0xC3, 0x87, 0x7C, 0x6F}, {0x82, 0x81, 0x0D, 0xB4}, {0x00, 0x8D, 0xEF, 0x02}, {0x41, 0x8B, 0x9E, 0xD9}, {0x45, 0x92, 0x5A, 0xB4}, {0x04, 0x94, 0x2B, 0x6F}, {0x86, 0x98, 0xC9, 0xD9}, {0xC7, 0x9E, 0xB8, 0x02}, {0x8E, 0xAA, 0x41, 0x02}, {0xCF, 0xAC, 0x30, 0xD9}, {0x4D, 0xA0, 0xD2, 0x6F}, {0x0C, 0xA6, 0xA3, 0xB4}, {0x08, 0xBF, 0x67, 0xD9}, {0x49, 0xB9, 0x16, 0x02}, {0xCB, 0xB5, 0xF4, 0xB4}, {0x8A, 0xB3, 0x85, 0x6F}, {0x2C, 0x6E, 0x83, 0xDA}, {0x6D, 0x68, 0xF2, 0x01}, {0xEF, 0x64, 0x10, 0xB7}, {0xAE, 0x62, 0x61, 0x6C}, {0xAA, 0x7B, 0xA5, 0x01}, {0xEB, 0x7D, 0xD4, 0xDA}, {0x69, 0x71, 0x36, 0x6C}, {0x28, 0x77, 0x47, 0xB7}, {0x61, 0x43, 0xBE, 0xB7}, {0x20, 0x45, 0xCF, 0x6C}, {0xA2, 0x49, 0x2D, 0xDA}, {0xE3, 0x4F, 0x5C, 0x01}, {0xE7, 0x56, 0x98, 0x6C}, {0xA6, 0x50, 0xE9, 0xB7}, {0x24, 0x5C, 0x0B, 0x01}, {0x65, 0x5A, 0x7A, 0xDA}, {0xB6, 0x34, 0xF9, 0x00}, {0xF7, 0x32, 0x88, 0xDB}, {0x75, 0x3E, 0x6A, 0x6D}, {0x34, 0x38, 0x1B, 0xB6}, {0x30, 0x21, 0xDF, 0xDB}, {0x71, 0x27, 0xAE, 0x00}, {0xF3, 0x2B, 0x4C, 0xB6}, {0xB2, 0x2D, 0x3D, 0x6D}, {0xFB, 0x19, 0xC4, 0x6D}, {0xBA, 0x1F, 0xB5, 0xB6}, {0x38, 0x13, 0x57, 0x00}, {0x79, 0x15, 0x26, 0xDB}, {0x7D, 0x0C, 0xE2, 0xB6}, {0x3C, 0x0A, 0x93, 0x6D}, {0xBE, 0x06, 0x71, 0xDB}, {0xFF, 0x00, 0x00, 0x00}}; #endif /* crctable.h */ aircrack-ng-1.6/include/aircrack-ng/crypto/crypto.h000066400000000000000000000156341361312141100223600ustar00rootroot00000000000000/* * MD5, SHA-1, RC4 and AES implementations * * Copyright (C) 2001-2004 Christophe Devine * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifndef _CRYPTO_H #define _CRYPTO_H #include #include #ifdef USE_GCRYPT #include #include #else #include #include #include #include #include #if HAVE_OPENSSL_CMAC_H #include #endif #endif #include #define CRYPT_NONE 0 #define CRYPT_WEP 1 #define CRYPT_WPA 2 #define S_LLC_SNAP "\xAA\xAA\x03\x00\x00\x00" #define S_LLC_SNAP_ARP (S_LLC_SNAP "\x08\x06") #define S_LLC_SNAP_WLCCP "\xAA\xAA\x03\x00\x40\x96\x00\x00" #define S_LLC_SNAP_IP (S_LLC_SNAP "\x08\x00") #define S_LLC_SNAP_SPANTREE "\x42\x42\x03\x00\x00\x00\x00\x00" #define S_LLC_SNAP_CDP "\xAA\xAA\x03\x00\x00\x0C\x20" #define IEEE80211_FC1_DIR_FROMDS 0x02 /* AP ->STA */ #define TYPE_ARP 0 #define TYPE_IP 1 #define NULL_MAC (unsigned char *) "\x00\x00\x00\x00\x00\x00" #define BROADCAST (unsigned char *) "\xFF\xFF\xFF\xFF\xFF\xFF" #define SPANTREE (unsigned char *) "\x01\x80\xC2\x00\x00\x00" #define CDP_VTP (unsigned char *) "\x01\x00\x0C\xCC\xCC\xCC" #define IEEE80211_FC0_SUBTYPE_MASK 0xf0 #define IEEE80211_FC0_SUBTYPE_SHIFT 4 /* for TYPE_DATA (bit combination) */ #define IEEE80211_FC0_SUBTYPE_QOS 0x80 #define IEEE80211_FC0_SUBTYPE_QOS_NULL 0xc0 #define GET_SUBTYPE(fc) \ (((fc) &IEEE80211_FC0_SUBTYPE_MASK) >> IEEE80211_FC0_SUBTYPE_SHIFT) \ << IEEE80211_FC0_SUBTYPE_SHIFT #define ROL32(A, n) (((A) << (n)) | (((A) >> (32 - (n))) & ((1UL << (n)) - 1))) #define ROR32(A, n) ROL32((A), 32 - (n)) struct WPA_ST_info { struct WPA_ST_info * next; /* next supplicant */ unsigned char stmac[6]; /* supplicant MAC */ unsigned char bssid[6]; /* authenticator MAC */ unsigned char snonce[32]; /* supplicant nonce */ unsigned char anonce[32]; /* authenticator nonce */ unsigned char keymic[20]; /* eapol frame MIC */ unsigned char eapol[256]; /* eapol frame contents */ unsigned char ptk[80]; /* pairwise transcient key */ unsigned eapol_size; /* eapol frame size */ unsigned long t_crc; /* last ToDS frame CRC */ unsigned long f_crc; /* last FromDS frame CRC */ int keyver, valid_ptk; unsigned char pn[6]; /* Packet Number (WPA-CCMP) */ }; struct Michael { unsigned long key0; unsigned long key1; unsigned long left; unsigned long right; unsigned long nBytesInM; unsigned long message; unsigned char mic[8]; }; /* Used for own RC4 implementation */ struct rc4_state { int x, y, m[256]; }; struct AP_info; void calc_pmk(char * key, char * essid, unsigned char pmk[40]); int decrypt_wep(unsigned char * data, int len, unsigned char * key, int keylen); int encrypt_wep(unsigned char * data, int len, unsigned char * key, int keylen); int check_crc_buf(const unsigned char * buf, int len); int calc_crc_buf(const unsigned char * buf, int len); void calc_mic(struct AP_info * ap, unsigned char * pmk, unsigned char * ptk, unsigned char * mic); int known_clear( void * clear, int * clen, int * weight, unsigned char * wh, size_t len); int add_crc32(unsigned char * data, int length); int add_crc32_plain(unsigned char * data, int length); int is_ipv6(void * wh); int is_dhcp_discover(void * wh, size_t len); int is_qos_arp_tkip(void * wh, int len); int calc_tkip_ppk(unsigned char * h80211, int caplen, unsigned char TK1[16], unsigned char key[16]); void encrypt_tkip(unsigned char * h80211, int caplen, unsigned char PTK[80]); int decrypt_tkip(unsigned char * h80211, int caplen, unsigned char TK1[16]); int encrypt_ccmp(unsigned char * h80211, int caplen, unsigned char TK1[16], unsigned char PN[6]); int decrypt_ccmp(unsigned char * h80211, int caplen, unsigned char TK1[16]); int calc_ptk(struct WPA_ST_info * wpa, unsigned char pmk[32]); int calc_tkip_mic(unsigned char * packet, int length, unsigned char ptk[80], unsigned char value[8]); int michael_test(unsigned char key[8], unsigned char * message, int length, unsigned char out[8]); int calc_tkip_mic_key(unsigned char * packet, int length, unsigned char key[8]); extern const unsigned long int crc_tbl[256]; extern const unsigned char crc_chop_tbl[256][4]; static inline void add_icv(unsigned char * input, int len, int offset) { REQUIRE(input != NULL); REQUIRE(len > 0 && len < (INT_MAX - 4)); REQUIRE(offset >= 0 && offset <= len); unsigned long crc = 0xFFFFFFFF; for (int n = offset; n < len; n++) crc = crc_tbl[(crc ^ input[n]) & 0xFF] ^ (crc >> 8); crc = ~crc; input[len] = (uint8_t)((crc) &0xFF); input[len + 1] = (uint8_t)((crc >> 8) & 0xFF); input[len + 2] = (uint8_t)((crc >> 16) & 0xFF); input[len + 3] = (uint8_t)((crc >> 24) & 0xFF); } static inline int eapol_handshake_step(const unsigned char * eapol, const int len) { REQUIRE(eapol != NULL); const int eapol_size = 4 + 1 + 2 + 2 + 8 + 32 + 16 + 8 + 8 + 16 + 2; if (len < eapol_size) return (0); /* not pairwise */ if ((eapol[6] & 0x08) == 0) return (0); /* 1: has no mic */ if ((eapol[5] & 1) == 0) return (1); /* 3: has ack */ if ((eapol[6] & 0x80) != 0) return (3); if (*((uint16_t *) &eapol[eapol_size - 2]) == 0) return (4); return (2); } /// Initialize the system cryptography librar(ies). API_IMPORT void ac_crypto_init(void); #endif /* crypto.h */ aircrack-ng-1.6/include/aircrack-ng/crypto/gcrypt-openssl-wrapper.h000066400000000000000000000213121361312141100254750ustar00rootroot00000000000000#ifndef _GCRYPT_OPENSSL_WRAPPER_H #define _GCRYPT_OPENSSL_WRAPPER_H /* * * gcrypt-openssl-wrapper.h * * Copyright (C) 2012 Carlos Alberto Lopez Perez * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. * */ #include // RC4_* #define RC4_KEY gcry_cipher_hd_t #define RC4_set_key(h, l, k) \ do \ { \ gcry_cipher_open(h, GCRY_CIPHER_ARCFOUR, GCRY_CIPHER_MODE_STREAM, 0); \ gcry_cipher_setkey(*h, k, l); \ } while (0) // we need to release the handle to avoid memory leaks. // And in the actual code there are not repeat calls to RC4() without calling // RC4_set_key() first, so we can encapsulate the call to gcry_cipher_close() // inside RC4() // This should be changed if you call RC4() without calling RC4_set_key before #define RC4(h, l, s, d) \ do \ { \ gcry_cipher_encrypt(*h, d, l, s, l); \ gcry_cipher_close(*h); \ } while (0) // SHA_* (We use the sha1-git implementation because is much faster) #define SHA_CTX blk_SHA_CTX #define SHA1_Init(ctx) blk_SHA1_Init(ctx) #define SHA1_Update(ctx, buffer, len) blk_SHA1_Update(ctx, buffer, len) #define SHA1_Final(digest, ctx) blk_SHA1_Final(digest, ctx) // EVP_* #define EVP_md5() GCRY_MD_MD5 #define EVP_sha1() GCRY_MD_SHA1 // AES_* #define AES_KEY gcry_cipher_hd_t #define AES_encrypt(text, enc_out, ctx) \ gcry_cipher_encrypt(*ctx, enc_out, 16, text, 16) #define AES_set_encrypt_key(key, len, ctx) \ do \ { \ gcry_cipher_open(ctx, GCRY_CIPHER_AES, GCRY_CIPHER_MODE_ECB, 0); \ gcry_cipher_setkey(*ctx, key, len / 8); \ } while (0) // CMAC_* #define EVP_aes_128_cbc() GCRY_MAC_CMAC_AES #define CMAC_CTX gcry_mac_hd_t #define CMAC_CTX_new() calloc(1, sizeof(gcry_mac_hd_t)) #define CMAC_CTX_free(ctx) \ do \ { \ gcry_mac_close(*ctx); \ free(ctx); \ } while (0) #define CMAC_Init(ctx, key, len, mac, flag) \ do \ { \ if ((len == 0) || (key == NULL) || (mac == 0)) \ { \ gcry_mac_reset(*ctx); \ } \ else \ { \ gcry_mac_open(ctx, mac, 0, NULL); \ gcry_mac_setkey(*ctx, key, len); \ } \ } while (0) #define CMAC_Update(ctx, data, len) gcry_mac_write(*ctx, data, len) #define CMAC_Final(ctx, mac, len) \ do \ { \ gcry_mac_read(*ctx, mac, len); \ } while (0) // HMAC_* #define HMAC_CTX gcry_md_hd_t #define HMAC_CTX_cleanup(ctx) gcry_md_close(*ctx) #define HMAC_CTX_init(ctx) ; // noop #define HMAC_Init_ex(ctx, key, len, md, engine) HMAC_Init(ctx, key, len, md) #define HMAC_Init(ctx, key, len, md) \ do \ { \ if ((len == 0) || (key == NULL) || (md == 0)) \ { \ gcry_md_reset(*ctx); \ } \ else \ { \ gcry_md_open(ctx, md, GCRY_MD_FLAG_HMAC); \ gcry_md_setkey(*ctx, key, len); \ } \ } while (0) #define HMAC_Update(ctx, data, len) gcry_md_write(*ctx, data, len) #define HMAC_Final(ctx, md, len) \ do \ { \ memcpy(md, \ gcry_md_read(*ctx, 0), \ gcry_md_get_algo_dlen(gcry_md_get_algo(*ctx))); \ } while (0) #define HMAC(algo, key, klen, data, dlen, res, rlen) \ do \ { \ gcry_md_hd_t mdh; \ gcry_md_open(&mdh, algo, GCRY_MD_FLAG_HMAC); \ gcry_md_setkey(mdh, key, klen); \ gcry_md_write(mdh, data, dlen); \ memcpy(res, gcry_md_read(mdh, algo), gcry_md_get_algo_dlen(algo)); \ gcry_md_close(mdh); \ } while (0) // MD5 #define MD5_CTX gcry_md_hd_t #define MD5_Init(ctx) gcry_md_open(ctx, GCRY_MD_MD5, 0) #define MD5_Update(ctx, data, len) gcry_md_write(*ctx, data, len) // HMAC_Update(ctx, data, len) #define MD5_Final(ctx, md) \ do \ { \ memcpy( \ md, \ gcry_md_read(*(gcry_md_hd_t *) ctx, GCRY_MD_MD5), \ gcry_md_get_algo_dlen(gcry_md_get_algo(*(gcry_md_hd_t *) ctx))); \ gcry_md_close(*(gcry_md_hd_t *) ctx); \ } while (0) // SHA256 #define SHA256_CTX gcry_md_hd_t #define SHA256_Init(ctx) gcry_md_open(ctx, GCRY_MD_SHA256, 0) #define SHA256_Update(ctx, data, len) gcry_md_write(*ctx, data, len) #define SHA256_Final(md, ctx) \ do \ { \ memcpy( \ md, \ gcry_md_read(*(gcry_md_hd_t *) ctx, GCRY_MD_SHA256), \ gcry_md_get_algo_dlen(gcry_md_get_algo(*(gcry_md_hd_t *) ctx))); \ gcry_md_close(*(gcry_md_hd_t *) ctx); \ } while (0) // http://tumblr.spantz.org/post/214737529/the-use-of-do-while-0-in-c-macros #endif // _GCRYPT_OPENSSL_WRAPPER_H aircrack-ng-1.6/include/aircrack-ng/crypto/sha1-git.h000066400000000000000000000032041361312141100224430ustar00rootroot00000000000000/* * sha1-git.h * * This code is based on the GIT SHA1 Implementation. * * Copyright (C) 2009 Linus Torvalds * Copyright (C) 2009 Nicolas Pitre * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. * */ /* * SHA1 routine optimized to do word accesses rather than byte accesses, * and to avoid unnecessary copies into the context array. * * This was initially based on the Mozilla SHA1 implementation, although * none of the original Mozilla code remains. */ typedef struct { unsigned long long size; unsigned int h0, h1, h2, h3, h4; unsigned int W[16]; } blk_SHA_CTX; void blk_SHA1_Init(blk_SHA_CTX * ctx); void blk_SHA1_Update(blk_SHA_CTX * ctx, const void * dataIn, unsigned long len); void blk_SHA1_Final(unsigned char hashout[20], blk_SHA_CTX * ctx); #define git_SHA_CTX blk_SHA_CTX #define git_SHA1_Init blk_SHA1_Init #define git_SHA1_Update blk_SHA1_Update #define git_SHA1_Final blk_SHA1_Final #define SHA_DIGEST_LENGTH 20 aircrack-ng-1.6/include/aircrack-ng/crypto/sha1-sse2.h000066400000000000000000000224141361312141100225400ustar00rootroot00000000000000/* C code for SSE2 (i386) optimized SHA1 - License: GPLv2 * (c) nx5 * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * is provided AS IS, WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and * NON-INFRINGEMENT. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, * MA 02110-1301, USA. * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. */ #include #include #include #include #include #if defined(__i386__) || ((defined(__x86_64__) && !defined(__CYGWIN__)) \ || (defined(__x86_64__) && defined(__CYGWIN__) \ && !defined(__clang__))) #ifdef OLD_SSE_CORE void show_result(char * key, unsigned char * pmk) { int i; printf("%-14s ", key); for (i = 0; i < 32; i++) printf("%.2X", pmk[i]); printf("\n"); } #endif extern int shasse2_init(unsigned char ctx[80]) __attribute__((regparm(1))); extern int shasse2_ends(unsigned char ctx[80], unsigned char digests[80]) __attribute__((regparm(2))); extern int shasse2_data(unsigned char ctx[80], unsigned char data[256], unsigned char buf[1280]) __attribute__((regparm(3))); extern int shasse2_cpuid(void); #ifdef OLD_SSE_CORE void calc_4pmk(char * _key1, char * _key2, char * _key3, char * _key4, char * _essid, unsigned char * _pmk1, unsigned char * _pmk2, unsigned char * _pmk3, unsigned char * _pmk4) { int slen; char essid[36] __attribute__((aligned(16))); char key1[128] __attribute__((aligned(16))); char key2[128] __attribute__((aligned(16))); char key3[128] __attribute__((aligned(16))); char key4[128] __attribute__((aligned(16))); unsigned char pmks[128 * 4] __attribute__((aligned(16))); // All in double size unsigned char k_ipad[256] __attribute__((aligned(16))); unsigned char ctx_ipad[80] __attribute__((aligned(16))); unsigned char k_opad[256] __attribute__((aligned(16))); unsigned char ctx_opad[80] __attribute__((aligned(16))); unsigned char buffer[256] __attribute__((aligned(16))); unsigned char sha1_ctx[80] __attribute__((aligned(16))); unsigned char wrkbuf[1280] __attribute__((aligned(16))); unsigned i, *u, *v, *w, *u3, *v4; unsigned char *pmk1, *pmk2, *pmk3, *pmk4; pmk1 = pmks; pmk2 = pmks + 128; pmk3 = pmks + 128 * 2; pmk4 = pmks + 128 * 3; memset(key1, 0, sizeof(key1)); memset(key2, 0, sizeof(key2)); memset(key3, 0, sizeof(key3)); memset(key4, 0, sizeof(key4)); memset(essid, 0, sizeof(essid)); memset(pmks, 0, sizeof(pmks)); memset(buffer, 0, sizeof(buffer)); memset(wrkbuf, 0, sizeof(wrkbuf)); memccpy(essid, _essid, 0, sizeof(essid)); memccpy(key1, _key1, 0, sizeof(key1)); memccpy(key2, _key2, 0, sizeof(key2)); memccpy(key3, _key3, 0, sizeof(key3)); memccpy(key4, _key4, 0, sizeof(key4)); slen = strlen(essid) + 4; /* SSE2 available, so compute four PMKs in a single row */ memset(k_ipad, 0, sizeof(k_ipad)); memset(k_opad, 0, sizeof(k_opad)); memcpy(k_ipad, key1, strlen(key1)); memcpy(k_opad, key1, strlen(key1)); memcpy(k_ipad + 64, key2, strlen(key2)); memcpy(k_opad + 64, key2, strlen(key2)); memcpy(k_ipad + 128, key3, strlen(key3)); memcpy(k_opad + 128, key3, strlen(key3)); memcpy(k_ipad + 192, key4, strlen(key4)); memcpy(k_opad + 192, key4, strlen(key4)); u = (unsigned *) (k_ipad); v = (unsigned *) (k_ipad + 64); u3 = (unsigned *) (k_ipad + 128); v4 = (unsigned *) (k_ipad + 192); w = (unsigned *) buffer; for (i = 0; i < 16; i++) { /* interleave the data */ *w++ = *u++ ^ 0x36363636; *w++ = *v++ ^ 0x36363636; *w++ = *u3++ ^ 0x36363636; *w++ = *v4++ ^ 0x36363636; } shasse2_init(ctx_ipad); shasse2_data(ctx_ipad, buffer, wrkbuf); u = (unsigned *) (k_opad); v = (unsigned *) (k_opad + 64); u3 = (unsigned *) (k_opad + 128); v4 = (unsigned *) (k_opad + 192); w = (unsigned *) buffer; for (i = 0; i < 16; i++) { *w++ = *u++ ^ 0x5C5C5C5C; *w++ = *v++ ^ 0x5C5C5C5C; *w++ = *u3++ ^ 0x5C5C5C5C; *w++ = *v4++ ^ 0x5C5C5C5C; } shasse2_init(ctx_opad); shasse2_data(ctx_opad, buffer, wrkbuf); memset(buffer, 0, sizeof(buffer)); buffer[80] = buffer[84] = buffer[88] = buffer[92] = 0x80; buffer[242] = buffer[246] = buffer[250] = buffer[254] = 0x02; buffer[243] = buffer[247] = buffer[251] = buffer[255] = 0xA0; essid[slen - 1] = '\1'; HMAC(EVP_sha1(), (unsigned char *) key1, strlen(key1), (unsigned char *) essid, slen, pmk1, NULL); HMAC(EVP_sha1(), (unsigned char *) key2, strlen(key2), (unsigned char *) essid, slen, pmk2, NULL); HMAC(EVP_sha1(), (unsigned char *) key3, strlen(key3), (unsigned char *) essid, slen, pmk3, NULL); HMAC(EVP_sha1(), (unsigned char *) key4, strlen(key4), (unsigned char *) essid, slen, pmk4, NULL); u = (unsigned *) pmk1; v = (unsigned *) pmk2; u3 = (unsigned *) pmk3; v4 = (unsigned *) pmk4; w = (unsigned *) buffer; *w++ = *u++; *w++ = *v++; *w++ = *u3++; *w++ = *v4++; *w++ = *u++; *w++ = *v++; *w++ = *u3++; *w++ = *v4++; *w++ = *u++; *w++ = *v++; *w++ = *u3++; *w++ = *v4++; *w++ = *u++; *w++ = *v++; *w++ = *u3++; *w++ = *v4++; *w++ = *u++; *w++ = *v++; *w++ = *u3++; *w++ = *v4++; for (i = 1; i < 4096; i++) { memcpy(sha1_ctx, ctx_ipad, 80); // eran 40 shasse2_data(sha1_ctx, buffer, wrkbuf); shasse2_ends(sha1_ctx, buffer); memcpy(sha1_ctx, ctx_opad, 80); shasse2_data(sha1_ctx, buffer, wrkbuf); shasse2_ends(sha1_ctx, buffer); u = (unsigned *) pmk1; v = (unsigned *) pmk2; u3 = (unsigned *) pmk3; v4 = (unsigned *) pmk4; w = (unsigned *) buffer; /* de-interleave the digests */ *u++ ^= *w++; *v++ ^= *w++; *u3++ ^= *w++; *v4++ ^= *w++; *u++ ^= *w++; *v++ ^= *w++; *u3++ ^= *w++; *v4++ ^= *w++; *u++ ^= *w++; *v++ ^= *w++; *u3++ ^= *w++; *v4++ ^= *w++; *u++ ^= *w++; *v++ ^= *w++; *u3++ ^= *w++; *v4++ ^= *w++; *u++ ^= *w++; *v++ ^= *w++; *u3++ ^= *w++; *v4++ ^= *w++; } essid[slen - 1] = '\2'; HMAC(EVP_sha1(), (unsigned char *) key1, strlen(key1), (unsigned char *) essid, slen, pmk1 + 20, NULL); HMAC(EVP_sha1(), (unsigned char *) key2, strlen(key2), (unsigned char *) essid, slen, pmk2 + 20, NULL); HMAC(EVP_sha1(), (unsigned char *) key3, strlen(key3), (unsigned char *) essid, slen, pmk3 + 20, NULL); HMAC(EVP_sha1(), (unsigned char *) key4, strlen(key4), (unsigned char *) essid, slen, pmk4 + 20, NULL); u = (unsigned *) (pmk1 + 20); // eran 20 v = (unsigned *) (pmk2 + 20); u3 = (unsigned *) (pmk3 + 20); // eran 20 v4 = (unsigned *) (pmk4 + 20); w = (unsigned *) buffer; *w++ = *u++; *w++ = *v++; *w++ = *u3++; *w++ = *v4++; *w++ = *u++; *w++ = *v++; *w++ = *u3++; *w++ = *v4++; *w++ = *u++; *w++ = *v++; *w++ = *u3++; *w++ = *v4++; *w++ = *u++; *w++ = *v++; *w++ = *u3++; *w++ = *v4++; *w++ = *u++; *w++ = *v++; *w++ = *u3++; *w++ = *v4++; for (i = 1; i < 4096; i++) { memcpy(sha1_ctx, ctx_ipad, 80); // eran 40 shasse2_data(sha1_ctx, buffer, wrkbuf); shasse2_ends(sha1_ctx, buffer); memcpy(sha1_ctx, ctx_opad, 80); shasse2_data(sha1_ctx, buffer, wrkbuf); shasse2_ends(sha1_ctx, buffer); u = (unsigned *) (pmk1 + 20); // eran 20 v = (unsigned *) (pmk2 + 20); u3 = (unsigned *) (pmk3 + 20); v4 = (unsigned *) (pmk4 + 20); w = (unsigned *) buffer; *u++ ^= *w++; *v++ ^= *w++; *u3++ ^= *w++; *v4++ ^= *w++; *u++ ^= *w++; *v++ ^= *w++; *u3++ ^= *w++; *v4++ ^= *w++; *u++ ^= *w++; *v++ ^= *w++; *u3++ ^= *w++; *v4++ ^= *w++; } memcpy(_pmk3, pmk3, 32); memcpy(_pmk4, pmk4, 32); memcpy(_pmk1, pmk1, 32); memcpy(_pmk2, pmk2, 32); /*printf("\n"); show_result(_key1, _pmk1); show_result(_key2, _pmk2); show_result(_key3, _pmk3); show_result(_key4, _pmk4); fflush(stdout);*/ } #endif #else #ifdef OLD_SSE_CORE void calc_4pmk(char * _key1, char * _key2, char * _key3, char * _key4, char * _essid, unsigned char * _pmk1, unsigned char * _pmk2, unsigned char * _pmk3, unsigned char * _pmk4) { calc_pmk(_key1, _essid, _pmk1); calc_pmk(_key2, _essid, _pmk2); calc_pmk(_key3, _essid, _pmk3); calc_pmk(_key4, _essid, _pmk4); } #endif #endif aircrack-ng-1.6/include/aircrack-ng/defs.h000066400000000000000000000224761361312141100204430ustar00rootroot00000000000000/** * Copyright (C) 2018-2020 Joseph Benden * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. **/ #ifndef AIRCRACK_NG_DEFS_H #define AIRCRACK_NG_DEFS_H #include #include #include #include #include #include #include // NOTE(jbenden): These macros violates MISRA C:2012. 20.10 - The # // and ## preprocessor operators should not be used. #define ALLEGE(c) \ do \ { \ if (!(c)) \ { \ fprintf(stderr, "FAILED:%s:%d: %s\n", __FILE__, __LINE__, #c); \ abort(); \ } \ } while (0) #define REQUIRE(c) \ do \ { \ if (!(c)) \ { \ fprintf(stderr, "Pre-condition Failed: %s\n", #c); \ abort(); \ } \ } while (0) #define ENSURE(c) \ do \ { \ if (!(c)) \ { \ fprintf(stderr, "Post-condition Failed: %s\n", #c); \ abort(); \ } \ } while (0) #define INVARIANT(c) \ do \ { \ if (!(c)) \ { \ fprintf(stderr, "Invariant Failed: %s\n", #c); \ abort(); \ } \ } while (0) #ifdef NDEBUG #undef REQUIRE #define REQUIRE(c) #undef ENSURE #define ENSURE(c) #undef INVARIANT #define INVARIANT(c) #endif #if defined(_MSC_VER) // Microsoft #define API_EXPORT __declspec(dllexport) #define API_IMPORT __declspec(dllimport) #elif defined(__GNUC__) || defined(__llvm__) || defined(__clang__) \ || defined(__INTEL_COMPILER) #define API_EXPORT __attribute__((visibility("default"))) #define API_IMPORT #else // do nothing and hope for the best? #define API_EXPORT #define API_IMPORT #pragma warning Unknown dynamic link import / export semantics. #endif #define STATIC_ASSERT(COND, MSG) \ typedef char static_assertion_##MSG[(!!(COND)) * 2 - 1] // token pasting madness: #define COMPILE_TIME_ASSERT3(X, L) \ STATIC_ASSERT(X, static_assertion_at_line_##L) #define COMPILE_TIME_ASSERT2(X, L) COMPILE_TIME_ASSERT3(X, L) #define COMPILE_TIME_ASSERT(X) COMPILE_TIME_ASSERT2(X, __LINE__) #if defined(__GNUC__) || defined(__llvm__) || defined(__clang__) \ || defined(__INTEL_COMPILER) #define likely(x) __builtin_expect(!!(x), 1) #define unlikely(x) __builtin_expect(!!(x), 0) #else #define likely(x) (x) #define unlikely(x) (x) #endif #define UNUSED_PARAM(x) (void) x #ifdef UNUSED #elif defined(__GNUC__) #define UNUSED(x) UNUSED_##x __attribute__((unused)) #elif defined(__LCLINT__) #define UNUSED(x) /*@unused@*/ x #else #define UNUSED(x) x #endif #define ArrayCount(a) (sizeof((a)) / sizeof((a)[0])) #define IGNORE_LTZ(c) \ do \ { \ int __rc = (c); \ if (__rc < 0) \ { \ fprintf(stderr, \ "%s:%d:Function failed(%d:%d): %s\n", \ __FILE__, \ __LINE__, \ __rc, \ errno, \ #c); \ } \ } while (0) #define IGNORE_NZ(c) \ do \ { \ int __rc = (c); \ if (__rc != 0) \ { \ fprintf(stderr, \ "%s:%d:Function failed(%d:%d): %s\n", \ __FILE__, \ __LINE__, \ __rc, \ errno, \ #c); \ } \ } while (0) #define IGNORE_ZERO(c) \ do \ { \ if ((c) == 0) \ { \ fprintf(stderr, \ "%s:%d:Function failed(%d): %s\n", \ __FILE__, \ __LINE__, \ errno, \ #c); \ } \ } while (0) #if __STDC_VERSION__ >= 199901L #define DO_PRAGMA(x) _Pragma (#x) #else #define DO_PRAGMA(x) #endif #if defined(__clang_major__) && __clang_major__ >= 4 #define UNROLL_LOOP_N_TIME(n) DO_PRAGMA(clang loop unroll_count(n)) #elif defined(__GNUC__) && __GNUC__ >= 8 #define UNROLL_LOOP_N_TIME(n) DO_PRAGMA(GCC unroll n) #else #define UNROLL_LOOP_N_TIME(n) #endif #ifdef __cplusplus extern "C" { #endif static inline size_t ustrlen(const uint8_t * s1) { return strlen((const char *) s1); } #define destroy(var, fn) \ ({ \ if ((var) != NULL) \ { \ fn((__typeof__(var))(var)); \ \ (var) = NULL; \ } \ }) #ifdef __cplusplus } #endif #endif aircrack-ng-1.6/include/aircrack-ng/osdep/000077500000000000000000000000001361312141100204505ustar00rootroot00000000000000aircrack-ng-1.6/include/aircrack-ng/osdep/byteorder.h000066400000000000000000000347341361312141100226330ustar00rootroot00000000000000/* * Compatibility header * * Copyright (C) 2009-2020 Thomas d'Otreppe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. * If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. * If you * do not wish to do so, delete this exception statement from your * version. * If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifndef _AIRCRACK_NG_BYTEORDER_H_ #define _AIRCRACK_NG_BYTEORDER_H_ #include #define ___my_swab16(x) \ ((u_int16_t)((((u_int16_t)(x) & (u_int16_t) 0x00ffU) << 8u) \ | (((u_int16_t)(x) & (u_int16_t) 0xff00U) >> 8u))) #define ___my_swab32(x) \ ((u_int32_t)((((u_int32_t)(x) & (u_int32_t) 0x000000ffUL) << 24u) \ | (((u_int32_t)(x) & (u_int32_t) 0x0000ff00UL) << 8u) \ | (((u_int32_t)(x) & (u_int32_t) 0x00ff0000UL) >> 8u) \ | (((u_int32_t)(x) & (u_int32_t) 0xff000000UL) >> 24u))) #define ___my_swab64(x) \ ((u_int64_t)( \ (u_int64_t)(((u_int64_t)(x) & (u_int64_t) 0x00000000000000ffULL) \ << 56u) \ | (u_int64_t)(((u_int64_t)(x) & (u_int64_t) 0x000000000000ff00ULL) \ << 40u) \ | (u_int64_t)(((u_int64_t)(x) & (u_int64_t) 0x0000000000ff0000ULL) \ << 24u) \ | (u_int64_t)(((u_int64_t)(x) & (u_int64_t) 0x00000000ff000000ULL) \ << 8u) \ | (u_int64_t)(((u_int64_t)(x) & (u_int64_t) 0x000000ff00000000ULL) \ >> 8u) \ | (u_int64_t)(((u_int64_t)(x) & (u_int64_t) 0x0000ff0000000000ULL) \ >> 24u) \ | (u_int64_t)(((u_int64_t)(x) & (u_int64_t) 0x00ff000000000000ULL) \ >> 40u) \ | (u_int64_t)(((u_int64_t)(x) & (u_int64_t) 0xff00000000000000ULL) \ >> 56u))) /* * Linux */ #if defined(linux) || defined(Linux) || defined(__linux__) || defined(__linux) \ || defined(__gnu_linux__) #include #include #include #ifndef __int8_t_defined typedef uint64_t u_int64_t; typedef uint32_t u_int32_t; typedef uint16_t u_int16_t; typedef uint8_t u_int8_t; #endif #endif /* * Cygwin */ #if defined(__CYGWIN32__) || defined(CYGWIN) #include #include #define __be64_to_cpu(x) ___my_swab64(x) #define __be32_to_cpu(x) ___my_swab32(x) #define __be16_to_cpu(x) ___my_swab16(x) #define __cpu_to_be64(x) ___my_swab64(x) #define __cpu_to_be32(x) ___my_swab32(x) #define __cpu_to_be16(x) ___my_swab16(x) #define __le64_to_cpu(x) (x) #define __le32_to_cpu(x) (x) #define __le16_to_cpu(x) (x) #define __cpu_to_le64(x) (x) #define __cpu_to_le32(x) (x) #define __cpu_to_le16(x) (x) #define AIRCRACK_NG_BYTE_ORDER_DEFINED #endif /* * Windows (DDK) */ #if defined(__WIN__) #include #define __be64_to_cpu(x) ___my_swab64(x) #define __be32_to_cpu(x) ___my_swab32(x) #define __be16_to_cpu(x) ___my_swab16(x) #define __cpu_to_be64(x) ___my_swab64(x) #define __cpu_to_be32(x) ___my_swab32(x) #define __cpu_to_be16(x) ___my_swab16(x) #define __le64_to_cpu(x) (x) #define __le32_to_cpu(x) (x) #define __le16_to_cpu(x) (x) #define __cpu_to_le64(x) (x) #define __cpu_to_le32(x) (x) #define __cpu_to_le16(x) (x) #define AIRCRACK_NG_BYTE_ORDER_DEFINED #endif /* * MAC (Darwin) */ #if defined(__APPLE_CC__) #if defined(__x86_64__) && defined(__APPLE__) #include #define __swab64(x) (unsigned long long) OSSwapInt64((uint64_t) x) #define __swab32(x) (unsigned long) OSSwapInt32((uint32_t) x) #define __swab16(x) (unsigned short) OSSwapInt16((uint16_t) x) #define __be64_to_cpu(x) (unsigned long long) OSSwapBigToHostInt64((uint64_t) x) #define __be32_to_cpu(x) (unsigned long) OSSwapBigToHostInt32((uint32_t) x) #define __be16_to_cpu(x) (unsigned short) OSSwapBigToHostInt16((uint16_t) x) #define __le64_to_cpu(x) \ (unsigned long long) OSSwapLittleToHostInt64((uint64_t) x) #define __le32_to_cpu(x) (unsigned long) OSSwapLittleToHostInt32((uint32_t) x) #define __le16_to_cpu(x) (unsigned short) OSSwapLittleToHostInt16((uint16_t) x) #define __cpu_to_be64(x) (unsigned long long) OSSwapHostToBigInt64((uint64_t) x) #define __cpu_to_be32(x) (unsigned long) OSSwapHostToBigInt32((uint32_t) x) #define __cpu_to_be16(x) (unsigned short) OSSwapHostToBigInt16((uint16_t) x) #define __cpu_to_le64(x) \ (unsigned long long) OSSwapHostToLittleInt64((uint64_t) x) #define __cpu_to_le32(x) (unsigned long) OSSwapHostToLittleInt32((uint32_t) x) #define __cpu_to_le16(x) (unsigned short) OSSwapHostToLittleInt16((uint16_t) x) #else #include #define __swab64(x) NXSwapLongLong(x) #define __swab32(x) NXSwapLong(x) #define __swab16(x) NXSwapShort(x) #define __be64_to_cpu(x) NXSwapBigLongLongToHost(x) #define __be32_to_cpu(x) NXSwapBigLongToHost(x) #define __be16_to_cpu(x) NXSwapBigShortToHost(x) #define __le64_to_cpu(x) NXSwapLittleLongLongToHost(x) #define __le32_to_cpu(x) NXSwapLittleLongToHost(x) #define __le16_to_cpu(x) NXSwapLittleShortToHost(x) #define __cpu_to_be64(x) NXSwapHostLongLongToBig(x) #define __cpu_to_be32(x) NXSwapHostLongToBig(x) #define __cpu_to_be16(x) NXSwapHostShortToBig(x) #define __cpu_to_le64(x) NXSwapHostLongLongToLittle(x) #define __cpu_to_le32(x) NXSwapHostLongToLittle(x) #define __cpu_to_le16(x) NXSwapHostShortToLittle(x) #endif #define __LITTLE_ENDIAN 1234 #define __BIG_ENDIAN 4321 #define __PDP_ENDIAN 3412 #define __BYTE_ORDER __BIG_ENDIAN #define AIRCRACK_NG_BYTE_ORDER_DEFINED #endif /* * Solaris * ------- */ #if defined(__SVR4) && defined(__sun__) #include #include #include typedef uint64_t u_int64_t; typedef uint32_t u_int32_t; typedef uint16_t u_int16_t; typedef uint8_t u_int8_t; #if defined(__sparc__) #define __be64_to_cpu(x) (x) #define __be32_to_cpu(x) (x) #define __be16_to_cpu(x) (x) #define __cpu_to_be64(x) (x) #define __cpu_to_be32(x) (x) #define __cpu_to_be16(x) (x) #define __le64_to_cpu(x) ___my_swab64(x) #define __le32_to_cpu(x) ___my_swab32(x) #define __le16_to_cpu(x) ___my_swab16(x) #define __cpu_to_le64(x) ___my_swab64(x) #define __cpu_to_le32(x) ___my_swab32(x) #define __cpu_to_le16(x) ___my_swab16(x) #define AIRCRACK_NG_BYTE_ORDER_DEFINED #define BIG_ENDIAN 1 #define BYTE_ORDER BIG_ENDIAN #else #define AIRCRACK_NG_BYTE_ORDER 1 #define LITTLE_ENDIAN 1 #endif #endif /* * Custom stuff */ #if defined(__MACH__) && !defined(__APPLE_CC__) && !defined(__GNU__) #include #define __cpu_to_be64(x) = OSSwapHostToBigInt64(x) #define __cpu_to_be32(x) = OSSwapHostToBigInt32(x) #define AIRCRACK_NG_BYTE_ORDER_DEFINED #endif // FreeBSD #if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) || defined(__MidnightBSD__) || defined(__NetBSD__) #undef ushort #undef uint #include #endif // XXX: Is there anything to include on OpenBSD/NetBSD/DragonFlyBSD/...? // XXX: Mac: Check // http://www.opensource.apple.com/source/CF/CF-476.18/CFByteOrder.h // http://developer.apple.com/DOCUMENTATION/CoreFoundation/Reference/CFByteOrderUtils/Reference/reference.html // Write to apple to ask what should be used. #if defined(LITTLE_ENDIAN) #define AIRCRACK_NG_LITTLE_ENDIAN LITTLE_ENDIAN #elif defined(__LITTLE_ENDIAN) #define AIRCRACK_NG_LITTLE_ENDIAN __LITTLE_ENDIAN #elif defined(_LITTLE_ENDIAN) #define AIRCRACK_NG_LITTLE_ENDIAN _LITTLE_ENDIAN #endif #if defined(BIG_ENDIAN) #define AIRCRACK_NG_BIG_ENDIAN BIG_ENDIAN #elif defined(__BIG_ENDIAN) #define AIRCRACK_NG_BIG_ENDIAN __BIG_ENDIAN #elif defined(_BIG_ENDIAN) #define AIRCRACK_NG_BIG_ENDIAN _BIG_ENDIAN #endif #if !defined(AIRCRACK_NG_LITTLE_ENDIAN) && !defined(AIRCRACK_NG_BIG_ENDIAN) #error Impossible to determine endianness (Little or Big endian), please contact the author. #endif #if defined(BYTE_ORDER) #if (BYTE_ORDER == AIRCRACK_NG_LITTLE_ENDIAN) #define AIRCRACK_NG_BYTE_ORDER AIRCRACK_NG_LITTLE_ENDIAN #elif (BYTE_ORDER == AIRCRACK_NG_BIG_ENDIAN) #define AIRCRACK_NG_BYTE_ORDER AIRCRACK_NG_BIG_ENDIAN #endif #elif defined(__BYTE_ORDER) #if (__BYTE_ORDER == AIRCRACK_NG_LITTLE_ENDIAN) #define AIRCRACK_NG_BYTE_ORDER AIRCRACK_NG_LITTLE_ENDIAN #elif (__BYTE_ORDER == AIRCRACK_NG_BIG_ENDIAN) #define AIRCRACK_NG_BYTE_ORDER AIRCRACK_NG_BIG_ENDIAN #endif #elif defined(_BYTE_ORDER) #if (_BYTE_ORDER == AIRCRACK_NG_LITTLE_ENDIAN) #define AIRCRACK_NG_BYTE_ORDER AIRCRACK_NG_LITTLE_ENDIAN #elif (_BYTE_ORDER == AIRCRACK_NG_BIG_ENDIAN) #define AIRCRACK_NG_BYTE_ORDER AIRCRACK_NG_BIG_ENDIAN #endif #endif #ifndef AIRCRACK_NG_BYTE_ORDER #error Impossible to determine endianness (Little or Big endian), please contact the author. #endif #if (AIRCRACK_NG_BYTE_ORDER == AIRCRACK_NG_LITTLE_ENDIAN) #ifndef AIRCRACK_NG_BYTE_ORDER_DEFINED #define __be64_to_cpu(x) ___my_swab64(x) #define __be32_to_cpu(x) ___my_swab32(x) #define __be16_to_cpu(x) ___my_swab16(x) #define __cpu_to_be64(x) ___my_swab64(x) #define __cpu_to_be32(x) ___my_swab32(x) #define __cpu_to_be16(x) ___my_swab16(x) #define __le64_to_cpu(x) (x) #define __le32_to_cpu(x) (x) #define __le16_to_cpu(x) (x) #define __cpu_to_le64(x) (x) #define __cpu_to_le32(x) (x) #define __cpu_to_le16(x) (x) #endif #ifndef htobe16 #define htobe16 ___my_swab16 #endif #ifndef htobe32 #define htobe32 ___my_swab32 #endif #ifndef htobe64 #define htobe64 ___my_swab64 #endif #ifndef betoh16 #define betoh16 ___my_swab16 #endif #ifndef betoh32 #define betoh32 ___my_swab32 #endif #ifndef betoh64 #define betoh64 ___my_swab64 #endif #ifndef htole16 #define htole16(x) (x) #endif #ifndef htole32 #define htole32(x) (x) #endif #ifndef htole64 #define htole64(x) (x) #endif #ifndef letoh16 #define letoh16(x) (x) #endif #ifndef letoh32 #define letoh32(x) (x) #endif #ifndef letoh64 #define letoh64(x) (x) #endif #endif #if (AIRCRACK_NG_BYTE_ORDER == AIRCRACK_NG_BIG_ENDIAN) #ifndef AIRCRACK_NG_BYTE_ORDER_DEFINED #define __be64_to_cpu(x) (x) #define __be32_to_cpu(x) (x) #define __be16_to_cpu(x) (x) #define __cpu_to_be64(x) (x) #define __cpu_to_be32(x) (x) #define __cpu_to_be16(x) (x) #define __le64_to_cpu(x) ___my_swab64(x) #define __le32_to_cpu(x) ___my_swab32(x) #define __le16_to_cpu(x) ___my_swab16(x) #define __cpu_to_le64(x) ___my_swab64(x) #define __cpu_to_le32(x) ___my_swab32(x) #define __cpu_to_le16(x) ___my_swab16(x) #endif #ifndef htobe16 #define htobe16(x) (x) #endif #ifndef htobe32 #define htobe32(x) (x) #endif #ifndef htobe64 #define htobe64(x) (x) #endif #ifndef betoh16 #define betoh16(x) (x) #endif #ifndef betoh32 #define betoh32(x) (x) #endif #ifndef betoh64 #define betoh64(x) (x) #endif #ifndef htole16 #define htole16 ___my_swab16 #endif #ifndef htole32 #define htole32 ___my_swab32 #endif #ifndef htole64 #define htole64 ___my_swab64 #endif #ifndef letoh16 #define letoh16 ___my_swab16 #endif #ifndef letoh32 #define letoh32 ___my_swab32 #endif #ifndef letoh64 #define letoh64 ___my_swab64 #endif #endif // Common defines #define cpu_to_le64 __cpu_to_le64 #define le64_to_cpu __le64_to_cpu #define cpu_to_le32 __cpu_to_le32 #ifndef le32_to_cpu #define le32_to_cpu __le32_to_cpu #endif #define cpu_to_le16 __cpu_to_le16 #ifndef le16_to_cpu #define le16_to_cpu __le16_to_cpu #endif #define cpu_to_be64 __cpu_to_be64 #define be64_to_cpu __be64_to_cpu #define cpu_to_be32 __cpu_to_be32 #define be32_to_cpu __be32_to_cpu #define cpu_to_be16 __cpu_to_be16 #define be16_to_cpu __be16_to_cpu #ifndef le16toh #define le16toh le16_to_cpu #endif #ifndef be16toh #define be16toh be16_to_cpu #endif #ifndef le32toh #define le32toh le32_to_cpu #endif #ifndef be32toh #define be32toh be32_to_cpu #endif #ifndef htons #define htons cpu_to_be16 #endif #ifndef htonl #define htonl cpu_to_be32 #endif #ifndef ntohs #define ntohs be16_to_cpu #endif #ifndef ntohl #define ntohl be32_to_cpu #endif /* Loads and stores. These avoid undefined behavior due to unaligned memory * accesses, via memcpy. */ inline static uint16_t load16(uint8_t * b) { uint16_t x; memcpy(&x, b, 2); return x; } inline static uint32_t load32(uint8_t * b) { uint32_t x; memcpy(&x, b, 4); return x; } inline static uint64_t load64(uint8_t * b) { uint64_t x; memcpy(&x, b, 8); return x; } inline static void store16(uint8_t * b, uint16_t i) { memcpy(b, &i, 2); } inline static void store32(uint8_t * b, uint32_t i) { memcpy(b, &i, 4); } inline static void store64(uint8_t * b, uint64_t i) { memcpy(b, &i, 8); } #define load16_le(b) (__le16_to_cpu(load16(b))) #define store16_le(b, i) (store16(b, __cpu_to_le16(i))) #define load16_be(b) (__be16_to_cpu(load16(b))) #define store16_be(b, i) (store16(b, __cpu_to_be16(i))) #define load32_le(b) (__le32_to_cpu(load32(b))) #define store32_le(b, i) (store32(b, __cpu_to_le32(i))) #define load32_be(b) (__be32_to_cpu(load32(b))) #define store32_be(b, i) (store32(b, __cpu_to_be32(i))) #define load64_le(b) (__le64_to_cpu(load64(b))) #define store64_le(b, i) (store64(b, __cpu_to_le64(i))) #define load64_be(b) (__be64_to_cpu(load64(b))) #define store64_be(b, i) (store64(b, __cpu_to_be64(i))) #endif aircrack-ng-1.6/include/aircrack-ng/osdep/channel.h000066400000000000000000000020051361312141100222260ustar00rootroot00000000000000/* * OS dependent APIs for Linux * * Copyright (C) 2018-2020 Thomas d'Otreppe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ #ifndef OSDEP_CHANNELS_H #define OSDEP_CHANNELS_H #define CHANNEL_NO_HT 0 #define CHANNEL_HT20 20 #define CHANNEL_HT40_PLUS 39 #define CHANNEL_HT40_MINUS 41 #endif // OSDEP_CHANNELS_H aircrack-ng-1.6/include/aircrack-ng/osdep/common.h000066400000000000000000000045301361312141100221130ustar00rootroot00000000000000/* * Copyright (c) 2010-2020 Thomas d'Otreppe * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * is provided AS IS, WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and * NON-INFRINGEMENT. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, * MA 02110-1301, USA. * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifndef _OSDEP_COMMON_H_ #define _OSDEP_COMMON_H_ #if defined(_MSC_VER) // Microsoft #define EXPORT __declspec(dllexport) #define IMPORT __declspec(dllimport) #elif defined(__GNUC__) || defined(__llvm__) || defined(__clang__) \ || defined(__INTEL_COMPILER) #define EXPORT __attribute__((visibility("default"))) #define IMPORT #else // do nothing and hope for the best? #define EXPORT #define IMPORT #pragma warning Unknown dynamic link import / export semantics. #endif IMPORT int getFrequencyFromChannel(int channel); IMPORT int getChannelFromFrequency(int frequency); /* // For later use, because aircrack-ng doesn't compile with MS compilers #if defined(WIN32) || defined(__WIN__) #define ftruncate(a, b) _chsize(a,b) #endif */ #define HIGHEST_CHANNEL 220 #define LOWEST_CHANNEL -16 #endif aircrack-ng-1.6/include/aircrack-ng/osdep/network.h000066400000000000000000000014621361312141100223150ustar00rootroot00000000000000/* * Copyright (c) 2007, 2008, Andrea Bittau * * Networking structures. * */ #ifndef __AIRCRACK_NG_OSDEP_NETWORK_H__ #define __AIRCRACK_NG_OSDEP_NETWORK_H__ #include #include #include enum { NET_RC = 1, NET_GET_CHAN, NET_SET_CHAN, NET_WRITE, NET_PACKET, /* 5 */ NET_GET_MAC, NET_MAC, NET_GET_MONITOR, NET_GET_RATE, NET_SET_RATE, }; #define HIGHEST_NET_COMMAND NET_SET_RATE struct net_hdr { uint8_t nh_type; uint32_t nh_len; uint8_t nh_data[0]; } __packed; IMPORT struct wif * net_open(char * iface); IMPORT int net_send(int s, int command, void * arg, int len); IMPORT int net_read_exact(int s, void * arg, int len); IMPORT int net_get(int s, void * arg, int * len); #endif /* __AIRCRACK_NG_OSEDEP_NETWORK_H__ */ aircrack-ng-1.6/include/aircrack-ng/osdep/osdep.h000066400000000000000000000153611361312141100217410ustar00rootroot00000000000000/* * Copyright (c) 2007, 2008, Andrea Bittau * All OS dependent crap should go here. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * is provided AS IS, WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and * NON-INFRINGEMENT. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, * MA 02110-1301, USA. * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifndef __AIRCRACK_NG_OSEDEP_H__ #define __AIRCRACK_NG_OSEDEP_H__ #include #include #include #include #include #include #if defined(__APPLE_CC__) && defined(_XCODE) #include #undef LINKTYPE_RADIOTAP_HDR #define LINKTYPE_RADIOTAP_HDR DLT_IEEE802_11_RADIO #undef LINKTYPE_IEEE802_11 #define LINKTYPE_IEEE802_11 DLT_IEEE802_11 #undef LINKTYPE_PRISM_HEADER #define LINKTYPE_PRISM_HEADER DLT_PRISM_HEADER #undef LINKTYPE_ETHERNET #define LINKTYPE_ETHERNET DLT_ERF_ETH #undef LINKTYPE_PPI_HDR #define LINKTYPE_PPI_HDR DLT_PPI #undef TCPDUMP_MAGIC #define TCPDUMP_MAGIC 0xa1b2c3d4 #endif /* For all structures, when adding new fields, always append them to the end. * This way legacy binary code does not need to be recompiled. This is * particularly useful for DLLs. -sorbo */ struct tx_info { uint32_t ti_rate; }; struct rx_info { uint64_t ri_mactime; int32_t ri_power; int32_t ri_noise; uint32_t ri_channel; uint32_t ri_freq; uint32_t ri_rate; uint32_t ri_antenna; } __packed; /* Normal code should not access this directly. Only osdep. * This structure represents a single interface. It should be created with * wi_open and destroyed with wi_close. */ #define MAX_IFACE_NAME 64 struct wif { int (*wi_read)(struct wif * wi, struct timespec * ts, int * dlt, unsigned char * h80211, int len, struct rx_info * ri); int (*wi_write)(struct wif * wi, struct timespec * ts, int dlt, unsigned char * h80211, int len, struct tx_info * ti); int (*wi_set_ht_channel)(struct wif * wi, int chan, unsigned int htval); int (*wi_set_channel)(struct wif * wi, int chan); int (*wi_get_channel)(struct wif * wi); int (*wi_set_freq)(struct wif * wi, int freq); int (*wi_get_freq)(struct wif * wi); void (*wi_close)(struct wif * wi); int (*wi_fd)(struct wif * wi); int (*wi_get_mac)(struct wif * wi, unsigned char * mac); int (*wi_set_mac)(struct wif * wi, unsigned char * mac); int (*wi_set_rate)(struct wif * wi, int rate); int (*wi_get_rate)(struct wif * wi); int (*wi_set_mtu)(struct wif * wi, int mtu); int (*wi_get_mtu)(struct wif * wi); int (*wi_get_monitor)(struct wif * wi); void * wi_priv; char wi_interface[MAX_IFACE_NAME]; }; /* Routines to be used by client code */ IMPORT struct wif * wi_open(char * iface); IMPORT int wi_read(struct wif * wi, struct timespec * ts, int * dlt, unsigned char * h80211, int len, struct rx_info * ri); IMPORT int wi_write(struct wif * wi, struct timespec * ts, int dlt, unsigned char * h80211, int len, struct tx_info * ti); IMPORT int wi_set_channel(struct wif * wi, int chan); IMPORT int wi_set_ht_channel(struct wif * wi, int chan, unsigned int htval); IMPORT int wi_get_channel(struct wif * wi); IMPORT int wi_set_freq(struct wif * wi, int freq); IMPORT int wi_get_freq(struct wif * wi); IMPORT void wi_close(struct wif * wi); IMPORT char * wi_get_ifname(struct wif * wi); IMPORT int wi_get_mac(struct wif * wi, unsigned char * mac); IMPORT int wi_set_mac(struct wif * wi, unsigned char * mac); IMPORT int wi_get_rate(struct wif * wi); IMPORT int wi_set_rate(struct wif * wi, int rate); IMPORT int wi_get_monitor(struct wif * wi); IMPORT int wi_get_mtu(struct wif * wi); IMPORT int wi_set_mtu(struct wif * wi, int mtu); /* wi_open_osdep should determine the type of card and setup the wif structure * appropriately. There is one per OS. Called by wi_open. */ extern struct wif * wi_open_osdep(char * iface); /* This will return the FD used for reading. This is required for using select * on it. */ IMPORT int wi_fd(struct wif * wi); /* Helper routines for osdep code. */ extern struct wif * wi_alloc(int sz); extern void * wi_priv(struct wif * wi); /* Client code can use this to determine the battery state. One per OS. */ IMPORT int get_battery_state(void); /* Client code can create a tap interface */ /* XXX we can unify the tap & wi stuff in the future, but for now, lets keep * them separate until we learn something. */ struct tif { int (*ti_read)(struct tif * ti, void * buf, int len); int (*ti_write)(struct tif * ti, void * buf, int len); int (*ti_fd)(struct tif * ti); char * (*ti_name)(struct tif * ti); int (*ti_set_mtu)(struct tif * ti, int mtu); int (*ti_get_mtu)(struct tif * ti); int (*ti_set_ip)(struct tif * ti, struct in_addr * ip); int (*ti_set_mac)(struct tif * ti, unsigned char * mac); void (*ti_close)(struct tif * ti); void * ti_priv; }; /* one per OS */ IMPORT struct tif * ti_open(char * iface); /* osdep routines */ extern struct tif * ti_alloc(int sz); extern void * ti_priv(struct tif * ti); /* client routines */ IMPORT char * ti_name(struct tif * ti); IMPORT int ti_set_mtu(struct tif * ti, int mtu); IMPORT int ti_get_mtu(struct tif * ti); IMPORT void ti_close(struct tif * ti); IMPORT int ti_fd(struct tif * ti); IMPORT int ti_read(struct tif * ti, void * buf, int len); IMPORT int ti_write(struct tif * ti, void * buf, int len); IMPORT int ti_set_mac(struct tif * ti, unsigned char * mac); IMPORT int ti_set_ip(struct tif * ti, struct in_addr * ip); #endif /* __AIRCRACK_NG_OSEDEP_H__ */ aircrack-ng-1.6/include/aircrack-ng/osdep/packed.h000066400000000000000000000034751361312141100220610ustar00rootroot00000000000000/* * Pack structures * * Copyright (c) 2007, 2008, Andrea Bittau * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * is provided AS IS, WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and * NON-INFRINGEMENT. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, * MA 02110-1301, USA. * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifndef __AIRCRACK_NG_OSDEP_PACKED_H__ #define __AIRCRACK_NG_OSDEP_PACKED_H__ #ifndef __packed #define __packed __attribute__((__packed__)) #endif /* __packed */ #ifndef __aligned #define __aligned(n) #endif #endif /* __AIRCRACK_NG_OSEDEP_PACKED_H__ */ aircrack-ng-1.6/include/aircrack-ng/ptw/000077500000000000000000000000001361312141100201505ustar00rootroot00000000000000aircrack-ng-1.6/include/aircrack-ng/ptw/aircrack-ptw-lib.h000066400000000000000000000074011361312141100234560ustar00rootroot00000000000000/* * Copyright (c) 2007-2009 Erik Tews, Andrei Pychkine and Ralf-Philipp * Weinmann. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. * If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. * If you * do not wish to do so, delete this exception statement from your * version. * If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifndef _AIRCRACK_PTW_H_ #define _AIRCRACK_PTW_H_ #include // Number of bytes we use for our table of seen IVs, this is (2^24)/8 #define PTW_IVTABLELEN 2097152 // How many sessions do we use to check if a guessed key is correct // 10 seems to be a reasonable choice // Its now the number of sessions for selecting 10 at a random position #define PTW_CONTROLSESSIONS 10000 // The maximum possible length of the main key, 13 is the maximum for a 104 bit // key #define PTW_KEYHSBYTES 29 // How long the IV is, 3 is the default value for WEP #define PTW_IVBYTES 3 // How many bytes of a keystream we collect, 16 are needed for a 104 bit key #define PTW_KSBYTES 32 // The MAGIC VALUE!! #define PTW_n 256 // distinguish klein and ptw #define NO_KLEIN 0x01 #define NO_PTW 0x02 // We use this to keep track of the outputs of A_i typedef struct { // How often the value b appeared as an output of A_i int votes; uint8_t b; } PTW_tableentry; // A recovered session typedef struct { // The IV used in this session uint8_t iv[PTW_IVBYTES]; // The keystream used in this session uint8_t keystream[PTW_KSBYTES]; // Weight for this session int weight; } PTW_session; typedef int (*rc4test_func)(uint8_t * key, int keylen, uint8_t * iv, uint8_t * keystream); // The state of an attack // You should usually never modify these values manually typedef struct { // How many unique packets or IVs have been collected int packets_collected; // Table to check for duplicate IVs uint8_t seen_iv[PTW_IVTABLELEN]; // How many sessions for checking a guessed key have been collected int sessions_collected; // The actual recovered sessions PTW_session sessions[PTW_CONTROLSESSIONS]; // The table with votes for the keybytesums PTW_tableentry table[PTW_KEYHSBYTES][PTW_n]; // Sessions for the original klein attack PTW_session * allsessions; int allsessions_size; // rc4test function, optimized if available rc4test_func rc4test; } PTW_attackstate; PTW_attackstate * PTW_newattackstate(void); void PTW_freeattackstate(PTW_attackstate *); int PTW_addsession(PTW_attackstate *, uint8_t *, uint8_t *, int *, int); int PTW_computeKey( PTW_attackstate *, uint8_t *, int, int, int *, int[][PTW_n], int attacks); #endif aircrack-ng-1.6/include/aircrack-ng/support/000077500000000000000000000000001361312141100210525ustar00rootroot00000000000000aircrack-ng-1.6/include/aircrack-ng/support/common.h000066400000000000000000000234441361312141100225220ustar00rootroot00000000000000/* * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * is provided AS IS, WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and * NON-INFRINGEMENT. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, * MA 02110-1301, USA. * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifndef _COMMON_H_ #define _COMMON_H_ #include #include #include #include #include #include #include #if defined(__CYGWIN32__) && !defined(__CYGWIN64__) int fseeko64(FILE * fp, int64_t offset, int whence); int64_t ftello64(FILE * fp); #undef fseek #define fseek fseeko64 #undef ftello #define ftello ftello64 #endif #if defined(__FreeBSD__) || defined(__OpenBSD__) #undef rand #define rand lrand48 #undef srand #define srand srand48 #endif #define SWAP(x, y) \ { \ unsigned char tmp = x; \ x = y; \ y = tmp; \ } #define SWAP32(x) \ x = ((((x) >> 24u) & 0x000000FFu) | (((x) >> 8u) & 0x0000FF00u) \ | (((x) << 8u) & 0x00FF0000u) \ | (((x) << 24u) & 0xFF000000u)) #define PCT \ { \ struct tm * lt; \ time_t tc = time(NULL); \ lt = localtime(&tc); \ printf("%02d:%02d:%02d ", lt->tm_hour, lt->tm_min, lt->tm_sec); \ } #ifndef MAX #define MAX(x, y) ((x) > (y) ? (x) : (y)) #endif #ifndef MIN #define MIN(x, y) ((x) > (y) ? (y) : (x)) #endif #ifndef ABS #define ABS(a) ((a) >= 0 ? (a) : (-(a))) #endif #ifdef __cplusplus extern "C" { #endif static const unsigned char ZERO[33] = "\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00"; void calctime(time_t t, float calc); /// Retrieves the working directory. char * get_current_working_directory(void); int is_string_number(const char * str); int get_ram_size(void); char * getVersion(const char * progname, const unsigned int maj, const unsigned int min, const unsigned int submin, const char * rev, const unsigned int beta, const unsigned int rc); /// Returns the number of CPU/cores available and online. int get_nb_cpus(void); int maccmp(unsigned char * mac1, unsigned char * mac2); static inline void mac2str(char * str, uint8_t * m, size_t macsize) { REQUIRE(str != NULL); REQUIRE(m != NULL); snprintf(str, macsize, "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", m[0], m[1], m[2], m[3], m[4], m[5]); } #define MAC_ADDRESS_STRING_LEN 18 /// Converts a mac address in a human-readable format. static inline char * mac2string(unsigned char * mac_address) { REQUIRE(mac_address != NULL); char * mac_string = (char *) malloc(MAC_ADDRESS_STRING_LEN); ALLEGE(mac_string != NULL); mac2str(mac_string, mac_address, MAC_ADDRESS_STRING_LEN); return (mac_string); } static inline int str2mac(uint8_t * mac, const char * str) { REQUIRE(mac != NULL); REQUIRE(str != NULL); unsigned int macf[6]; if (sscanf(str, "%x:%x:%x:%x:%x:%x", &macf[0], &macf[1], &macf[2], &macf[3], &macf[4], &macf[5]) != 6) return (-1); for (int i = 0; i < 6; i++) *mac++ = (uint8_t) macf[i]; return (0); } int hexCharToInt(unsigned char c); int hexStringToArray(char * in, int in_length, unsigned char * out, int out_length); /// Return the mac address bytes (or null if it's not a mac address) int getmac(const char * macAddress, const int strict, unsigned char * mac); /// Read a line of characters inputted by the user int readLine(char line[], int maxlength); int hexToInt(char s[], int len); int string_has_suffix(const char * str, const char * suf); // Returns 1 if the current process is running in the background, 0 otherwise int is_background(void); static inline int time_diff(struct timeval * past, struct timeval * now) { REQUIRE(past != NULL); REQUIRE(now != NULL); time_t p = 0, n = 0; if (now->tv_sec > past->tv_sec) n = (now->tv_sec - past->tv_sec) * 1000 * 1000; else p = (past->tv_sec - now->tv_sec) * 1000 * 1000; n += now->tv_usec; p += past->tv_usec; return (int) (n - p); } static inline int elapsed_time_diff(struct timeval * past, struct timeval * now) { REQUIRE(past != NULL); REQUIRE(now != NULL); time_t el = now->tv_sec - past->tv_sec; if (el == 0) { el = now->tv_usec - past->tv_usec; } else { el = (el - 1) * 1000 * 1000; el += 1000 * 1000 - past->tv_usec; el += now->tv_usec; } if (el < 0) return (666 * 1000 * 1000); return (int) (el); } #define msec_diff(past, now) (time_diff((past), (now)) / 1000) /// Return \a str with all leading whitespace removed. static inline void ltrim(char * str) { REQUIRE(str != NULL); size_t i; size_t begin = 0u; size_t end = strlen(str) - 1u; while (isspace((int) str[begin])) begin++; // Shift all characters back to the start of the string array. for (i = begin; i <= end; i++) str[i - begin] = str[i]; // Ensure the string is null terminated. str[i - begin] = '\0'; } /// Return \a str with all trailing whitespace removed. static inline void rtrim(char * str) { REQUIRE(str != NULL); size_t end = strlen(str) - 1u; while ((end != 0) && isspace((int) str[end])) end--; // Ensure the string is null terminated. str[end + 1] = '\0'; } /// Return \a str with all leading and trailing whitespace removed. static inline void trim(char * str) { REQUIRE(str != NULL); ltrim(str); rtrim(str); } /* See if a string contains a character in the first "n" bytes. * * Returns a pointer to the first occurrence of the character, or NULL * if the character is not present in the string. * * Breaks the str* naming convention to avoid a name collision if we're * compiling on a system that has strnchr() */ static inline char * strchr_n(char * str, int c, size_t n) { size_t count = 0; if (str == NULL || n == 0) { return (NULL); } while (*str != c && *str != '\0' && count < n) { str++; count++; } return (*str == c) ? (str) : (NULL); } /* Remove a newline-terminated block of data from a buffer, replacing * the newline with a '\0'. * * Returns the number of characters left in the buffer, or -1 if the * buffer did not contain a newline. */ static inline ssize_t get_line_from_buffer(char * buffer, size_t size, char * line) { char * cursor = strchr_n(buffer, 0x0A, size); if (NULL != cursor) { *cursor = '\0'; cursor++; strcpy(line, buffer); memmove(buffer, cursor, size - (strlen(line) + 1)); return (size - (strlen(line) + 1)); } return (-1); } int station_compare(const void * a, const void * b); /// Initialize standard C random number generator. static inline void rand_init(void) { srand(time(NULL)); // NOLINT(cert-msc32-c,cert-msc51-cpp) } /// Initialize standard C random number generator with specific seed. static inline void rand_init_with(int seed) { srand(seed); // NOLINT(cert-msc32-c,cert-msc51-cpp) } /// Acquire a random unsigned char, from the standard C random number generator. static inline uint8_t rand_u8(void) { // coverity[dont_call] return (uint8_t)( rand() & 0xFFU); // NOLINT(cert-msc30-c,cert-msc50-cpp,hicpp-signed-bitwise) } /// Acquire a random unsigned short, from the standard C random number generator. static inline uint16_t rand_u16(void) { // coverity[dont_call] return (uint16_t)( rand() & 0xFFFFU); // NOLINT(cert-msc30-c,cert-msc50-cpp,hicpp-signed-bitwise) } /// Acquire a random unsigned long, from the standard C random number generator. static inline uint32_t rand_u32(void) { // coverity[dont_call] return (uint32_t)( rand() & 0xFFFFFFFFUL); // NOLINT(cert-msc30-c,cert-msc50-cpp,hicpp-signed-bitwise) } /// Acquire a random float, from the standard C random number generator. static inline float rand_f32(void) { // coverity[dont_call] return ((float) rand() / (float) RAND_MAX); } /// Saturated add for unsigned, 32-bit integers. static inline uint32_t adds_u32(uint32_t a, uint32_t b) { uint32_t c = a + b; if (unlikely(c < a)) /* can only happen due to overflow */ c = -1; return (c); } #ifdef __cplusplus }; #endif #endif aircrack-ng-1.6/include/aircrack-ng/support/communications.h000066400000000000000000000207751361312141100242660ustar00rootroot00000000000000/* * Copyright (C) 2006-2020 Thomas d'Otreppe * Copyright (C) 2006-2009 Martin Beck * Copyright (C) 2018-2020 Joseph Benden * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. * If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. * If you * do not wish to do so, delete this exception statement from your * version. * If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifndef AIRCRACK_NG_COMMUNICATIONS_H #define AIRCRACK_NG_COMMUNICATIONS_H #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define RATE_1M 1000000 #define RATE_2M 2000000 #define RATE_5_5M 5500000 #define RATE_11M 11000000 #define RATE_6M 6000000 #define RATE_9M 9000000 #define RATE_12M 12000000 #define RATE_18M 18000000 #define RATE_24M 24000000 #define RATE_36M 36000000 #define RATE_48M 48000000 #define RATE_54M 54000000 static const int bitrates[] = {RATE_1M, RATE_2M, RATE_5_5M, RATE_6M, RATE_9M, RATE_11M, RATE_12M, RATE_18M, RATE_24M, RATE_36M, RATE_48M, RATE_54M}; struct communication_options { uint8_t f_bssid[6]; uint8_t f_dmac[6]; uint8_t f_smac[6]; uint8_t f_netmask[6]; int f_minlen; int f_maxlen; int f_type; int f_subtype; int f_tods; int f_fromds; int f_iswep; uint8_t deauth_rc; int r_nbpps; unsigned int r_fctrl; uint8_t r_bssid[6]; uint8_t r_dmac[6]; uint8_t r_smac[6]; uint8_t r_trans[6]; uint8_t r_dip[4]; uint8_t r_sip[4]; char r_essid[33]; int r_fromdsinj; char r_smac_set; char ip_out[16]; // 16 for 15 chars + \x00 char ip_in[16]; int port_out; int port_in; char * iface_out; char * s_face; char * s_file; uint8_t * prga; size_t prgalen; int a_mode; int a_count; int a_delay; int f_retry; int ringbuffer; int ghost; int delay; int npackets; int fast; int bittest; int nodetect; int ignore_negative_one; int rtc; int reassoc; int crypt; uint8_t wepkey[64]; size_t weplen; int f_index; /* outfiles index */ FILE * f_txt; /* output csv file */ FILE * f_kis; /* output kismet csv file */ FILE * f_kis_xml; /* output kismet netxml file */ FILE * f_gps; /* output gps file */ FILE * f_cap; /* output cap file */ FILE * f_ivs; /* output ivs file */ FILE * f_xor; /* output prga file */ FILE * f_logcsv; /* output rolling AP/GPS csv log */ char * f_cap_name; char * prefix; int output_format_pcap; int output_format_csv; int output_format_kismet_csv; int output_format_kismet_netxml; int output_format_log_csv; int usegpsd; /* do we use GPSd? */ int record_data; /* do we record data? */ unsigned char sharedkey[3][4096]; /* array for 3 packets with a size of \ up to 4096Byte */ time_t sk_start; size_t sk_len; size_t sk_len2; int quiet; int verbose; }; struct devices { int fd_in, arptype_in; int fd_out, arptype_out; int fd_rtc; struct tif * dv_ti; struct tif * dv_ti2; uint8_t mac_in[6]; uint8_t mac_out[6]; int is_wlanng; int is_hostap; int is_madwifi; int is_madwifing; int is_bcm43xx; FILE * f_cap_in; struct pcap_file_header pfh_in; }; /* Expects host-endian arguments, but returns little-endian seq. */ static inline uint16_t fnseq(uint16_t fn, uint16_t seq) { uint16_t r = 0; if (fn > 15) { fprintf(stderr, "too many fragments (%d)\n", fn); exit(EXIT_FAILURE); } r = fn; r |= ((seq % 4096) << IEEE80211_SEQ_SEQ_SHIFT); return (htole16(r)); } static inline int get_ip_port(char * iface, char * ip, const int ip_size) { REQUIRE(iface != NULL); REQUIRE(ip != NULL); REQUIRE(ip_size > 0); char * host; char * ptr; int port = -1; struct in_addr addr; host = strdup(iface); if (!host) return (-1); ptr = strchr(host, ':'); if (!ptr) goto out; *ptr++ = 0; if (!inet_aton(host, (struct in_addr *) &addr)) goto out; /* XXX resolve hostname */ if (strlen(host) > 15) { port = -1; goto out; } strncpy(ip, host, (size_t) ip_size); port = (int) strtol(ptr, NULL, 10); if (port <= 0) port = -1; out: free(host); return (port); } int read_packet(struct wif * wi, void * buf, uint32_t count, struct rx_info * ri); int wait_for_beacon(struct wif * wi, uint8_t * bssid, uint8_t * capa, char * essid); int attack_check(uint8_t * bssid, char * essid, uint8_t * capa, struct wif * wi, int ignore_negative_one); typedef void (*read_sleep_cb)(void); static inline void read_sleep(int fd_in, unsigned long usec, read_sleep_cb cb) { struct timeval tv, tv2, tv3; fd_set rfds; gettimeofday(&tv, NULL); gettimeofday(&tv2, NULL); tv3.tv_sec = 0; tv3.tv_usec = 10000; while (((tv2.tv_sec * 1000000UL - tv.tv_sec * 1000000UL) + (tv2.tv_usec - tv.tv_usec)) < (usec)) { FD_ZERO(&rfds); FD_SET(fd_in, &rfds); if (select(fd_in + 1, &rfds, NULL, NULL, &tv3) < 0) { continue; } if (FD_ISSET(fd_in, &rfds)) cb(); gettimeofday(&tv2, NULL); } } extern unsigned long nb_pkt_sent; enum Send_Packet_Option { kNoChange, kRewriteSequenceNumber, kRewriteDuration, }; static inline int send_packet(struct wif * wi, void * buf, size_t count, enum Send_Packet_Option option) { REQUIRE(buf != NULL); REQUIRE(count > 0 && count < INT_MAX); REQUIRE(option >= kNoChange && option <= kRewriteDuration); //-V1016 uint8_t * pkt = (uint8_t *) buf; if ((option & kRewriteSequenceNumber) != 0 && (count > 24) && (pkt[1] & 0x04) == 0 && (pkt[22] & 0x0F) == 0) { pkt[22] = (uint8_t)((nb_pkt_sent & 0x0000000F) << 4); pkt[23] = (uint8_t)((nb_pkt_sent & 0x00000FF0) >> 4); } if ((option & kRewriteDuration) != 0 && count > 24) { // Set the duration... pkt[2] = 0x3A; pkt[3] = 0x01; // Reset Retry Flag pkt[1] = (uint8_t)(pkt[1] & ~0x4); } if (wi_write(wi, NULL, LINKTYPE_IEEE802_11, buf, (int) count, NULL) == -1) { switch (errno) { case EAGAIN: case ENOBUFS: usleep(10000); return (0); /* XXX not sure I like this... -sorbo */ default: perror("wi_write()"); return (-1); } } ++nb_pkt_sent; return (0); } int getnet(struct wif * wi, uint8_t * capa, int filter, int force, uint8_t * f_bssid, uint8_t * r_bssid, uint8_t * r_essid, int ignore_negative_one, int nodetect); int capture_ask_packet(int * caplen, int just_grab); int filter_packet(unsigned char * h80211, int caplen); int dump_initialize(char * prefix); int dump_initialize_multi_format(char * prefix, int ivs_only); int check_shared_key(const uint8_t * h80211, size_t caplen); int encrypt_data(uint8_t * data, size_t length); int create_wep_packet(uint8_t * packet, size_t * length, size_t hdrlen); int set_clear_arp(uint8_t * buf, uint8_t * smac, uint8_t * dmac); int set_final_arp(uint8_t * buf, uint8_t * mymac); int set_clear_ip(uint8_t * buf, size_t ip_len); int set_final_ip(uint8_t * buf, uint8_t * mymac); int msleep(int msec); int read_prga(unsigned char ** dest, char * file); int set_bitrate(struct wif * wi, int rate); #endif //AIRCRACK_NG_COMMUNICATIONS_H aircrack-ng-1.6/include/aircrack-ng/support/crypto_engine_loader.h000066400000000000000000000153741361312141100254300ustar00rootroot00000000000000/* * Copyright (C) 2018-2020 Joseph Benden * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * is provided AS IS, WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and * NON-INFRINGEMENT. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, * MA 02110-1301, USA. * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifndef AIRCRACK_NG_CRYPTO_ENGINE_LOADER_H #define AIRCRACK_NG_CRYPTO_ENGINE_LOADER_H #if defined(_MSC_VER) // Microsoft #define EXPORT __declspec(dllexport) #define IMPORT __declspec(dllimport) #elif defined(__GNUC__) || defined(__llvm__) || defined(__clang__) \ || defined(__INTEL_COMPILER) #define EXPORT __attribute__((visibility("default"))) #define IMPORT #else // do nothing and hope for the best? #define EXPORT #define IMPORT #pragma warning Unknown dynamic link import / export semantics. #endif #define STATIC_ASSERT(COND, MSG) \ typedef char static_assertion_##MSG[(!!(COND)) * 2 - 1] // token pasting madness: #define COMPILE_TIME_ASSERT3(X, L) \ STATIC_ASSERT(X, static_assertion_at_line_##L) #define COMPILE_TIME_ASSERT2(X, L) COMPILE_TIME_ASSERT3(X, L) #define COMPILE_TIME_ASSERT(X) COMPILE_TIME_ASSERT2(X, __LINE__) #if defined(__GNUC__) || defined(__llvm__) || defined(__clang__) \ || defined(__INTEL_COMPILER) #define likely(x) __builtin_expect(!!(x), 1) #define unlikely(x) __builtin_expect(!!(x), 0) #else #define likely(x) (x) #define unlikely(x) (x) #endif #include #include #include #ifdef __cplusplus extern "C" { #endif /** * Returns an integer bit representation of the available SIMD * Aircrack-ng Crypto Engine modules for the runtime machine. * * @return Integer bit representation of SIMD flags. */ IMPORT int ac_crypto_engine_loader_get_available(void); /** * Returns an absolute path to the best Aircrack-ng Crypto * library to load. The caller \b MUST deallocate the * returned memory using \a free! * * @param simd_features Integer bit representation of SIMD flags. * @return character sequence that must be deallocated by caller. */ IMPORT char * ac_crypto_engine_loader_best_library_for(int simd_features); /// Produces an integer bit representation of a SIMD character sequence. IMPORT int ac_crypto_engine_loader_string_to_flag(const char * const str); /** * Produces a character representation of the SIMD integer flags. * * All selected bits of \a flags are converted; producing a space * separated string representation. * * Caller \b MUST deallocate the returned value using \a free * * @param flags Integer bit representation of SIMD flags. * @return character sequence that must be deallocated by caller. */ IMPORT char * ac_crypto_engine_loader_flags_to_string(int flags); /// Loads the specified Aircrack-ng Crypto Engine specified by \a flags. /// Does nothing in a static build. IMPORT int ac_crypto_engine_loader_load(int flags); /// Unloads the Aircrack-ng Crypto Engine. Does nothing in a static build. IMPORT void ac_crypto_engine_loader_unload(void); // Symbols defined by the loader. extern int (*dso_ac_crypto_engine_init)(ac_crypto_engine_t * engine); extern void (*dso_ac_crypto_engine_destroy)(ac_crypto_engine_t * engine); extern void (*dso_ac_crypto_engine_set_essid)(ac_crypto_engine_t * engine, const uint8_t * essid); extern int (*dso_ac_crypto_engine_thread_init)(ac_crypto_engine_t * engine, int threadid); extern void (*dso_ac_crypto_engine_thread_destroy)(ac_crypto_engine_t * engine, int threadid); extern int (*dso_ac_crypto_engine_simd_width)(void); extern int (*dso_ac_crypto_engine_wpa_crack)( ac_crypto_engine_t * engine, const wpapsk_password key[MAX_KEYS_PER_CRYPT_SUPPORTED], const uint8_t eapol[256], uint32_t eapol_size, uint8_t mic[MAX_KEYS_PER_CRYPT_SUPPORTED][20], uint8_t keyver, const uint8_t cmpmic[20], int nparallel, int threadid); extern int (*dso_ac_crypto_engine_wpa_pmkid_crack)( ac_crypto_engine_t * engine, const wpapsk_password key[MAX_KEYS_PER_CRYPT_SUPPORTED], const uint8_t pmkid[32], int nparallel, int threadid); extern void (*dso_ac_crypto_engine_set_pmkid_salt)(ac_crypto_engine_t * engine, const uint8_t bssid[6], const uint8_t stmac[6], int threadid); extern void (*dso_ac_crypto_engine_calc_pke)(ac_crypto_engine_t * engine, const uint8_t bssid[6], const uint8_t stmac[6], const uint8_t anonce[32], const uint8_t snonce[32], int threadid); extern int (*dso_ac_crypto_engine_supported_features)(void); extern uint8_t * (*dso_ac_crypto_engine_get_pmk)(ac_crypto_engine_t * engine, int threadid, int index); extern uint8_t * (*dso_ac_crypto_engine_get_ptk)(ac_crypto_engine_t * engine, int threadid, int index); extern void (*dso_ac_crypto_engine_calc_one_pmk)(const uint8_t * key, const uint8_t * essid, uint32_t essid_length, uint8_t pmk[40]); extern void (*dso_ac_crypto_engine_calc_pmk)( ac_crypto_engine_t * engine, const wpapsk_password key[MAX_KEYS_PER_CRYPT_SUPPORTED], int nparallel, int threadid); extern void (*dso_ac_crypto_engine_calc_mic)( ac_crypto_engine_t * engine, const uint8_t eapol[256], const uint32_t eapol_size, uint8_t mic[MAX_KEYS_PER_CRYPT_SUPPORTED][20], const uint8_t keyver, const int vectorIdx, const int threadid); // End symbols defined by the loader. #ifdef __cplusplus } #endif #endif // AIRCRACK_NG_CRYPTO_ENGINE_LOADER_H aircrack-ng-1.6/include/aircrack-ng/support/fragments.h000066400000000000000000000050261361312141100232140ustar00rootroot00000000000000/* * Copyright (C) 2006-2020 Thomas d'Otreppe * Copyright (C) 2006-2009 Martin Beck * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. * If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. * If you * do not wish to do so, delete this exception statement from your * version. * If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifndef AIRCRACK_NG_FRAGMENTS_H #define AIRCRACK_NG_FRAGMENTS_H #include // if not all fragments are available 60 seconds after the last fragment was // received, they will be removed #define FRAG_TIMEOUT (1000000 * 60) typedef struct Fragment_list * pFrag_t; struct Fragment_list { unsigned char source[6]; unsigned short sequence; unsigned char * fragment[16]; short fragmentlen[16]; char fragnum; unsigned char * header; short headerlen; struct timeval access; char wep; pFrag_t next; }; int addFrag(unsigned char * packet, unsigned char * smac, int len, int crypt, unsigned char * wepkey, int weplen); int timeoutFrag(void); int delFrag(unsigned char * smac, int sequence); unsigned char * getCompleteFrag(unsigned char * smac, int sequence, size_t * packetlen, int crypt, unsigned char * wepkey, int weplen); #endif //AIRCRACK_NG_FRAGMENTS_H aircrack-ng-1.6/include/aircrack-ng/support/mcs_index_rates.h000066400000000000000000000041511361312141100243730ustar00rootroot00000000000000/* * Functions and macros to obtain 802.11n or ac rates based on MCS index * * Copyright (C) 2018-2020 Thomas d'Otreppe * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * is provided AS IS, WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and * NON-INFRINGEMENT. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, * MA 02110-1301, USA. * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifndef MCS_INDEX_RATES_H #define MCS_INDEX_RATES_H // http://mcsindex.com/ // 20/40/80/160MHz -> (0, 1, 2, 3) // 0: long GI, 1: short GI // amount of spatial streams (minus 1) // MCS index extern const float MCS_index_rates[4][2][8][10]; float get_80211n_rate(const int width, const int is_short_GI, const int mcs_index); float get_80211ac_rate(const int width, const int is_short_GI, const int mcs_idx, const int amount_ss); #endif // MCS_INDEX_RATES_H aircrack-ng-1.6/include/aircrack-ng/support/pcap_local.h000066400000000000000000000062651361312141100233310ustar00rootroot00000000000000/* * * Copyright (C) 2001-2004 Christophe Devine * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifndef _AIRCRACK_NG_PCAP_H_ #define _AIRCRACK_NG_PCAP_H_ #include #define FORMAT_CAP 1 #define FORMAT_IVS 2 #define FORMAT_IVS2 3 #define FORMAT_HCCAP 4 #define FORMAT_HCCAPX 5 #define HCCAPX_MAGIC "HCPX" #define HCCAPX_CIGAM "XPCH" #define TCPDUMP_MAGIC 0xA1B2C3D4 #define TCPDUMP_CIGAM 0xD4C3B2A1 #define IVSONLY_MAGIC "\xBF\xCA\x84\xD4" #define IVS2_MAGIC "\xAE\x78\xD1\xFF" #define IVS2_EXTENSION "ivs" #define IVS2_VERSION 1 #define PCAP_VERSION_MAJOR 2 #define PCAP_VERSION_MINOR 4 #define LINKTYPE_ETHERNET 1 #define LINKTYPE_IEEE802_11 105 #define LINKTYPE_PRISM_HEADER 119 #define LINKTYPE_RADIOTAP_HDR 127 #define LINKTYPE_PPI_HDR 192 // BSSID const. length of 6 bytes; can be together with all the other types #define IVS2_BSSID 0x0001 // ESSID var. length; alone, or with BSSID #define IVS2_ESSID 0x0002 // wpa structure, const. length; alone, or with BSSID #define IVS2_WPA 0x0004 // IV+IDX+KEYSTREAM, var. length; alone or with BSSID #define IVS2_XOR 0x0008 /* [IV+IDX][i][l][XOR_1]..[XOR_i][weight] * * holds i possible keystreams for the same IV with a length of l for each * keystream (l max 32) * * and an array "int weight[16]" at the end */ #define IVS2_PTW 0x0010 // unencrypted packet #define IVS2_CLR 0x0020 // Maximum length of an Information Element #define MAX_IE_ELEMENT_SIZE 256 struct pcap_file_header { uint32_t magic; uint16_t version_major; uint16_t version_minor; int32_t thiszone; uint32_t sigfigs; uint32_t snaplen; uint32_t linktype; }; struct pcap_pkthdr { int32_t tv_sec; int32_t tv_usec; uint32_t caplen; uint32_t len; }; struct ivs2_filehdr { uint16_t version; }; struct ivs2_pkthdr { uint16_t flags; uint16_t len; }; #endif /* common.h */ aircrack-ng-1.6/include/aircrack-ng/support/station.h000066400000000000000000000206341361312141100227110ustar00rootroot00000000000000/* * Copyright (C) 2006-2020 Thomas d'Otreppe * Copyright (C) 2006-2009 Martin Beck * Copyright (C) 2018-2020 Joseph Benden * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. * If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. * If you * do not wish to do so, delete this exception statement from your * version. * If you delete this exception statement from all source * files in the program, then also delete it here. */ #include #include #include #include #ifndef AIRCRACK_NG_STATION_H #define AIRCRACK_NG_STATION_H #define NB_PRB 10 /* size of probed ESSID ring buffer */ #define NB_PWR 5 /* size of signal power ring buffer */ /* WPS_info struct */ struct WPS_info { unsigned char version; /* WPS Version */ unsigned char state; /* Current WPS state */ unsigned char ap_setup_locked; /* AP setup locked */ unsigned int meth; /* WPS Config Methods */ }; #define MAX_AC_MCS_INDEX 8 /* 802.11n channel information */ struct n_channel_info { char mcs_index; /* Maximum MCS TX index */ char sec_channel; /* 802.11n secondary channel*/ unsigned char short_gi_20; /* Short GI for 20MHz */ unsigned char short_gi_40; /* Short GI for 40MHz */ unsigned char any_chan_width; /* Support for 20 or 40MHz as opposed to only 20 or only 40MHz */ }; /* 802.11ac channel information */ struct ac_channel_info { unsigned char center_sgmt[2]; /* 802.11ac Center segment 0*/ unsigned char mu_mimo; /* MU-MIMO support */ unsigned char short_gi_80; /* Short GI for 80MHz */ unsigned char short_gi_160; /* Short GI for 160MHz */ unsigned char split_chan; /* 80+80MHz Channel support */ unsigned char mhz_160_chan; /* 160 MHz channel support */ unsigned char wave_2; /* Wave 2 */ unsigned char mcs_index[MAX_AC_MCS_INDEX]; /* Maximum TX rate */ }; enum channel_width_enum { CHANNEL_UNKNOWN_WIDTH, CHANNEL_3MHZ, CHANNEL_5MHZ, CHANNEL_10MHZ, CHANNEL_20MHZ, CHANNEL_22MHZ, CHANNEL_30MHZ, CHANNEL_20_OR_40MHZ, CHANNEL_40MHZ, CHANNEL_80MHZ, CHANNEL_80_80MHZ, CHANNEL_160MHZ }; /** linked list of detected access points. */ struct AP_info { struct AP_info * prev; /* prev. AP in list */ struct AP_info * next; /* next AP in list */ time_t tinit, tlast; /* first and last time seen */ int channel; /* AP radio channel */ enum channel_width_enum channel_width; /* Channel width */ char standard[3]; /* 802.11 standard: n or ac */ struct n_channel_info n_channel; /* 802.11n channel info */ struct ac_channel_info ac_channel; /* 802.11ac channel info */ int max_speed; /* AP maximum speed in Mb/s */ int avg_power; /* averaged signal power */ int best_power; /* best signal power */ int power_index; /* index in power ring buf. */ int power_lvl[NB_PWR]; /* signal power ring buffer */ int preamble; /* 0 = long, 1 = short */ unsigned int security; /* ENC_*, AUTH_*, STD_* */ int beacon_logged; /* We need 1 beacon per AP */ int dict_started; /* 1 if dict attack started */ int ssid_length; /* length of ssid */ float gps_loc_min[5]; /* min gps coordinates */ float gps_loc_max[5]; /* max gps coordinates */ float gps_loc_best[5]; /* best gps coordinates */ unsigned long nb_bcn; /* total number of beacons */ unsigned long nb_pkt; /* total number of packets */ unsigned long nb_data; /* number of data packets */ unsigned long nb_data_old; /* number of data packets/sec*/ int nb_dataps; /* number of data packets/sec*/ struct timeval tv; /* time for data per second */ char * manuf; /* the access point's manufacturer */ unsigned long long timestamp; /* Timestamp to calculate uptime */ uint8_t bssid[6]; /* access point MAC address */ uint8_t essid[ESSID_LENGTH + 1]; /* access point identifier */ uint8_t lanip[4]; /* IP address if unencrypted */ uint8_t * ivbuf; /* table holding WEP IV data */ uint8_t ** uiv_root; /* IV uniqueness root struct */ long ivbuf_size; /* IV buffer allocated size */ long nb_ivs; /* total number of unique IVs */ long nb_ivs_clean; /* total number of unique IVs */ long nb_ivs_vague; /* total number of unique IVs */ unsigned int crypt; /* encryption algorithm */ int eapol; /* set if EAPOL is present */ int target; /* flag set if AP is a target */ struct ST_info * st_1st; /* DEPRECATED: linked list of stations */ c_avl_tree_t * stations; /* AVL tree of stations keyed on MAC*/ struct WPA_hdsk wpa; /* valid WPA handshake data */ PTW_attackstate * ptw_clean; PTW_attackstate * ptw_vague; int wpa_stored; /* wpa stored in ivs file? */ int essid_stored; /* essid stored in ivs file? */ int rx_quality; /* percent of captured beacons */ int fcapt; /* amount of captured frames */ int fmiss; /* amount of missed frames */ unsigned int last_seq; /* last sequence number */ struct timeval ftimef; /* time of first frame */ struct timeval ftimel; /* time of last frame */ struct timeval ftimer; /* time of restart */ char * key; /* if wep-key found by dict */ char decloak_detect; /* run decloak detection? */ struct pkt_buf * packets; /* list of captured packets (last few seconds) */ char is_decloak; /* detected decloak */ // This feature eats 48Mb per AP int EAP_detected; uint8_t * data_root; /* first 2 bytes of data if */ /* WEP network; used for */ /* detecting WEP cloak */ /* + one byte to indicate */ /* (in)existence of the IV */ int marked; int marked_color; struct WPS_info wps; }; /** linked list of detected clients */ struct ST_info { struct ST_info * prev; /* the prev client in list */ struct ST_info * next; /* the next client in list */ struct AP_info * base; /* AP this client belongs to */ uint8_t stmac[6]; /* the client's MAC address */ struct WPA_hdsk wpa; /* WPA handshake data */ char * manuf; /* the client's manufacturer */ time_t tinit, tlast; /* first and last time seen */ unsigned long nb_pkt; /* total number of packets */ uint8_t essid[ESSID_LENGTH + 1]; /* last associated essid */ int essid_length; /* essid length of last asso */ int probe_index; /* probed ESSIDs ring index */ char probes[NB_PRB][MAX_IE_ELEMENT_SIZE]; /* probed ESSIDs ring buffer */ int ssid_length[NB_PRB]; /* ssid lengths ring buffer */ int power; /* last signal power */ int best_power; /* best signal power */ int rate_to; /* last bitrate to station */ int rate_from; /* last bitrate from station */ struct timeval ftimer; /* time of restart */ int missed; /* number of missed packets */ unsigned int lastseq; /* last seen sequnce number */ int wpatype; /* 1=wpa1 2=wpa2 */ int wpahash; /* 1=md5(tkip) 2=sha1(ccmp) */ int wep; /* capability encryption bit */ int qos_to_ds; /* does it use 802.11e to ds */ int qos_fr_ds; /* does it receive 802.11e */ int channel; /* Channel station is seen */ float gps_loc_min[5]; /* min gps coordinates */ float gps_loc_max[5]; /* max gps coordinates */ float gps_loc_best[5]; /* best gps coordinates */ }; #endif //AIRCRACK_NG_STATION_H aircrack-ng-1.6/include/aircrack-ng/third-party/000077500000000000000000000000001361312141100216055ustar00rootroot00000000000000aircrack-ng-1.6/include/aircrack-ng/third-party/eapol.h000066400000000000000000000011621361312141100230560ustar00rootroot00000000000000#ifndef _NET_EAPOL_H_ #define _NET_EAPOL_H_ #include struct WPA_hdsk { uint8_t stmac[6]; /* supplicant MAC */ uint8_t snonce[32]; /* supplicant nonce */ uint8_t anonce[32]; /* authenticator nonce */ uint8_t pmkid[16]; /* eapol frame PMKID RSN */ uint8_t keymic[16]; /* eapol frame MIC */ uint8_t eapol[256]; /* eapol frame contents */ uint32_t eapol_size; /* eapol frame size */ uint8_t keyver; /* key version (TKIP / AES) */ uint8_t state; /* handshake completion */ uint8_t found; uint8_t eapol_source; uint64_t replay; }; #endif // _NET_EAPOL_H_ aircrack-ng-1.6/include/aircrack-ng/third-party/ethernet.h000066400000000000000000000462401361312141100236020ustar00rootroot00000000000000/* * Fundamental constants relating to ethernet. * * $FreeBSD$ * */ #ifndef _NET_ETHERNET_H_ #define _NET_ETHERNET_H_ /* * Some basic Ethernet constants. */ #define ETHER_ADDR_LEN 6 /* length of an Ethernet address */ #define ETHER_TYPE_LEN 2 /* length of the Ethernet type field */ #define ETHER_CRC_LEN 4 /* length of the Ethernet CRC */ #define ETHER_HDR_LEN (ETHER_ADDR_LEN*2+ETHER_TYPE_LEN) #define ETHER_MIN_LEN 64 /* minimum frame len, including CRC */ #define ETHER_MAX_LEN 1518 /* maximum frame len, including CRC */ #define ETHER_MAX_LEN_JUMBO 9018 /* max jumbo frame len, including CRC */ #define ETHER_VLAN_ENCAP_LEN 4 /* len of 802.1Q VLAN encapsulation */ /* * Mbuf adjust factor to force 32-bit alignment of IP header. * Drivers should do m_adj(m, ETHER_ALIGN) when setting up a * receive so the upper layers get the IP header properly aligned * past the 14-byte Ethernet header. */ #define ETHER_ALIGN 2 /* driver adjust for IP hdr alignment */ /* * Compute the maximum frame size based on ethertype (i.e. possible * encapsulation) and whether or not an FCS is present. */ #define ETHER_MAX_FRAME(ifp, etype, hasfcs) \ ((ifp)->if_mtu + ETHER_HDR_LEN + \ ((hasfcs) ? ETHER_CRC_LEN : 0) + \ (((etype) == ETHERTYPE_VLAN) ? ETHER_VLAN_ENCAP_LEN : 0)) /* * Ethernet-specific mbuf flags. */ #define M_HASFCS M_PROTO5 /* FCS included at end of frame */ /* * Ethernet CRC32 polynomials (big- and little-endian versions). */ #define ETHER_CRC_POLY_LE 0xedb88320 #define ETHER_CRC_POLY_BE 0x04c11db6 /* * A macro to validate a length with */ #define ETHER_IS_VALID_LEN(foo) \ ((foo) >= ETHER_MIN_LEN && (foo) <= ETHER_MAX_LEN) /* * Structure of a 10Mb/s Ethernet header. */ struct ether_header { u_char ether_dhost[ETHER_ADDR_LEN]; u_char ether_shost[ETHER_ADDR_LEN]; u_short ether_type; } __packed; /* * Structure of a 48-bit Ethernet address. */ struct ether_addr { u_char octet[ETHER_ADDR_LEN]; } __packed; #define ETHER_IS_MULTICAST(addr) (*(addr) & 0x01) /* is address mcast/bcast? */ /* * NOTE: 0x0000-0x05DC (0..1500) are generally IEEE 802.3 length fields. * However, there are some conflicts. */ #define ETHERTYPE_8023 0x0004 /* IEEE 802.3 packet */ /* 0x0101 .. 0x1FF Experimental */ #define ETHERTYPE_PUP 0x0200 /* Xerox PUP protocol - see 0A00 */ #define ETHERTYPE_PUPAT 0x0200 /* PUP Address Translation - see 0A01 */ #define ETHERTYPE_SPRITE 0x0500 /* ??? */ /* 0x0400 Nixdorf */ #define ETHERTYPE_NS 0x0600 /* XNS */ #define ETHERTYPE_NSAT 0x0601 /* XNS Address Translation (3Mb only) */ #define ETHERTYPE_DLOG1 0x0660 /* DLOG (?) */ #define ETHERTYPE_DLOG2 0x0661 /* DLOG (?) */ #define ETHERTYPE_IP 0x0800 /* IP protocol */ #define ETHERTYPE_X75 0x0801 /* X.75 Internet */ #define ETHERTYPE_NBS 0x0802 /* NBS Internet */ #define ETHERTYPE_ECMA 0x0803 /* ECMA Internet */ #define ETHERTYPE_CHAOS 0x0804 /* CHAOSnet */ #define ETHERTYPE_X25 0x0805 /* X.25 Level 3 */ #define ETHERTYPE_ARP 0x0806 /* Address resolution protocol */ #define ETHERTYPE_NSCOMPAT 0x0807 /* XNS Compatibility */ #define ETHERTYPE_FRARP 0x0808 /* Frame Relay ARP (RFC1701) */ /* 0x081C Symbolics Private */ /* 0x0888 - 0x088A Xyplex */ #define ETHERTYPE_UBDEBUG 0x0900 /* Ungermann-Bass network debugger */ #define ETHERTYPE_IEEEPUP 0x0A00 /* Xerox IEEE802.3 PUP */ #define ETHERTYPE_IEEEPUPAT 0x0A01 /* Xerox IEEE802.3 PUP Address Translation */ #define ETHERTYPE_VINES 0x0BAD /* Banyan VINES */ #define ETHERTYPE_VINESLOOP 0x0BAE /* Banyan VINES Loopback */ #define ETHERTYPE_VINESECHO 0x0BAF /* Banyan VINES Echo */ /* 0x1000 - 0x100F Berkeley Trailer */ /* * The ETHERTYPE_NTRAILER packet types starting at ETHERTYPE_TRAIL have * (type-ETHERTYPE_TRAIL)*512 bytes of data followed * by an ETHER type (as given above) and then the (variable-length) header. */ #define ETHERTYPE_TRAIL 0x1000 /* Trailer packet */ #define ETHERTYPE_NTRAILER 16 #define ETHERTYPE_DCA 0x1234 /* DCA - Multicast */ #define ETHERTYPE_VALID 0x1600 /* VALID system protocol */ #define ETHERTYPE_DOGFIGHT 0x1989 /* Artificial Horizons ("Aviator" dogfight simulator [on Sun]) */ #define ETHERTYPE_RCL 0x1995 /* Datapoint Corporation (RCL lan protocol) */ /* The following 3C0x types are unregistered: */ #define ETHERTYPE_NBPVCD 0x3C00 /* 3Com NBP virtual circuit datagram (like XNS SPP) not registered */ #define ETHERTYPE_NBPSCD 0x3C01 /* 3Com NBP System control datagram not registered */ #define ETHERTYPE_NBPCREQ 0x3C02 /* 3Com NBP Connect request (virtual cct) not registered */ #define ETHERTYPE_NBPCRSP 0x3C03 /* 3Com NBP Connect response not registered */ #define ETHERTYPE_NBPCC 0x3C04 /* 3Com NBP Connect complete not registered */ #define ETHERTYPE_NBPCLREQ 0x3C05 /* 3Com NBP Close request (virtual cct) not registered */ #define ETHERTYPE_NBPCLRSP 0x3C06 /* 3Com NBP Close response not registered */ #define ETHERTYPE_NBPDG 0x3C07 /* 3Com NBP Datagram (like XNS IDP) not registered */ #define ETHERTYPE_NBPDGB 0x3C08 /* 3Com NBP Datagram broadcast not registered */ #define ETHERTYPE_NBPCLAIM 0x3C09 /* 3Com NBP Claim NetBIOS name not registered */ #define ETHERTYPE_NBPDLTE 0x3C0A /* 3Com NBP Delete NetBIOS name not registered */ #define ETHERTYPE_NBPRAS 0x3C0B /* 3Com NBP Remote adaptor status request not registered */ #define ETHERTYPE_NBPRAR 0x3C0C /* 3Com NBP Remote adaptor response not registered */ #define ETHERTYPE_NBPRST 0x3C0D /* 3Com NBP Reset not registered */ #define ETHERTYPE_PCS 0x4242 /* PCS Basic Block Protocol */ #define ETHERTYPE_IMLBLDIAG 0x424C /* Information Modes Little Big LAN diagnostic */ #define ETHERTYPE_DIDDLE 0x4321 /* THD - Diddle */ #define ETHERTYPE_IMLBL 0x4C42 /* Information Modes Little Big LAN */ #define ETHERTYPE_SIMNET 0x5208 /* BBN Simnet Private */ #define ETHERTYPE_DECEXPER 0x6000 /* DEC Unassigned, experimental */ #define ETHERTYPE_MOPDL 0x6001 /* DEC MOP dump/load */ #define ETHERTYPE_MOPRC 0x6002 /* DEC MOP remote console */ #define ETHERTYPE_DECnet 0x6003 /* DEC DECNET Phase IV route */ #define ETHERTYPE_DN ETHERTYPE_DECnet /* libpcap, tcpdump */ #define ETHERTYPE_LAT 0x6004 /* DEC LAT */ #define ETHERTYPE_DECDIAG 0x6005 /* DEC diagnostic protocol (at interface initialization?) */ #define ETHERTYPE_DECCUST 0x6006 /* DEC customer protocol */ #define ETHERTYPE_SCA 0x6007 /* DEC LAVC, SCA */ #define ETHERTYPE_AMBER 0x6008 /* DEC AMBER */ #define ETHERTYPE_DECMUMPS 0x6009 /* DEC MUMPS */ /* 0x6010 - 0x6014 3Com Corporation */ #define ETHERTYPE_TRANSETHER 0x6558 /* Trans Ether Bridging (RFC1701)*/ #define ETHERTYPE_RAWFR 0x6559 /* Raw Frame Relay (RFC1701) */ #define ETHERTYPE_UBDL 0x7000 /* Ungermann-Bass download */ #define ETHERTYPE_UBNIU 0x7001 /* Ungermann-Bass NIUs */ #define ETHERTYPE_UBDIAGLOOP 0x7002 /* Ungermann-Bass diagnostic/loopback */ #define ETHERTYPE_UBNMC 0x7003 /* Ungermann-Bass ??? (NMC to/from UB Bridge) */ #define ETHERTYPE_UBBST 0x7005 /* Ungermann-Bass Bridge Spanning Tree */ #define ETHERTYPE_OS9 0x7007 /* OS/9 Microware */ #define ETHERTYPE_OS9NET 0x7009 /* OS/9 Net? */ /* 0x7020 - 0x7029 LRT (England) (now Sintrom) */ #define ETHERTYPE_RACAL 0x7030 /* Racal-Interlan */ #define ETHERTYPE_PRIMENTS 0x7031 /* Prime NTS (Network Terminal Service) */ #define ETHERTYPE_CABLETRON 0x7034 /* Cabletron */ #define ETHERTYPE_CRONUSVLN 0x8003 /* Cronus VLN */ #define ETHERTYPE_CRONUS 0x8004 /* Cronus Direct */ #define ETHERTYPE_HP 0x8005 /* HP Probe */ #define ETHERTYPE_NESTAR 0x8006 /* Nestar */ #define ETHERTYPE_ATTSTANFORD 0x8008 /* AT&T/Stanford (local use) */ #define ETHERTYPE_EXCELAN 0x8010 /* Excelan */ #define ETHERTYPE_SG_DIAG 0x8013 /* SGI diagnostic type */ #define ETHERTYPE_SG_NETGAMES 0x8014 /* SGI network games */ #define ETHERTYPE_SG_RESV 0x8015 /* SGI reserved type */ #define ETHERTYPE_SG_BOUNCE 0x8016 /* SGI bounce server */ #define ETHERTYPE_APOLLODOMAIN 0x8019 /* Apollo DOMAIN */ #define ETHERTYPE_TYMSHARE 0x802E /* Tymeshare */ #define ETHERTYPE_TIGAN 0x802F /* Tigan, Inc. */ #define ETHERTYPE_REVARP 0x8035 /* Reverse addr resolution protocol */ #define ETHERTYPE_AEONIC 0x8036 /* Aeonic Systems */ #define ETHERTYPE_IPXNEW 0x8037 /* IPX (Novell Netware?) */ #define ETHERTYPE_LANBRIDGE 0x8038 /* DEC LANBridge */ #define ETHERTYPE_DSMD 0x8039 /* DEC DSM/DDP */ #define ETHERTYPE_ARGONAUT 0x803A /* DEC Argonaut Console */ #define ETHERTYPE_VAXELN 0x803B /* DEC VAXELN */ #define ETHERTYPE_DECDNS 0x803C /* DEC DNS Naming Service */ #define ETHERTYPE_ENCRYPT 0x803D /* DEC Ethernet Encryption */ #define ETHERTYPE_DECDTS 0x803E /* DEC Distributed Time Service */ #define ETHERTYPE_DECLTM 0x803F /* DEC LAN Traffic Monitor */ #define ETHERTYPE_DECNETBIOS 0x8040 /* DEC PATHWORKS DECnet NETBIOS Emulation */ #define ETHERTYPE_DECLAST 0x8041 /* DEC Local Area System Transport */ /* 0x8042 DEC Unassigned */ #define ETHERTYPE_PLANNING 0x8044 /* Planning Research Corp. */ /* 0x8046 - 0x8047 AT&T */ #define ETHERTYPE_DECAM 0x8048 /* DEC Availability Manager for Distributed Systems DECamds (but someone at DEC says not) */ #define ETHERTYPE_EXPERDATA 0x8049 /* ExperData */ #define ETHERTYPE_VEXP 0x805B /* Stanford V Kernel exp. */ #define ETHERTYPE_VPROD 0x805C /* Stanford V Kernel prod. */ #define ETHERTYPE_ES 0x805D /* Evans & Sutherland */ #define ETHERTYPE_LITTLE 0x8060 /* Little Machines */ #define ETHERTYPE_COUNTERPOINT 0x8062 /* Counterpoint Computers */ /* 0x8065 - 0x8066 Univ. of Mass @ Amherst */ #define ETHERTYPE_VEECO 0x8067 /* Veeco Integrated Auto. */ #define ETHERTYPE_GENDYN 0x8068 /* General Dynamics */ #define ETHERTYPE_ATT 0x8069 /* AT&T */ #define ETHERTYPE_AUTOPHON 0x806A /* Autophon */ #define ETHERTYPE_COMDESIGN 0x806C /* ComDesign */ #define ETHERTYPE_COMPUGRAPHIC 0x806D /* Compugraphic Corporation */ /* 0x806E - 0x8077 Landmark Graphics Corp. */ #define ETHERTYPE_MATRA 0x807A /* Matra */ #define ETHERTYPE_DDE 0x807B /* Dansk Data Elektronik */ #define ETHERTYPE_MERIT 0x807C /* Merit Internodal (or Univ of Michigan?) */ /* 0x807D - 0x807F Vitalink Communications */ #define ETHERTYPE_VLTLMAN 0x8080 /* Vitalink TransLAN III Management */ /* 0x8081 - 0x8083 Counterpoint Computers */ /* 0x8088 - 0x808A Xyplex */ #define ETHERTYPE_ATALK 0x809B /* AppleTalk */ #define ETHERTYPE_AT ETHERTYPE_ATALK /* old NetBSD */ #define ETHERTYPE_APPLETALK ETHERTYPE_ATALK /* HP-UX */ /* 0x809C - 0x809E Datability */ #define ETHERTYPE_SPIDER 0x809F /* Spider Systems Ltd. */ /* 0x80A3 Nixdorf */ /* 0x80A4 - 0x80B3 Siemens Gammasonics Inc. */ /* 0x80C0 - 0x80C3 DCA (Digital Comm. Assoc.) Data Exchange Cluster */ /* 0x80C4 - 0x80C5 Banyan Systems */ #define ETHERTYPE_PACER 0x80C6 /* Pacer Software */ #define ETHERTYPE_APPLITEK 0x80C7 /* Applitek Corporation */ /* 0x80C8 - 0x80CC Intergraph Corporation */ /* 0x80CD - 0x80CE Harris Corporation */ /* 0x80CF - 0x80D2 Taylor Instrument */ /* 0x80D3 - 0x80D4 Rosemount Corporation */ #define ETHERTYPE_SNA 0x80D5 /* IBM SNA Services over Ethernet */ #define ETHERTYPE_VARIAN 0x80DD /* Varian Associates */ /* 0x80DE - 0x80DF TRFS (Integrated Solutions Transparent Remote File System) */ /* 0x80E0 - 0x80E3 Allen-Bradley */ /* 0x80E4 - 0x80F0 Datability */ #define ETHERTYPE_RETIX 0x80F2 /* Retix */ #define ETHERTYPE_AARP 0x80F3 /* AppleTalk AARP */ /* 0x80F4 - 0x80F5 Kinetics */ #define ETHERTYPE_APOLLO 0x80F7 /* Apollo Computer */ #define ETHERTYPE_VLAN 0x8100 /* IEEE 802.1Q VLAN tagging (XXX conflicts) */ /* 0x80FF - 0x8101 Wellfleet Communications (XXX conflicts) */ #define ETHERTYPE_BOFL 0x8102 /* Wellfleet; BOFL (Breath OF Life) pkts [every 5-10 secs.] */ #define ETHERTYPE_WELLFLEET 0x8103 /* Wellfleet Communications */ /* 0x8107 - 0x8109 Symbolics Private */ #define ETHERTYPE_TALARIS 0x812B /* Talaris */ #define ETHERTYPE_WATERLOO 0x8130 /* Waterloo Microsystems Inc. (XXX which?) */ #define ETHERTYPE_HAYES 0x8130 /* Hayes Microcomputers (XXX which?) */ #define ETHERTYPE_VGLAB 0x8131 /* VG Laboratory Systems */ /* 0x8132 - 0x8137 Bridge Communications */ #define ETHERTYPE_IPX 0x8137 /* Novell (old) NetWare IPX (ECONFIG E option) */ #define ETHERTYPE_NOVELL 0x8138 /* Novell, Inc. */ /* 0x8139 - 0x813D KTI */ #define ETHERTYPE_MUMPS 0x813F /* M/MUMPS data sharing */ #define ETHERTYPE_AMOEBA 0x8145 /* Vrije Universiteit (NL) Amoeba 4 RPC (obsolete) */ #define ETHERTYPE_FLIP 0x8146 /* Vrije Universiteit (NL) FLIP (Fast Local Internet Protocol) */ #define ETHERTYPE_VURESERVED 0x8147 /* Vrije Universiteit (NL) [reserved] */ #define ETHERTYPE_LOGICRAFT 0x8148 /* Logicraft */ #define ETHERTYPE_NCD 0x8149 /* Network Computing Devices */ #define ETHERTYPE_ALPHA 0x814A /* Alpha Micro */ #define ETHERTYPE_SNMP 0x814C /* SNMP over Ethernet (see RFC1089) */ /* 0x814D - 0x814E BIIN */ #define ETHERTYPE_TEC 0x814F /* Technically Elite Concepts */ #define ETHERTYPE_RATIONAL 0x8150 /* Rational Corp */ /* 0x8151 - 0x8153 Qualcomm */ /* 0x815C - 0x815E Computer Protocol Pty Ltd */ /* 0x8164 - 0x8166 Charles River Data Systems */ #define ETHERTYPE_XTP 0x817D /* Protocol Engines XTP */ #define ETHERTYPE_SGITW 0x817E /* SGI/Time Warner prop. */ #define ETHERTYPE_HIPPI_FP 0x8180 /* HIPPI-FP encapsulation */ #define ETHERTYPE_STP 0x8181 /* Scheduled Transfer STP, HIPPI-ST */ /* 0x8182 - 0x8183 Reserved for HIPPI-6400 */ /* 0x8184 - 0x818C SGI prop. */ #define ETHERTYPE_MOTOROLA 0x818D /* Motorola */ #define ETHERTYPE_NETBEUI 0x8191 /* PowerLAN NetBIOS/NetBEUI (PC) */ /* 0x819A - 0x81A3 RAD Network Devices */ /* 0x81B7 - 0x81B9 Xyplex */ /* 0x81CC - 0x81D5 Apricot Computers */ /* 0x81D6 - 0x81DD Artisoft Lantastic */ /* 0x81E6 - 0x81EF Polygon */ /* 0x81F0 - 0x81F2 Comsat Labs */ /* 0x81F3 - 0x81F5 SAIC */ /* 0x81F6 - 0x81F8 VG Analytical */ /* 0x8203 - 0x8205 QNX Software Systems Ltd. */ /* 0x8221 - 0x8222 Ascom Banking Systems */ /* 0x823E - 0x8240 Advanced Encryption Systems */ /* 0x8263 - 0x826A Charles River Data Systems */ /* 0x827F - 0x8282 Athena Programming */ /* 0x829A - 0x829B Inst Ind Info Tech */ /* 0x829C - 0x82AB Taurus Controls */ /* 0x82AC - 0x8693 Walker Richer & Quinn */ #define ETHERTYPE_ACCTON 0x8390 /* Accton Technologies (unregistered) */ #define ETHERTYPE_TALARISMC 0x852B /* Talaris multicast */ #define ETHERTYPE_KALPANA 0x8582 /* Kalpana */ /* 0x8694 - 0x869D Idea Courier */ /* 0x869E - 0x86A1 Computer Network Tech */ /* 0x86A3 - 0x86AC Gateway Communications */ #define ETHERTYPE_SECTRA 0x86DB /* SECTRA */ #define ETHERTYPE_IPV6 0x86DD /* IP protocol version 6 */ #define ETHERTYPE_DELTACON 0x86DE /* Delta Controls */ #define ETHERTYPE_ATOMIC 0x86DF /* ATOMIC */ /* 0x86E0 - 0x86EF Landis & Gyr Powers */ /* 0x8700 - 0x8710 Motorola */ #define ETHERTYPE_RDP 0x8739 /* Control Technology Inc. RDP Without IP */ #define ETHERTYPE_MICP 0x873A /* Control Technology Inc. Mcast Industrial Ctrl Proto. */ /* 0x873B - 0x873C Control Technology Inc. Proprietary */ #define ETHERTYPE_TCPCOMP 0x876B /* TCP/IP Compression (RFC1701) */ #define ETHERTYPE_IPAS 0x876C /* IP Autonomous Systems (RFC1701) */ #define ETHERTYPE_SECUREDATA 0x876D /* Secure Data (RFC1701) */ #define ETHERTYPE_FLOWCONTROL 0x8808 /* 802.3x flow control packet */ #define ETHERTYPE_SLOW 0x8809 /* 802.3ad link aggregation (LACP) */ #define ETHERTYPE_PPP 0x880B /* PPP (obsolete by PPPoE) */ #define ETHERTYPE_HITACHI 0x8820 /* Hitachi Cable (Optoelectronic Systems Laboratory) */ #define ETHERTYPE_MPLS 0x8847 /* MPLS Unicast */ #define ETHERTYPE_MPLS_MCAST 0x8848 /* MPLS Multicast */ #define ETHERTYPE_AXIS 0x8856 /* Axis Communications AB proprietary bootstrap/config */ #define ETHERTYPE_PPPOEDISC 0x8863 /* PPP Over Ethernet Discovery Stage */ #define ETHERTYPE_PPPOE 0x8864 /* PPP Over Ethernet Session Stage */ #define ETHERTYPE_LANPROBE 0x8888 /* HP LanProbe test? */ #define ETHERTYPE_PAE 0x888e /* EAPOL PAE/802.1x */ #define ETHERTYPE_LOOPBACK 0x9000 /* Loopback: used to test interfaces */ #define ETHERTYPE_LBACK ETHERTYPE_LOOPBACK /* DEC MOP loopback */ #define ETHERTYPE_XNSSM 0x9001 /* 3Com (Formerly Bridge Communications), XNS Systems Management */ #define ETHERTYPE_TCPSM 0x9002 /* 3Com (Formerly Bridge Communications), TCP/IP Systems Management */ #define ETHERTYPE_BCLOOP 0x9003 /* 3Com (Formerly Bridge Communications), loopback detection */ #define ETHERTYPE_DEBNI 0xAAAA /* DECNET? Used by VAX 6220 DEBNI */ #define ETHERTYPE_SONIX 0xFAF5 /* Sonix Arpeggio */ #define ETHERTYPE_VITAL 0xFF00 /* BBN VITAL-LanBridge cache wakeups */ /* 0xFF00 - 0xFFOF ISC Bunker Ramo */ #define ETHERTYPE_MAX 0xFFFF /* Maximum valid ethernet type, reserved */ /* * The ETHERTYPE_NTRAILER packet types starting at ETHERTYPE_TRAIL have * (type-ETHERTYPE_TRAIL)*512 bytes of data followed * by an ETHER type (as given above) and then the (variable-length) header. */ #define ETHERTYPE_TRAIL 0x1000 /* Trailer packet */ #define ETHERTYPE_NTRAILER 16 #define ETHERMTU (ETHER_MAX_LEN-ETHER_HDR_LEN-ETHER_CRC_LEN) #define ETHERMIN (ETHER_MIN_LEN-ETHER_HDR_LEN-ETHER_CRC_LEN) #define ETHERMTU_JUMBO (ETHER_MAX_LEN_JUMBO - ETHER_HDR_LEN - ETHER_CRC_LEN) /* * The ETHER_BPF_MTAP macro should be used by drivers which support hardware * offload for VLAN tag processing. It will check the mbuf to see if it has * M_VLANTAG set, and if it does, will pass the packet along to * ether_vlan_mtap. This function will re-insert VLAN tags for the duration * of the tap, so they show up properly for network analyzers. */ #define ETHER_BPF_MTAP(_ifp, _m) do { \ if (bpf_peers_present((_ifp)->if_bpf)) { \ M_ASSERTVALID(_m); \ if (((_m)->m_flags & M_VLANTAG) != 0) \ ether_vlan_mtap((_ifp)->if_bpf, (_m), NULL, 0); \ else \ bpf_mtap((_ifp)->if_bpf, (_m)); \ } \ } while (0) #ifdef _KERNEL struct ifnet; struct mbuf; struct route; struct sockaddr; struct bpf_if; extern uint32_t ether_crc32_le(const uint8_t *, size_t); extern uint32_t ether_crc32_be(const uint8_t *, size_t); extern void ether_demux(struct ifnet *, struct mbuf *); extern void ether_ifattach(struct ifnet *, const u_int8_t *); extern void ether_ifdetach(struct ifnet *); extern int ether_ioctl(struct ifnet *, u_long, caddr_t); extern int ether_output(struct ifnet *, struct mbuf *, const struct sockaddr *, struct route *); extern int ether_output_frame(struct ifnet *, struct mbuf *); extern char *ether_sprintf(const u_int8_t *); void ether_vlan_mtap(struct bpf_if *, struct mbuf *, void *, u_int); struct mbuf *ether_vlanencap(struct mbuf *, uint16_t); #else /* _KERNEL */ /* * Ethernet address conversion/parsing routines. */ #ifdef __cplusplus extern "C" { #endif struct ether_addr *ether_aton(const char *); struct ether_addr *ether_aton_r(const char *, struct ether_addr *); int ether_hostton(const char *, struct ether_addr *); int ether_line(const char *, struct ether_addr *, char *); char *ether_ntoa(const struct ether_addr *); char *ether_ntoa_r(const struct ether_addr *, char *); int ether_ntohost(char *, const struct ether_addr *); #ifdef __cplusplus } #endif #endif /* !_KERNEL */ #endif /* !_NET_ETHERNET_H_ */ aircrack-ng-1.6/include/aircrack-ng/third-party/hashcat.h000066400000000000000000000164531361312141100234020ustar00rootroot00000000000000/* * Hashcat structures and macros * * Copyright (C) 2018-2020 Thomas d'Otreppe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. * If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. * If you * do not wish to do so, delete this exception statement from your * version. * If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifndef _HASHCAT_H_ #define _HASHCAT_H_ #include // Hashcat v3.5 and lower typedef struct { char essid[36]; unsigned char mac1[6]; unsigned char mac2[6]; unsigned char nonce1[32]; unsigned char nonce2[32]; unsigned char eapol[256]; int eapol_size; int keyver; unsigned char keymic[16]; } hccap_t; // Docs: https://hashcat.net/wiki/doku.php?id=hccapx #define HCCAPX_SIGNATURE 0x58504348 // HCPX #define HCCAPX_CURRENT_VERSION 4 // https://hashcat.net/wiki/doku.php?id=hccapx typedef struct hccapx { uint32_t signature; /* signature (file magic) of .hccapx files, it is always the string HCPX */ uint32_t version; /* version number of the .hccapx file format */ uint8_t message_pair; /* possible values range from 0 to 5 or 128 to 133 */ /* message_pair was extended with some additional information: the highest * bit could be used * to indicate if the message pair matching was done based on replay counter * or not. Whenever * the highest bit (bit 8) was set to 1 it means that the replay counter was * ignored (i.e. it * was not considered at all by the matching algorithm): * * .----------------------------------------------------------------------------------------------------------------------------. * | message_pair (hex) | message_pair (dec) | Highest bit | Meaning | * .----------------------------------------------------------------------------------------------------------------------------. * | 0x00 to 0x05 | 0 to 5 | 0 | Message pair * according to table below with replay counter matching | * | 0x80 to 0x85 | 128 to 133 | 1 | Message pair * according to table below, replay counter was ignored | * .----------------------------------------------------------------------------------------------------------------------------. * * The message_pair value describes which messages of the 4-way handshake were * combined to form the * .hccapx structure. It is always a pair of 2 messages: 1 from the AP (access * point) and 1 from the STA (client). * * Furthermore, the message_pair value also gives a hint from which of the 2 * messages the EAPOL origins. * This is interesting data, but not necessarily needed for hashcat to be able * to crack the hash. * * On the other hand, it could be very important to know if "only" message 1 * and message 2 were captured * or if for instance message 3 and/or message 4 were captured too. If message * 3 and/or message 4 were captured * it should be a hard evidence that the connection was established and that * the password the client used was the * correct one. * * The following table lists all values currently allowed for the message_pair * field: * * .----------------------------------------------------------------------------------------------------------------------------. * | message_pair value | Messages of the handshake | Source of the EAPOL | AP * message | STA message | Replay counter matching | * .----------------------------------------------------------------------------------------------------------------------------. * | 0 | M1 + M2 | M2 | M1 * | M2 | Yes | * | 1 | M1 + M4 | M4 | M1 * | M4 | Yes | * | 2 | M2 + M3 | M2 | M3 * | M2 | Yes | * | 3 | M2 + M3 | M3 | M3 * | M2 | Yes | * | 4 | M3 + M4 | M3 | M3 * | M4 | Yes | * | 5 | M3 + M4 | M4 | M3 * | M4 | Yes | * | 128 | M1 + M2 | M2 | M1 * | M2 | No | * | 129 | M1 + M4 | M4 | M1 * | M4 | No | * | 130 | M2 + M3 | M2 | M3 * | M2 | No | * | 131 | M2 + M3 | M3 | M3 * | M2 | No | * | 132 | M3 + M4 | M3 | M3 * | M4 | No | * | 133 | M3 + M4 | M4 | M3 * | M4 | No | * .----------------------------------------------------------------------------------------------------------------------------. * * Note: M1 means message 1 of the handshake, M2 means message 2 of the * handshake, M3 means message 3 of * the handshake and M4 means message 4 of the 4-way handshake */ uint8_t essid_len; /* length of the network name (ESSID) */ uint8_t essid[32]; /* ESSID */ uint8_t keyver; /* set to 1 if WPA is used, other values (preferably 2) means WPA2 */ uint8_t keymic[16]; /* the actual hash value (MD5 for WPA, SHA1 for WPA2) truncated to 128 bit (16 bytes) */ uint8_t mac_ap[6]; /* BSSID */ uint8_t nonce_ap[32]; /* nonce (random salt) generated by the access point */ uint8_t mac_sta[6]; /* mac address of the client connecting to the access point */ uint8_t nonce_sta[32]; /* nonce (random salt) generated by the client connecting to the access point */ uint16_t eapol_len; /* length of the EAPOL */ uint8_t eapol[256]; /* EAPOL (max 256 bytes) */ } __attribute__((packed)) hccapx_t; #endif aircrack-ng-1.6/include/aircrack-ng/third-party/ieee80211.h000066400000000000000000000534471361312141100232760ustar00rootroot00000000000000/* $NetBSD: ieee80211.h,v 1.26 2013/03/30 14:14:31 christos Exp $ */ /*- * Copyright (c) 2001 Atsushi Onoe * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * Alternatively, this software may be distributed under the terms of the * GNU General Public License ("GPL") version 2 as published by the Free * Software Foundation. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/net80211/ieee80211.h,v 1.10 2005/07/22 16:55:27 sam Exp $ */ #ifndef _NET80211_IEEE80211_H_ #define _NET80211_IEEE80211_H_ /* * 802.11 protocol definitions. */ #define IEEE80211_ADDR_LEN 6 /* size of 802.11 address */ /* is 802.11 address multicast/broadcast? */ #define IEEE80211_IS_MULTICAST(_a) (*(_a) & 0x01) /* IEEE 802.11 PLCP header */ struct ieee80211_plcp_hdr { u_int16_t i_sfd; u_int8_t i_signal; u_int8_t i_service; u_int16_t i_length; u_int16_t i_crc; } __packed; #define IEEE80211_PLCP_SFD 0xF3A0 #define IEEE80211_PLCP_SERVICE 0x00 /* * generic definitions for IEEE 802.11 frames */ struct ieee80211_frame { u_int8_t i_fc[2]; u_int8_t i_dur[2]; u_int8_t i_addr1[IEEE80211_ADDR_LEN]; u_int8_t i_addr2[IEEE80211_ADDR_LEN]; u_int8_t i_addr3[IEEE80211_ADDR_LEN]; u_int8_t i_seq[2]; /* possibly followed by addr4[IEEE80211_ADDR_LEN]; */ /* see below */ } __packed; struct ieee80211_qosframe { u_int8_t i_fc[2]; u_int8_t i_dur[2]; u_int8_t i_addr1[IEEE80211_ADDR_LEN]; u_int8_t i_addr2[IEEE80211_ADDR_LEN]; u_int8_t i_addr3[IEEE80211_ADDR_LEN]; u_int8_t i_seq[2]; u_int8_t i_qos[2]; /* possibly followed by addr4[IEEE80211_ADDR_LEN]; */ /* see below */ } __packed; struct ieee80211_qoscntl { u_int8_t i_qos[2]; }; struct ieee80211_frame_addr4 { u_int8_t i_fc[2]; u_int8_t i_dur[2]; u_int8_t i_addr1[IEEE80211_ADDR_LEN]; u_int8_t i_addr2[IEEE80211_ADDR_LEN]; u_int8_t i_addr3[IEEE80211_ADDR_LEN]; u_int8_t i_seq[2]; u_int8_t i_addr4[IEEE80211_ADDR_LEN]; } __packed; struct ieee80211_qosframe_addr4 { u_int8_t i_fc[2]; u_int8_t i_dur[2]; u_int8_t i_addr1[IEEE80211_ADDR_LEN]; u_int8_t i_addr2[IEEE80211_ADDR_LEN]; u_int8_t i_addr3[IEEE80211_ADDR_LEN]; u_int8_t i_seq[2]; u_int8_t i_addr4[IEEE80211_ADDR_LEN]; u_int8_t i_qos[2]; } __packed; #define IEEE80211_FC0_VERSION_MASK 0x03 #define IEEE80211_FC0_VERSION_SHIFT 0 #define IEEE80211_FC0_VERSION_0 0x00 #define IEEE80211_FC0_TYPE_MASK 0x0c #define IEEE80211_FC0_TYPE_SHIFT 2 #define IEEE80211_FC0_TYPE_MGT 0x00 #define IEEE80211_FC0_TYPE_CTL 0x04 #define IEEE80211_FC0_TYPE_DATA 0x08 #define IEEE80211_FC0_SUBTYPE_MASK 0xf0 #define IEEE80211_FC0_SUBTYPE_SHIFT 4 /* for TYPE_MGT */ #define IEEE80211_FC0_SUBTYPE_ASSOC_REQ 0x00 #define IEEE80211_FC0_SUBTYPE_ASSOC_RESP 0x10 #define IEEE80211_FC0_SUBTYPE_REASSOC_REQ 0x20 #define IEEE80211_FC0_SUBTYPE_REASSOC_RESP 0x30 #define IEEE80211_FC0_SUBTYPE_PROBE_REQ 0x40 #define IEEE80211_FC0_SUBTYPE_PROBE_RESP 0x50 #define IEEE80211_FC0_SUBTYPE_BEACON 0x80 #define IEEE80211_FC0_SUBTYPE_ATIM 0x90 #define IEEE80211_FC0_SUBTYPE_DISASSOC 0xa0 #define IEEE80211_FC0_SUBTYPE_AUTH 0xb0 #define IEEE80211_FC0_SUBTYPE_DEAUTH 0xc0 /* for TYPE_CTL */ #define IEEE80211_FC0_SUBTYPE_PS_POLL 0xa0 #define IEEE80211_FC0_SUBTYPE_RTS 0xb0 #define IEEE80211_FC0_SUBTYPE_CTS 0xc0 #define IEEE80211_FC0_SUBTYPE_ACK 0xd0 #define IEEE80211_FC0_SUBTYPE_CF_END 0xe0 #define IEEE80211_FC0_SUBTYPE_CF_END_ACK 0xf0 /* for TYPE_DATA (bit combination) */ #define IEEE80211_FC0_SUBTYPE_DATA 0x00 #define IEEE80211_FC0_SUBTYPE_CF_ACK 0x10 #define IEEE80211_FC0_SUBTYPE_CF_POLL 0x20 #define IEEE80211_FC0_SUBTYPE_CF_ACPL 0x30 #define IEEE80211_FC0_SUBTYPE_NODATA 0x40 #define IEEE80211_FC0_SUBTYPE_CFACK 0x50 #define IEEE80211_FC0_SUBTYPE_CFPOLL 0x60 #define IEEE80211_FC0_SUBTYPE_CF_ACK_CF_ACK 0x70 #define IEEE80211_FC0_SUBTYPE_QOS 0x80 #define IEEE80211_FC0_SUBTYPE_QOS_NULL 0xc0 /* * DS bit usage * * TA = transmitter address * RA = receiver address * DA = destination address * SA = source address * * ToDS FromDS A1(RA) A2(TA) A3 A4 Use * ----------------------------------------------------------------- * 0 0 DA SA BSSID - IBSS/DLS * 0 1 DA BSSID SA - AP -> STA * 1 0 BSSID SA DA - AP <- STA * 1 1 RA TA DA SA unspecified (WDS) */ #define IEEE80211_FC1_DIR_MASK 0x03 #define IEEE80211_FC1_DIR_NODS 0x00 /* STA->STA */ #define IEEE80211_FC1_DIR_TODS 0x01 /* STA->AP */ #define IEEE80211_FC1_DIR_FROMDS 0x02 /* AP ->STA */ #define IEEE80211_FC1_DIR_DSTODS 0x03 /* AP ->AP */ #define IEEE80211_FC1_MORE_FRAG 0x04 #define IEEE80211_FC1_RETRY 0x08 #define IEEE80211_FC1_PWR_MGT 0x10 #define IEEE80211_FC1_MORE_DATA 0x20 #define IEEE80211_FC1_PROTECTED 0x40 #define IEEE80211_FC1_WEP 0x40 /* pre-RSNA compat */ #define IEEE80211_FC1_ORDER 0x80 #define IEEE80211_SEQ_FRAG_MASK 0x000f #define IEEE80211_SEQ_FRAG_SHIFT 0 #define IEEE80211_SEQ_SEQ_MASK 0xfff0 #define IEEE80211_SEQ_SEQ_SHIFT 4 #define IEEE80211_NWID_LEN 32 /* * QoS Control field (see 7.1.3.5). */ /* bit 8 is reserved */ #define IEEE80211_QOS_TXOP 0xff00 #define IEEE80211_QOS_AMSDU 0x0080 /* 11n */ #define IEEE80211_QOS_ACKPOLICY_NORMAL 0x0000 #define IEEE80211_QOS_ACKPOLICY_NOACK 0x0020 #define IEEE80211_QOS_ACKPOLICY_NOEXPLACK 0x0040 #define IEEE80211_QOS_ACKPOLICY 0x0060 #define IEEE80211_QOS_ACKPOLICY_S 5 #define IEEE80211_QOS_ACKPOLICY_MASK 0x0060 #define IEEE80211_QOS_ACKPOLICY_BA 0x0060 #define IEEE80211_QOS_ESOP 0x0010 #define IEEE80211_QOS_ESOP_S 4 #define IEEE80211_QOS_TID 0x000f /* * WME/802.11e information element. */ struct ieee80211_wme_info { u_int8_t wme_id; /* IEEE80211_ELEMID_VENDOR */ u_int8_t wme_len; /* length in bytes */ u_int8_t wme_oui[3]; /* 0x00, 0x50, 0xf2 */ u_int8_t wme_type; /* OUI type */ u_int8_t wme_subtype; /* OUI subtype */ u_int8_t wme_version; /* spec revision */ u_int8_t wme_info; /* QoS info */ } __packed; /* * WME/802.11e Tspec Element */ struct ieee80211_wme_tspec { u_int8_t ts_id; u_int8_t ts_len; u_int8_t ts_oui[3]; u_int8_t ts_oui_type; u_int8_t ts_oui_subtype; u_int8_t ts_version; u_int8_t ts_tsinfo[3]; u_int8_t ts_nom_msdu[2]; u_int8_t ts_max_msdu[2]; u_int8_t ts_min_svc[4]; u_int8_t ts_max_svc[4]; u_int8_t ts_inactv_intv[4]; u_int8_t ts_susp_intv[4]; u_int8_t ts_start_svc[4]; u_int8_t ts_min_rate[4]; u_int8_t ts_mean_rate[4]; u_int8_t ts_max_burst[4]; u_int8_t ts_min_phy[4]; u_int8_t ts_peak_rate[4]; u_int8_t ts_delay[4]; u_int8_t ts_surplus[2]; u_int8_t ts_medium_time[2]; } __packed; /* * WME AC parameter field */ struct ieee80211_wme_acparams { u_int8_t acp_aci_aifsn; u_int8_t acp_logcwminmax; u_int16_t acp_txop; } __packed; /* WME stream classes */ enum ieee80211_wme_ac { WME_AC_BE = 0, /* best effort */ WME_AC_BK = 1, /* background */ WME_AC_VI = 2, /* video */ WME_AC_VO = 3, /* voice */ }; #define WME_NUM_AC 4 /* 4 AC categories */ #define WME_PARAM_ACI 0x60 /* Mask for ACI field */ #define WME_PARAM_ACI_S 5 /* Shift for ACI field */ #define WME_PARAM_ACM 0x10 /* Mask for ACM bit */ #define WME_PARAM_ACM_S 4 /* Shift for ACM bit */ #define WME_PARAM_AIFSN 0x0f /* Mask for aifsn field */ #define WME_PARAM_AIFSN_S 0 /* Shift for aifsn field */ #define WME_PARAM_LOGCWMIN 0x0f /* Mask for CwMin field (in log) */ #define WME_PARAM_LOGCWMIN_S 0 /* Shift for CwMin field */ #define WME_PARAM_LOGCWMAX 0xf0 /* Mask for CwMax field (in log) */ #define WME_PARAM_LOGCWMAX_S 4 /* Shift for CwMax field */ #define WME_AC_TO_TID(_ac) ( \ ((_ac) == WME_AC_VO) ? 6 : \ ((_ac) == WME_AC_VI) ? 5 : \ ((_ac) == WME_AC_BK) ? 1 : \ 0) #define TID_TO_WME_AC(_tid) ( \ ((_tid) < 1) ? WME_AC_BE : \ ((_tid) < 3) ? WME_AC_BK : \ ((_tid) < 6) ? WME_AC_VI : \ WME_AC_VO) /* * WME Parameter Element */ struct ieee80211_wme_param { u_int8_t param_id; u_int8_t param_len; u_int8_t param_oui[3]; u_int8_t param_oui_type; u_int8_t param_oui_sybtype; u_int8_t param_version; u_int8_t param_qosInfo; #define WME_QOSINFO_COUNT 0x0f /* Mask for param count field */ u_int8_t param_reserved; struct ieee80211_wme_acparams params_acParams[WME_NUM_AC]; } __packed; /* * Management Notification Frame */ struct ieee80211_mnf { u_int8_t mnf_category; u_int8_t mnf_action; u_int8_t mnf_dialog; u_int8_t mnf_status; } __packed; #define MNF_SETUP_REQ 0 #define MNF_SETUP_RESP 1 #define MNF_TEARDOWN 2 /* * Control frames. */ struct ieee80211_frame_min { u_int8_t i_fc[2]; u_int8_t i_dur[2]; u_int8_t i_addr1[IEEE80211_ADDR_LEN]; u_int8_t i_addr2[IEEE80211_ADDR_LEN]; /* FCS */ } __packed; struct ieee80211_frame_rts { u_int8_t i_fc[2]; u_int8_t i_dur[2]; u_int8_t i_ra[IEEE80211_ADDR_LEN]; u_int8_t i_ta[IEEE80211_ADDR_LEN]; /* FCS */ } __packed; struct ieee80211_frame_cts { u_int8_t i_fc[2]; u_int8_t i_dur[2]; u_int8_t i_ra[IEEE80211_ADDR_LEN]; /* FCS */ } __packed; struct ieee80211_frame_ack { u_int8_t i_fc[2]; u_int8_t i_dur[2]; u_int8_t i_ra[IEEE80211_ADDR_LEN]; /* FCS */ } __packed; struct ieee80211_frame_pspoll { u_int8_t i_fc[2]; u_int8_t i_aid[2]; u_int8_t i_bssid[IEEE80211_ADDR_LEN]; u_int8_t i_ta[IEEE80211_ADDR_LEN]; /* FCS */ } __packed; struct ieee80211_frame_cfend { /* NB: also CF-End+CF-Ack */ u_int8_t i_fc[2]; u_int8_t i_dur[2]; /* should be zero */ u_int8_t i_ra[IEEE80211_ADDR_LEN]; u_int8_t i_bssid[IEEE80211_ADDR_LEN]; /* FCS */ } __packed; static __inline int ieee80211_has_seq(const struct ieee80211_frame *wh) { return (wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) != IEEE80211_FC0_TYPE_CTL; } static __inline int ieee80211_has_addr4(const struct ieee80211_frame *wh) { return (wh->i_fc[1] & IEEE80211_FC1_DIR_MASK) == IEEE80211_FC1_DIR_DSTODS; } static __inline int ieee80211_has_qos(const struct ieee80211_frame *wh) { return (wh->i_fc[0] & (IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_QOS)) == (IEEE80211_FC0_TYPE_DATA | IEEE80211_FC0_SUBTYPE_QOS); } static __inline int ieee80211_has_htc(const struct ieee80211_frame *wh) { return (wh->i_fc[1] & IEEE80211_FC1_ORDER) && (ieee80211_has_qos(wh) || (wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) == IEEE80211_FC0_TYPE_MGT); } static __inline u_int16_t ieee80211_get_qos(const struct ieee80211_frame *wh) { const u_int8_t *frm; if (ieee80211_has_addr4(wh)) frm = ((const struct ieee80211_qosframe_addr4 *)wh)->i_qos; else frm = ((const struct ieee80211_qosframe *)wh)->i_qos; return le16toh(*(const u_int16_t *)frm); } /* * BEACON management packets * * octet timestamp[8] * octet beacon interval[2] * octet capability information[2] * information element * octet elemid * octet length * octet information[length] */ typedef u_int8_t *ieee80211_mgt_beacon_t; #define IEEE80211_BEACON_INTERVAL(beacon) \ ((beacon)[8] | ((beacon)[9] << 8)) #define IEEE80211_BEACON_CAPABILITY(beacon) \ ((beacon)[10] | ((beacon)[11] << 8)) #define IEEE80211_CAPINFO_ESS 0x0001 #define IEEE80211_CAPINFO_IBSS 0x0002 #define IEEE80211_CAPINFO_CF_POLLABLE 0x0004 #define IEEE80211_CAPINFO_CF_POLLREQ 0x0008 #define IEEE80211_CAPINFO_PRIVACY 0x0010 #define IEEE80211_CAPINFO_SHORT_PREAMBLE 0x0020 #define IEEE80211_CAPINFO_PBCC 0x0040 #define IEEE80211_CAPINFO_CHNL_AGILITY 0x0080 /* bits 8-9 are reserved */ #define IEEE80211_CAPINFO_SHORT_SLOTTIME 0x0400 #define IEEE80211_CAPINFO_RSN 0x0800 /* bit 12 is reserved */ #define IEEE80211_CAPINFO_DSSSOFDM 0x2000 /* bits 14-15 are reserved */ /* * 802.11i/WPA information element (maximally sized). */ struct ieee80211_ie_wpa { u_int8_t wpa_id; /* IEEE80211_ELEMID_VENDOR */ u_int8_t wpa_len; /* length in bytes */ u_int8_t wpa_oui[3]; /* 0x00, 0x50, 0xf2 */ u_int8_t wpa_type; /* OUI type */ u_int16_t wpa_version; /* spec revision */ u_int32_t wpa_mcipher[1]; /* multicast/group key cipher */ u_int16_t wpa_uciphercnt; /* # pairwise key ciphers */ u_int32_t wpa_uciphers[8];/* ciphers */ u_int16_t wpa_authselcnt; /* authentication selector cnt*/ u_int32_t wpa_authsels[8];/* selectors */ u_int16_t wpa_caps; /* 802.11i capabilities */ u_int16_t wpa_pmkidcnt; /* 802.11i pmkid count */ u_int16_t wpa_pmkids[8]; /* 802.11i pmkids */ } __packed; /* * Management information element payloads. */ enum { IEEE80211_ELEMID_SSID = 0, IEEE80211_ELEMID_RATES = 1, IEEE80211_ELEMID_FHPARMS = 2, IEEE80211_ELEMID_DSPARMS = 3, IEEE80211_ELEMID_CFPARMS = 4, IEEE80211_ELEMID_TIM = 5, IEEE80211_ELEMID_IBSSPARMS = 6, IEEE80211_ELEMID_COUNTRY = 7, IEEE80211_ELEMID_EDCAPARMS = 12, IEEE80211_ELEMID_CHALLENGE = 16, /* 17-31 reserved for challenge text extension */ IEEE80211_ELEMID_PWRCNSTR = 32, IEEE80211_ELEMID_PWRCAP = 33, IEEE80211_ELEMID_TPCREQ = 34, IEEE80211_ELEMID_TPCREP = 35, IEEE80211_ELEMID_SUPPCHAN = 36, IEEE80211_ELEMID_CHANSWITCHANN = 37, IEEE80211_ELEMID_MEASREQ = 38, IEEE80211_ELEMID_MEASREP = 39, IEEE80211_ELEMID_QUIET = 40, IEEE80211_ELEMID_IBSSDFS = 41, IEEE80211_ELEMID_ERP = 42, IEEE80211_ELEMID_HTCAP = 45, /* 11n */ IEEE80211_ELEMID_QOS_CAP = 46, IEEE80211_ELEMID_RSN = 48, IEEE80211_ELEMID_XRATES = 50, IEEE80211_ELEMID_TIE = 56, /* 11r */ IEEE80211_ELEMID_HTINFO = 61, /* 11n */ IEEE80211_ELEMID_MMIE = 76, /* 11w */ IEEE80211_ELEMID_TPC = 150, IEEE80211_ELEMID_CCKM = 156, IEEE80211_ELEMID_VENDOR = 221 /* vendor private */ }; struct ieee80211_tim_ie { u_int8_t tim_ie; /* IEEE80211_ELEMID_TIM */ u_int8_t tim_len; u_int8_t tim_count; /* DTIM count */ u_int8_t tim_period; /* DTIM period */ u_int8_t tim_bitctl; /* bitmap control */ u_int8_t tim_bitmap[1]; /* variable-length bitmap */ } __packed; struct ieee80211_band { u_int8_t schan; /* starting channel */ u_int8_t nchan; /* number channels */ u_int8_t maxtxpwr; /* tx power cap */ } __packed; struct ieee80211_country_ie { u_int8_t ie; /* IEEE80211_ELEMID_COUNTRY */ u_int8_t len; u_int8_t cc[3]; /* ISO CC+(I)ndoor/(O)utdoor */ struct ieee80211_band band[4]; /* up to 4 sub bands */ } __packed; #define IEEE80211_CHALLENGE_LEN 128 #define IEEE80211_RATE_BASIC 0x80 #define IEEE80211_RATE_VAL 0x7f /* EPR information element flags */ #define IEEE80211_ERP_NON_ERP_PRESENT 0x01 #define IEEE80211_ERP_USE_PROTECTION 0x02 #define IEEE80211_ERP_LONG_PREAMBLE 0x04 /* Atheros private advanced capabilities info */ #define ATHEROS_CAP_TURBO_PRIME 0x01 #define ATHEROS_CAP_COMPRESSION 0x02 #define ATHEROS_CAP_FAST_FRAME 0x04 /* bits 3-6 reserved */ #define ATHEROS_CAP_BOOST 0x80 #define ATH_OUI 0x7f0300 /* Atheros OUI */ #define ATH_OUI_TYPE 0x01 #define ATH_OUI_VERSION 0x01 #define WPA_OUI 0xf25000 #define WPA_OUI_TYPE 0x01 #define WPA_VERSION 1 /* current supported version */ #define WPA_CSE_NULL 0x00 #define WPA_CSE_WEP40 0x01 #define WPA_CSE_TKIP 0x02 #define WPA_CSE_CCMP 0x04 #define WPA_CSE_WEP104 0x05 #define WPA_ASE_NONE 0x00 #define WPA_ASE_8021X_UNSPEC 0x01 #define WPA_ASE_8021X_PSK 0x02 #define RSN_OUI 0xac0f00 #define RSN_VERSION 1 /* current supported version */ #define RSN_CSE_NULL 0x00 #define RSN_CSE_WEP40 0x01 #define RSN_CSE_TKIP 0x02 #define RSN_CSE_WRAP 0x03 #define RSN_CSE_CCMP 0x04 #define RSN_CSE_WEP104 0x05 #define RSN_ASE_NONE 0x00 #define RSN_ASE_8021X_UNSPEC 0x01 #define RSN_ASE_8021X_PSK 0x02 #define RSN_CAP_PREAUTH 0x01 #define WME_OUI 0xf25000 #define WME_OUI_TYPE 0x02 #define WME_INFO_OUI_SUBTYPE 0x00 #define WME_PARAM_OUI_SUBTYPE 0x01 #define WME_VERSION 1 /* * AUTH management packets * * octet algo[2] * octet seq[2] * octet status[2] * octet chal.id * octet chal.length * octet chal.text[253] */ typedef u_int8_t *ieee80211_mgt_auth_t; #define IEEE80211_AUTH_ALGORITHM(auth) \ ((auth)[0] | ((auth)[1] << 8)) #define IEEE80211_AUTH_TRANSACTION(auth) \ ((auth)[2] | ((auth)[3] << 8)) #define IEEE80211_AUTH_STATUS(auth) \ ((auth)[4] | ((auth)[5] << 8)) #define IEEE80211_AUTH_ALG_OPEN 0x0000 #define IEEE80211_AUTH_ALG_SHARED 0x0001 #define IEEE80211_AUTH_ALG_LEAP 0x0080 enum { IEEE80211_AUTH_OPEN_REQUEST = 1, IEEE80211_AUTH_OPEN_RESPONSE = 2 }; enum { IEEE80211_AUTH_SHARED_REQUEST = 1, IEEE80211_AUTH_SHARED_CHALLENGE = 2, IEEE80211_AUTH_SHARED_RESPONSE = 3, IEEE80211_AUTH_SHARED_PASS = 4 }; /* * Reason codes * * Unlisted codes are reserved */ enum { IEEE80211_REASON_UNSPECIFIED = 1, IEEE80211_REASON_AUTH_EXPIRE = 2, IEEE80211_REASON_AUTH_LEAVE = 3, IEEE80211_REASON_ASSOC_EXPIRE = 4, IEEE80211_REASON_ASSOC_TOOMANY = 5, IEEE80211_REASON_NOT_AUTHED = 6, IEEE80211_REASON_NOT_ASSOCED = 7, IEEE80211_REASON_ASSOC_LEAVE = 8, IEEE80211_REASON_ASSOC_NOT_AUTHED = 9, IEEE80211_REASON_RSN_REQUIRED = 11, IEEE80211_REASON_RSN_INCONSISTENT = 12, IEEE80211_REASON_IE_INVALID = 13, IEEE80211_REASON_MIC_FAILURE = 14, IEEE80211_STATUS_SUCCESS = 0, IEEE80211_STATUS_UNSPECIFIED = 1, IEEE80211_STATUS_CAPINFO = 10, IEEE80211_STATUS_NOT_ASSOCED = 11, IEEE80211_STATUS_OTHER = 12, IEEE80211_STATUS_ALG = 13, IEEE80211_STATUS_SEQUENCE = 14, IEEE80211_STATUS_CHALLENGE = 15, IEEE80211_STATUS_TIMEOUT = 16, IEEE80211_STATUS_TOOMANY = 17, IEEE80211_STATUS_BASIC_RATE = 18, IEEE80211_STATUS_SP_REQUIRED = 19, IEEE80211_STATUS_PBCC_REQUIRED = 20, IEEE80211_STATUS_CA_REQUIRED = 21, IEEE80211_STATUS_TOO_MANY_STATIONS = 22, IEEE80211_STATUS_RATES = 23, IEEE80211_STATUS_SHORTSLOT_REQUIRED = 25, IEEE80211_STATUS_DSSSOFDM_REQUIRED = 26 }; #define IEEE80211_WEP_KEYLEN 5 /* 40bit */ #define IEEE80211_WEP_IVLEN 3 /* 24bit */ #define IEEE80211_WEP_KIDLEN 1 /* 1 octet */ #define IEEE80211_WEP_CRCLEN 4 /* CRC-32 */ #define IEEE80211_WEP_TOTLEN (IEEE80211_WEP_IVLEN + \ IEEE80211_WEP_KIDLEN + \ IEEE80211_WEP_CRCLEN) #define IEEE80211_WEP_NKID 4 /* number of key ids */ /* * 802.11i defines an extended IV for use with non-WEP ciphers. * When the EXTIV bit is set in the key id byte an additional * 4 bytes immediately follow the IV for TKIP. For CCMP the * EXTIV bit is likewise set but the 8 bytes represent the * CCMP header rather than IV+extended-IV. */ #define IEEE80211_WEP_EXTIV 0x20 #define IEEE80211_WEP_EXTIVLEN 4 /* extended IV length */ #define IEEE80211_WEP_MICLEN 8 /* trailing MIC */ #define IEEE80211_CRC_LEN 4 /* * Maximum acceptable MTU is: * IEEE80211_MAX_LEN - WEP overhead - CRC - * QoS overhead - RSN/WPA overhead * Min is arbitrarily chosen > IEEE80211_MIN_LEN. The default * mtu is Ethernet-compatible; it's set by ether_ifattach. */ #define IEEE80211_MTU_MAX 2290 #define IEEE80211_MTU_MIN 32 #define IEEE80211_MAX_LEN (2300 + IEEE80211_CRC_LEN + \ (IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN + IEEE80211_WEP_CRCLEN)) #define IEEE80211_ACK_LEN \ (sizeof(struct ieee80211_frame_ack) + IEEE80211_CRC_LEN) #define IEEE80211_MIN_LEN \ (sizeof(struct ieee80211_frame_min) + IEEE80211_CRC_LEN) /* * The 802.11 spec says at most 2007 stations may be * associated at once. For most AP's this is way more * than is feasible so we use a default of 128. This * number may be overridden by the driver and/or by * user configuration. */ #define IEEE80211_AID_MAX 2007 #define IEEE80211_AID_DEF 128 #define IEEE80211_AID(b) ((b) &~ 0xc000) /* * RTS frame length parameters. The default is specified in * the 802.11 spec as 512; we treat it as implementation-dependent * so it's defined in ieee80211_var.h. The max may be wrong * for jumbo frames. */ #define IEEE80211_RTS_MIN 1 #define IEEE80211_RTS_MAX 2346 /* * TX fragmentation parameters. As above for RTS, we treat * default as implementation-dependent so define it elsewhere. */ #define IEEE80211_FRAG_MIN 256 #define IEEE80211_FRAG_MAX 2346 /* * 802.11 frame duration definitions. */ struct ieee80211_duration { uint16_t d_rts_dur; uint16_t d_data_dur; uint16_t d_plcp_len; uint8_t d_residue; /* unused octets in time slot */ }; /* One Time Unit (TU) is 1Kus = 1024 microseconds. */ #define IEEE80211_DUR_TU 1024 /* IEEE 802.11b durations for DSSS PHY in microseconds */ #define IEEE80211_DUR_DS_LONG_PREAMBLE 144 #define IEEE80211_DUR_DS_SHORT_PREAMBLE 72 #define IEEE80211_DUR_DS_SLOW_PLCPHDR 48 #define IEEE80211_DUR_DS_FAST_PLCPHDR 24 #define IEEE80211_DUR_DS_SLOW_ACK 112 #define IEEE80211_DUR_DS_FAST_ACK 56 #define IEEE80211_DUR_DS_SLOW_CTS 112 #define IEEE80211_DUR_DS_FAST_CTS 56 #define IEEE80211_DUR_DS_SLOT 20 #define IEEE80211_DUR_DS_SIFS 10 #define IEEE80211_DUR_DS_PIFS (IEEE80211_DUR_DS_SIFS + IEEE80211_DUR_DS_SLOT) #define IEEE80211_DUR_DS_DIFS (IEEE80211_DUR_DS_SIFS + \ 2 * IEEE80211_DUR_DS_SLOT) #define IEEE80211_DUR_DS_EIFS (IEEE80211_DUR_DS_SIFS + \ IEEE80211_DUR_DS_SLOW_ACK + \ IEEE80211_DUR_DS_LONG_PREAMBLE + \ IEEE80211_DUR_DS_SLOW_PLCPHDR + \ IEEE80211_DUR_DS_DIFS) #endif /* !_NET80211_IEEE80211_H_ */ aircrack-ng-1.6/include/aircrack-ng/third-party/if_arp.h000066400000000000000000000133331361312141100232210ustar00rootroot00000000000000/*- * Copyright (c) 1986, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)if_arp.h 8.1 (Berkeley) 6/10/93 * $FreeBSD$ */ #ifndef _NET_IF_ARP_H_ #define _NET_IF_ARP_H_ /* * Address Resolution Protocol. * * See RFC 826 for protocol description. ARP packets are variable * in size; the arphdr structure defines the fixed-length portion. * Protocol type values are the same as those for 10 Mb/s Ethernet. * It is followed by the variable-sized fields ar_sha, arp_spa, * arp_tha and arp_tpa in that order, according to the lengths * specified. Field names used correspond to RFC 826. */ struct arphdr { u_short ar_hrd; /* format of hardware address */ #define ARPHRD_ETHER 1 /* ethernet hardware format */ #define ARPHRD_IEEE802 6 /* token-ring hardware format */ #define ARPHRD_ARCNET 7 /* arcnet hardware format */ #define ARPHRD_FRELAY 15 /* frame relay hardware format */ #define ARPHRD_IEEE1394 24 /* firewire hardware format */ #define ARPHRD_INFINIBAND 32 /* infiniband hardware format */ u_short ar_pro; /* format of protocol address */ u_char ar_hln; /* length of hardware address */ u_char ar_pln; /* length of protocol address */ u_short ar_op; /* one of: */ #define ARPOP_REQUEST 1 /* request to resolve address */ #define ARPOP_REPLY 2 /* response to previous request */ #define ARPOP_REVREQUEST 3 /* request protocol address given hardware */ #define ARPOP_REVREPLY 4 /* response giving protocol address */ #define ARPOP_INVREQUEST 8 /* request to identify peer */ #define ARPOP_INVREPLY 9 /* response identifying peer */ /* * The remaining fields are variable in size, * according to the sizes above. */ #ifdef COMMENT_ONLY u_char ar_sha[]; /* sender hardware address */ u_char ar_spa[]; /* sender protocol address */ u_char ar_tha[]; /* target hardware address */ u_char ar_tpa[]; /* target protocol address */ #endif }; #define ar_sha(ap) (((caddr_t)((ap)+1)) + 0) #define ar_spa(ap) (((caddr_t)((ap)+1)) + (ap)->ar_hln) #define ar_tha(ap) (((caddr_t)((ap)+1)) + (ap)->ar_hln + (ap)->ar_pln) #define ar_tpa(ap) (((caddr_t)((ap)+1)) + 2*(ap)->ar_hln + (ap)->ar_pln) #define arphdr_len2(ar_hln, ar_pln) \ (sizeof(struct arphdr) + 2*(ar_hln) + 2*(ar_pln)) #define arphdr_len(ap) (arphdr_len2((ap)->ar_hln, (ap)->ar_pln)) /* * ARP ioctl request */ struct arpreq { struct sockaddr arp_pa; /* protocol address */ struct sockaddr arp_ha; /* hardware address */ int arp_flags; /* flags */ }; /* arp_flags and at_flags field values */ #define ATF_INUSE 0x01 /* entry in use */ #define ATF_COM 0x02 /* completed entry (enaddr valid) */ #define ATF_PERM 0x04 /* permanent entry */ #define ATF_PUBL 0x08 /* publish entry (respond for other host) */ #define ATF_USETRAILERS 0x10 /* has requested trailers */ #ifdef _KERNEL /* * Structure shared between the ethernet driver modules and * the address resolution code. */ struct arpcom { struct ifnet *ac_ifp; /* network-visible interface */ void *ac_netgraph; /* ng_ether(4) netgraph node info */ }; #define IFP2AC(ifp) ((struct arpcom *)(ifp->if_l2com)) #define AC2IFP(ac) ((ac)->ac_ifp) #endif /* _KERNEL */ struct arpstat { /* Normal things that happen: */ uint64_t txrequests; /* # of ARP requests sent by this host. */ uint64_t txreplies; /* # of ARP replies sent by this host. */ uint64_t rxrequests; /* # of ARP requests received by this host. */ uint64_t rxreplies; /* # of ARP replies received by this host. */ uint64_t received; /* # of ARP packets received by this host. */ uint64_t arp_spares[4]; /* For either the upper or lower half. */ /* Abnormal event and error counting: */ uint64_t dropped; /* # of packets dropped waiting for a reply. */ uint64_t timeouts; /* # of times with entries removed */ /* due to timeout. */ uint64_t dupips; /* # of duplicate IPs detected. */ }; #ifdef _KERNEL #include #include VNET_PCPUSTAT_DECLARE(struct arpstat, arpstat); /* * In-kernel consumers can use these accessor macros directly to update * stats. */ #define ARPSTAT_ADD(name, val) \ VNET_PCPUSTAT_ADD(struct arpstat, arpstat, name, (val)) #define ARPSTAT_SUB(name, val) ARPSTAT_ADD(name, -(val)) #define ARPSTAT_INC(name) ARPSTAT_ADD(name, 1) #define ARPSTAT_DEC(name) ARPSTAT_SUB(name, 1) #endif /* _KERNEL */ #endif /* !_NET_IF_ARP_H_ */ aircrack-ng-1.6/include/aircrack-ng/third-party/if_llc.h000066400000000000000000000113251361312141100232100ustar00rootroot00000000000000/* $NetBSD: if_llc.h,v 1.21 2014/09/05 05:32:07 matt Exp $ */ /* * Copyright (c) 1988, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)if_llc.h 8.1 (Berkeley) 6/10/93 */ #ifndef _NET_IF_LLC_H_ #define _NET_IF_LLC_H_ /* * IEEE 802.2 Link Level Control headers, for use in conjunction with * 802.{3,4,5} media access control methods. * * Headers here do not use bit fields due to shortcommings in many * compilers. */ struct llc { uint8_t llc_dsap; uint8_t llc_ssap; union { struct { uint8_t control; uint8_t format_id; uint8_t class_u; uint8_t window_x2; } type_u /* XXX __packed ??? */; struct { uint8_t num_snd_x2; uint8_t num_rcv_x2; } type_i /* XXX __packed ??? */; struct { uint8_t control; uint8_t num_rcv_x2; } type_s /* XXX __packed ??? */; struct { uint8_t control; /* * We cannot put the following fields in a structure because * the structure rounding might cause padding. */ uint8_t frmr_rej_pdu0; uint8_t frmr_rej_pdu1; uint8_t frmr_control; uint8_t frmr_control_ext; uint8_t frmr_cause; } type_frmr /* XXX __packed ??? */; struct { uint8_t control; uint8_t org_code[3]; uint16_t ether_type; } type_snap __packed; struct { uint8_t control; uint8_t control_ext; } type_raw /* XXX __packed ??? */; } llc_un /* XXX __packed ??? */; } __packed; struct frmrinfo { uint8_t frmr_rej_pdu0; uint8_t frmr_rej_pdu1; uint8_t frmr_control; uint8_t frmr_control_ext; uint8_t frmr_cause; } __packed; #define llc_control llc_un.type_u.control #define llc_control_ext llc_un.type_raw.control_ext #define llc_fid llc_un.type_u.format_id #define llc_class llc_un.type_u.class_u #define llc_window llc_un.type_u.window_x2 #define llc_frmrinfo llc_un.type_frmr.frmr_rej_pdu0 #define llc_frmr_pdu0 llc_un.type_frmr.frmr_rej_pdu0 #define llc_frmr_pdu1 llc_un.type_frmr.frmr_rej_pdu1 #define llc_frmr_control llc_un.type_frmr.frmr_control #define llc_frmr_control_ext llc_un.type_frmr.frmr_control_ext #define llc_frmr_cause llc_un.type_frmr.frmr_cause #define llc_snap llc_un.type_snap /* * Don't use sizeof(struct llc_un) for LLC header sizes */ #define LLC_ISFRAMELEN 4 #define LLC_UFRAMELEN 3 #define LLC_FRMRLEN 7 #define LLC_SNAPFRAMELEN 8 /* * Unnumbered LLC format commands */ #define LLC_UI 0x3 #define LLC_UI_P 0x13 #define LLC_DISC 0x43 #define LLC_DISC_P 0x53 #define LLC_UA 0x63 #define LLC_UA_P 0x73 #define LLC_TEST 0xe3 #define LLC_TEST_P 0xf3 #define LLC_FRMR 0x87 #define LLC_FRMR_P 0x97 #define LLC_DM 0x0f #define LLC_DM_P 0x1f #define LLC_XID 0xaf #define LLC_XID_P 0xbf #define LLC_SABME 0x6f #define LLC_SABME_P 0x7f /* * Supervisory LLC commands */ #define LLC_RR 0x01 #define LLC_RNR 0x05 #define LLC_REJ 0x09 /* * Info format - dummy only */ #define LLC_INFO 0x00 /* * ISO PDTR 10178 contains among others */ #define LLC_8021D_LSAP 0x42 #define LLC_X25_LSAP 0x7e #define LLC_SNAP_LSAP 0xaa #define LLC_ISO_LSAP 0xfe /* * LLC XID definitions from 802.2, as needed */ #define LLC_XID_FORMAT_BASIC 0x81 #define LLC_XID_BASIC_MINLEN (LLC_UFRAMELEN + 3) #define LLC_XID_CLASS_I 0x1 #define LLC_XID_CLASS_II 0x3 #define LLC_XID_CLASS_III 0x5 #define LLC_XID_CLASS_IV 0x7 #endif /* !_NET_IF_LLC_H_ */ aircrack-ng-1.6/include/aircrack-ng/tui/000077500000000000000000000000001361312141100201375ustar00rootroot00000000000000aircrack-ng-1.6/include/aircrack-ng/tui/console.h000066400000000000000000000111731361312141100217550ustar00rootroot00000000000000/* * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * is provided AS IS, WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and * NON-INFRINGEMENT. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, * MA 02110-1301, USA. * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifndef AIRCRACK_NG_CONSOLE_H #define AIRCRACK_NG_CONSOLE_H /** * Styling attributes for \a textstyle function. */ #define TEXT_RESET 0 #define TEXT_BRIGHT 1 #define TEXT_DIM 2 #define TEXT_UNDERLINE 3 #define TEXT_BLINK 4 #define TEXT_REVERSE 7 #define TEXT_HIDDEN 8 #define TEXT_MAX_STYLE 8 /** * Color definitions for \a textcolor functions. */ #define TEXT_BLACK 0 #define TEXT_RED 1 #define TEXT_GREEN 2 #define TEXT_YELLOW 3 #define TEXT_BLUE 4 #define TEXT_MAGENTA 5 #define TEXT_CYAN 6 #define TEXT_WHITE 7 #define TEXT_MAX_COLOR 7 /** * Movement direction definitions for \a move function. */ #define CURSOR_UP 0 #define CURSOR_DOWN 1 #define CURSOR_FORWARD 2 #define CURSOR_BACK 3 /** * Character codes for common keyboard keys. */ #define KEY_TAB 0x09 #define KEY_ESCAPE 0x1B #define KEY_SPACE 0x20 #define KEY_ARROW_UP 0x41 #define KEY_ARROW_DOWN 0x42 #define KEY_ARROW_RIGHT 0x43 #define KEY_ARROW_LEFT 0x44 #define KEY_a 0x61 #define KEY_c 0x63 #define KEY_d 0x64 #define KEY_i 0x69 #define KEY_m 0x6D #define KEY_n 0x6E #define KEY_q 0x71 #define KEY_r 0x72 #define KEY_s 0x73 #define KEY_o 0x6F //color on #define KEY_p 0x70 //color off /// Changes the styling, foreground, and background /// character color, as shown in the user's terminal /// console. void textcolor(int attr, int fg, int bg); /// Changes the foreground character color, as shown in the /// user's terminal console. void textcolor_fg(int fg); /// Changes the background character color, as shown in the /// user's terminal console. void textcolor_bg(int bg); /// Switch to normal color or intensity, as shown in the /// user's terminal console. void textcolor_normal(void); /// Switches the styling applied to future written characters to /// the user's terminal console. void textstyle(int attr); /// Moves the cursor to specified column and row, 1-based. void moveto(int x, int y); /// Move the cursor a specified number of positions, in the specified /// direction. void move(int which, int n); /// \brief Erase a subset of the terminal console. /** * From Wikipedia: * * Clears part of the screen. If n {\displaystyle n} n is 0 (or missing), * clear from cursor to end of screen. If n {\displaystyle n} n is 1, * clear from cursor to beginning of the screen. If n {\displaystyle n} n * is 2, clear entire screen (and moves cursor to upper left on DOS * ANSI.SYS). If n {\displaystyle n} n is 3, clear entire screen and * delete all lines saved in the scrollback buffer (this feature was * added for xterm and is supported by other terminal applications). */ void erase_display(int n); /// \brief Erase part of the line; of the user's terminal console. void erase_line(int n); /// Hide the cursor within the terminal console. void hide_cursor(void); /// Show the cursor within the terminal console. void show_cursor(void); /// Reset the terminal console display back to a known working state. void reset_term(void); /// Wrapper around \a getch to avoid displaying the character on the terminal /// console. int mygetch(void); void console_utf8_enable(void); static inline void console_puts(const char * msg) { printf("%s", msg); erase_line(0); putchar('\n'); } #endif // AIRCRACK_NG_CONSOLE_H aircrack-ng-1.6/include/aircrack-ng/utf8/000077500000000000000000000000001361312141100202245ustar00rootroot00000000000000aircrack-ng-1.6/include/aircrack-ng/utf8/verifyssid.h000066400000000000000000000003511361312141100225630ustar00rootroot00000000000000#ifndef VERIFYSSID_H_INCLUDED #define VERIFYSSID_H_INCLUDED #include #ifdef __cplusplus extern "C" { #endif extern int verifyssid(const unsigned char * s); #ifdef __cplusplus }; #endif #endif // VERIFYSSID_H_INCLUDED aircrack-ng-1.6/include/aircrack-ng/version.h.in000066400000000000000000000037171361312141100216110ustar00rootroot00000000000000/* * (c) 2010-2020 Thomas d'Otreppe * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * is provided AS IS, WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and * NON-INFRINGEMENT. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, * MA 02110-1301, USA. * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. */ #define _MAJ @_MAJ@ #define _MIN @_MIN@ #define _SUB_MIN @_SUB_MIN@ #define _BETA @_BETA@ #define _RC @_RC@ #define _SCM "@_SCM@" #define LT_VER @LT_VER@ #define WEBSITE "https://aircrack-ng.org" extern char * getVersion(const char * progname, const unsigned int maj, const unsigned int min, const unsigned int submin, const char * rev, const unsigned int beta, const unsigned int rc); aircrack-ng-1.6/lib/000077500000000000000000000000001361312141100143005ustar00rootroot00000000000000aircrack-ng-1.6/lib/Makefile.inc000066400000000000000000000246601361312141100165200ustar00rootroot00000000000000# Aircrack-ng # # Copyright (C) 2019 Joseph Benden # # Autotool support was written by: Joseph Benden # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA # # In addition, as a special exception, the copyright holders give # permission to link the code of portions of this program with the # OpenSSL library under certain conditions as described in each # individual source file, and distribute linked combinations # including the two. # # You must obey the GNU General Public License in all respects # for all of the code used other than OpenSSL. # # If you modify file(s) with this exception, you may extend this # exception to your dnl version of the file(s), but you are not obligated # to do so. # # If you dnl do not wish to do so, delete this exception statement from your # version. # # If you delete this exception statement from all source files in the # program, then also delete it here. include %D%/osdep/Makefile.inc SRC_CE_WEP = %D%/ce-wep/uniqueiv.c SRC_CE_WPA = %D%/ce-wpa/crypto_engine.c \ %D%/ce-wpa/memory.c \ %D%/ce-wpa/simd-intrinsics.c \ %D%/ce-wpa/wpapsk.c SRC_COW = %D%/cowpatty/cowpatty.c SRC_CRYPTO = %D%/crypto/crypto.c SRC_PTW = %D%/ptw/aircrack-ptw-lib.c SRC_LIBAC = %D%/libac/adt/avl_tree.c \ %D%/libac/adt/circular_buffer.c \ %D%/libac/adt/circular_queue.c \ %D%/libac/cpu/simd_cpuid.c \ %D%/libac/support/fragments.c \ %D%/libac/support/common.c \ %D%/libac/support/communications.c \ %D%/libac/support/crypto_engine_loader.c \ %D%/libac/support/mcs_index_rates.c \ %D%/libac/tui/console.c \ %D%/libac/utf8/verifyssid.c SRC_RADIOTAP = %D%/radiotap/radiotap.c if LIBGCRYPT SRC_CRYPTO += %D%/crypto/sha1-git.c endif if X86 SRC_CRYPTO += %D%/crypto/sha1-sse2.S endif libaccrypto_la_SOURCES = $(SRC_CRYPTO) libaccrypto_la_CFLAGS = $(COMMON_CFLAGS) $(PCRE_CFLAGS) libaccrypto_la_LIBADD = $(PCRE_LIBS) $(LIBAIRCRACK_OSDEP_LIBS) $(CRYPTO_LIBS) libcowpatty_la_SOURCES = $(SRC_COW) libcowpatty_la_CFLAGS = $(COMMON_CFLAGS) $(LIBCOW_CFLAGS) if !STATIC_CRYPTO libcowpatty_la_LIBADD = $(COMMON_LDADD) endif libptw_la_SOURCES = $(SRC_PTW) libptw_la_CFLAGS = $(COMMON_CFLAGS) if !STATIC_CRYPTO libptw_la_LIBADD = $(COMMON_LDADD) endif libradiotap_la_SOURCES = $(SRC_RADIOTAP) libradiotap_la_LDFLAGS = -no-undefined ######################################################################## # Aircrack Support Library # ######################################################################## if ARM TRAMPOLINE = %D%/libac/cpu/trampoline_arm.c endif if PPC TRAMPOLINE = %D%/libac/cpu/trampoline_ppc.c endif if X86 TRAMPOLINE = %D%/libac/cpu/trampoline_x86.c endif if !ARM if !PPC if !X86 TRAMPOLINE = %D%/libac/cpu/trampoline_stubs.c endif endif endif if HAVE_HWLOC CPUSET = %D%/libac/cpu/cpuset_hwloc.c endif if !HAVE_HWLOC CPUSET = %D%/libac/cpu/cpuset_pthread.c endif libaircrack_la_SOURCES = $(SRC_LIBAC) $(TRAMPOLINE) $(CPUSET) libaircrack_la_CFLAGS = $(COMMON_CFLAGS) $(PCRE_CFLAGS) \ "-DLIBAIRCRACK_CE_WPA_PATH=\"$(LIBAIRCRACK_CE_WPA_PATH)\"" \ "-DABS_TOP_SRCDIR=\"$(abs_top_srcdir)\"" \ "-DABS_TOP_BUILDDIR=\"$(abs_top_builddir)\"" \ "-DLIBDIR=\"$(libdir)\"" libaircrack_la_LIBADD = $(COMMON_LDADD) $(LIBAIRCRACK_OSDEP_LIBS) $(PCRE_LIBS) $(CRYPTO_LIBS) if CYGWIN libaircrack_la_LIBADD += -lshlwapi endif if STATIC_BUILD libaircrack_la_CFLAGS += -DSTATIC_BUILD endif if HAVE_HWLOC libaircrack_la_CFLAGS += $(HWLOC_CFLAGS) if !CYGWIN if !STATIC_HWLOC libaircrack_la_LIBADD += $(HWLOC_LIBS) endif endif if CYGWIN if !STATIC_HWLOC libaircrack_la_LIBADD += $(HWLOC_LIBS) endif endif endif ######################################################################## # Aircrack Crypto Engine for WEP # ######################################################################## libaircrack_ce_wep_la_SOURCES = $(SRC_CE_WEP) libaircrack_ce_wep_la_CFLAGS = $(COMMON_CFLAGS) libaircrack_ce_wep_la_LIBADD = $(CRYPTO_LIBS) ######################################################################## # Aircrack Crypto Engine for WPA # ######################################################################## # Intel/AMD libaircrack_ce_wpa_x86_avx512_la_SOURCES = $(SRC_CE_WPA) libaircrack_ce_wpa_x86_avx512_la_CFLAGS = $(x86_avx512_cflags) -DSIMD_CORE -DJOHN_AVX512F $(PTHREAD_CFLAGS) $(CRYPTO_CFLAGS) $(ZLIB_CFLAGS) libaircrack_ce_wpa_x86_avx512_la_LDFLAGS = -release $(LT_VER) -no-undefined if !STATIC_CRYPTO libaircrack_ce_wpa_x86_avx512_la_LIBADD = $(LIBACCRYPTO_LIBS) $(PTHREAD_LIBS) $(CRYPTO_LIBS) $(ZLIB_LIBS) endif libaircrack_ce_wpa_x86_avx2_la_SOURCES = $(SRC_CE_WPA) libaircrack_ce_wpa_x86_avx2_la_CFLAGS = $(x86_avx2_cflags) -DSIMD_CORE -DJOHN_AVX2 $(PTHREAD_CFLAGS) $(CRYPTO_CFLAGS) $(ZLIB_CFLAGS) libaircrack_ce_wpa_x86_avx2_la_LDFLAGS = -release $(LT_VER) -no-undefined if !STATIC_CRYPTO libaircrack_ce_wpa_x86_avx2_la_LIBADD = $(LIBACCRYPTO_LIBS) $(PTHREAD_LIBS) $(CRYPTO_LIBS) $(ZLIB_LIBS) endif libaircrack_ce_wpa_x86_avx_la_SOURCES = $(SRC_CE_WPA) libaircrack_ce_wpa_x86_avx_la_CFLAGS = $(x86_avx_cflags) -DSIMD_CORE -DJOHN_AVX $(PTHREAD_CFLAGS) $(CRYPTO_CFLAGS) $(ZLIB_CFLAGS) libaircrack_ce_wpa_x86_avx_la_LDFLAGS = -release $(LT_VER) -no-undefined if !STATIC_CRYPTO libaircrack_ce_wpa_x86_avx_la_LIBADD = $(LIBACCRYPTO_LIBS) $(PTHREAD_LIBS) $(CRYPTO_LIBS) $(ZLIB_LIBS) endif libaircrack_ce_wpa_x86_sse2_la_SOURCES = $(SRC_CE_WPA) libaircrack_ce_wpa_x86_sse2_la_CFLAGS = $(x86_sse2_cflags) -DSIMD_CORE -DJOHN_SSE2 $(PTHREAD_CFLAGS) $(CRYPTO_CFLAGS) $(ZLIB_CFLAGS) libaircrack_ce_wpa_x86_sse2_la_LDFLAGS = -release $(LT_VER) -no-undefined if !STATIC_CRYPTO libaircrack_ce_wpa_x86_sse2_la_LIBADD = $(LIBACCRYPTO_LIBS) $(PTHREAD_LIBS) $(CRYPTO_LIBS) $(ZLIB_LIBS) endif # ARM/AARCH64 libaircrack_ce_wpa_arm_neon_la_SOURCES = $(SRC_CE_WPA) libaircrack_ce_wpa_arm_neon_la_CFLAGS = $(arm_neon_cflags) -DSIMD_CORE -DHAS_NEON $(PTHREAD_CFLAGS) $(CRYPTO_CFLAGS) $(ZLIB_CFLAGS) libaircrack_ce_wpa_arm_neon_la_LDFLAGS = -release $(LT_VER) -no-undefined if !STATIC_CRYPTO libaircrack_ce_wpa_arm_neon_la_LIBADD = $(LIBACCRYPTO_LIBS) $(PTHREAD_LIBS) $(CRYPTO_LIBS) $(ZLIB_LIBS) endif # PowerPC libaircrack_ce_wpa_ppc_altivec_la_SOURCES = $(SRC_CE_WPA) libaircrack_ce_wpa_ppc_altivec_la_CFLAGS = $(ppc_altivec_cflags) -DSIMD_CORE -DHAS_ALTIVEC=1 -DJOHN_ALTIVEC $(PTHREAD_CFLAGS) $(CRYPTO_CFLAGS) $(ZLIB_CFLAGS) libaircrack_ce_wpa_ppc_altivec_la_LDFLAGS = -release $(LT_VER) -no-undefined if !STATIC_CRYPTO libaircrack_ce_wpa_ppc_altivec_la_LIBADD = $(LIBACCRYPTO_LIBS) $(PTHREAD_LIBS) $(CRYPTO_LIBS) $(ZLIB_LIBS) endif libaircrack_ce_wpa_ppc_power8_la_SOURCES = $(SRC_CE_WPA) libaircrack_ce_wpa_ppc_power8_la_CFLAGS = $(ppc_altivec_cflags) -DSIMD_CORE -DHAS_ALTIVEC=1 -DJOHN_ALTIVEC -DJOHN_POWER8 $(PTHREAD_CFLAGS) $(CRYPTO_CFLAGS) $(ZLIB_CFLAGS) libaircrack_ce_wpa_ppc_power8_la_LDFLAGS = -release $(LT_VER) -no-undefined if !STATIC_CRYPTO libaircrack_ce_wpa_ppc_power8_la_LIBADD = $(LIBACCRYPTO_LIBS) $(PTHREAD_LIBS) $(CRYPTO_LIBS) $(ZLIB_LIBS) endif # Generic library libaircrack_ce_wpa_la_CFLAGS = $(PTHREAD_CFLAGS) $(CRYPTO_CFLAGS) $(ZLIB_CFLAGS) libaircrack_ce_wpa_la_SOURCES = $(SRC_CE_WPA) libaircrack_ce_wpa_la_LDFLAGS = -release $(LT_VER) -no-undefined if !STATIC_CRYPTO libaircrack_ce_wpa_la_LIBADD = $(LIBACCRYPTO_LIBS) $(PTHREAD_LIBS) $(CRYPTO_LIBS) $(ZLIB_LIBS) endif # Build librarie(s) lib_LTLIBRARIES += libaircrack-ce-wpa.la if ARM if NEON lib_LTLIBRARIES += libaircrack-ce-wpa-arm-neon.la endif endif if PPC if ALTIVEC lib_LTLIBRARIES += libaircrack-ce-wpa-ppc-altivec.la endif if POWER8 lib_LTLIBRARIES += libaircrack-ce-wpa-ppc-power8.la endif endif if X86 if AVX512F lib_LTLIBRARIES += libaircrack-ce-wpa-x86-avx512.la endif lib_LTLIBRARIES += libaircrack-ce-wpa-x86-avx2.la libaircrack-ce-wpa-x86-avx.la libaircrack-ce-wpa-x86-sse2.la endif noinst_LTLIBRARIES += libaircrack-ce-wep.la libcowpatty.la libaccrypto.la libptw.la libaircrack.la libradiotap.la EXTRA_DIST += %D%/ce-wep/uniqueiv.c \ %D%/ce-wpa/crypto_engine.c \ %D%/ce-wpa/memory.c \ %D%/ce-wpa/simd-intrinsics.c \ %D%/ce-wpa/wpapsk.c \ %D%/cowpatty/cowpatty.c \ %D%/crypto/crypto.c \ %D%/crypto/sha1-git.c \ %D%/crypto/sha1-sse2.S \ %D%/libac/adt/avl_tree.c \ %D%/libac/adt/circular_buffer.c \ %D%/libac/adt/circular_queue.c \ %D%/libac/cpu/cpuset_hwloc.c \ %D%/libac/cpu/cpuset_pthread.c \ %D%/libac/cpu/simd_cpuid.c \ %D%/libac/cpu/trampoline_arm.c \ %D%/libac/cpu/trampoline_ppc.c \ %D%/libac/cpu/trampoline_stubs.c \ %D%/libac/cpu/trampoline_x86.c \ %D%/libac/support/common.c \ %D%/libac/support/communications.c \ %D%/libac/support/crypto_engine_loader.c \ %D%/libac/support/fragments.c \ %D%/libac/support/mcs_index_rates.c \ %D%/libac/tui/console.c \ %D%/libac/utf8/verifyssid.c \ %D%/osdep/aircrack_ng_airpcap.h \ %D%/osdep/airpcap.c \ %D%/osdep/common.c \ %D%/osdep/crctable_osdep.h \ %D%/osdep/cygwin.c \ %D%/osdep/cygwin.h \ %D%/osdep/cygwin_tap.c \ %D%/osdep/darwin.c \ %D%/osdep/darwin_tap.c \ %D%/osdep/dummy.c \ %D%/osdep/dummy_tap.c \ %D%/osdep/file.c \ %D%/osdep/freebsd.c \ %D%/osdep/freebsd_tap.c \ %D%/osdep/linux.c \ %D%/osdep/linux_tap.c \ %D%/osdep/netbsd.c \ %D%/osdep/netbsd_tap.c \ %D%/osdep/network.c \ %D%/osdep/openbsd.c \ %D%/osdep/openbsd_tap.c \ %D%/osdep/osdep.c \ %D%/osdep/tap-win32/common.h \ %D%/ptw/aircrack-ptw-lib.c \ %D%/radiotap/COPYING \ %D%/radiotap/parse.c \ %D%/radiotap/platform.h \ %D%/radiotap/radiotap.c \ %D%/radiotap/radiotap.h \ %D%/radiotap/radiotap_iter.h aircrack-ng-1.6/lib/ce-wep/000077500000000000000000000000001361312141100154605ustar00rootroot00000000000000aircrack-ng-1.6/lib/ce-wep/uniqueiv.c000066400000000000000000000142141361312141100174730ustar00rootroot00000000000000/* * IV uniqueness detection method. * * Copyright (C) 2004-2008 Stanislaw Pusep: * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. * If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. * If you * do not wish to do so, delete this exception statement from your * version. * If you delete this exception statement from all source * files in the program, then also delete it here. */ /* * Each IV byte is stored in corresponding "level". We have 3 levels with * IV[2] as root index (level 0), IV[1] and IV[2] as level 2 and level 1 * indices respectively. Space required to allocate all data is at maximum * 2^24/8 (2 MB) and space required by filled index structures is 257 KB. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include "aircrack-ng/defs.h" #include "aircrack-ng/ce-wep/uniqueiv.h" /* allocate root structure */ unsigned char ** uniqueiv_init(void) { int i; /* allocate root bucket (level 0) as vector of pointers */ unsigned char ** uiv_root = (unsigned char **) malloc(256 * sizeof(unsigned char *)); if (uiv_root == NULL) return (NULL); /* setup initial state as empty */ for (i = 0; i < 256; ++i) uiv_root[i] = NULL; return (uiv_root); } /* update records with new IV */ int uniqueiv_mark(unsigned char ** uiv_root, unsigned char IV[3]) { unsigned char ** uiv_lvl1; unsigned char * uiv_lvl2; short i; if (uiv_root == NULL) return (0); /* select bucket from level 1 */ uiv_lvl1 = (unsigned char **) uiv_root[IV[2]]; /* create if it doesn't exist */ if (uiv_lvl1 == NULL) { /* allocate level 2 bucket being a vector of bits */ uiv_lvl1 = (unsigned char **) malloc(256 * sizeof(unsigned char *)); if (uiv_lvl1 == NULL) return (1); /* setup initial state as empty */ for (i = 0; i < 256; i++) uiv_lvl1[i] = NULL; /* link to parent bucket */ uiv_root[IV[2]] = (unsigned char *) uiv_lvl1; } /* select bucket from level 2 */ uiv_lvl2 = (unsigned char *) uiv_lvl1[IV[1]]; /* create if it doesn't exist */ if (uiv_lvl2 == NULL) { /* allocate level 2 bucket as a vector of pointers */ uiv_lvl2 = (unsigned char *) malloc(32 * sizeof(unsigned char)); if (uiv_lvl2 == NULL) return (1); /* setup initial state as empty */ for (i = 0; i < 32; i++) uiv_lvl2[i] = 0; /* link to parent bucket */ uiv_lvl1[IV[1]] = uiv_lvl2; } /* place single bit into level 2 bucket */ uiv_lvl2[BITWISE_OFFT(IV[0])] |= BITWISE_MASK(IV[0]); return (0); } /* check if already seen IV */ int uniqueiv_check(unsigned char ** uiv_root, unsigned char IV[3]) { unsigned char ** uiv_lvl1; unsigned char * uiv_lvl2; if (uiv_root == NULL) return (IV_NOTHERE); /* select bucket from level 1 */ uiv_lvl1 = (unsigned char **) uiv_root[IV[2]]; /* stop here if not even allocated */ if (uiv_lvl1 == NULL) return (IV_NOTHERE); /* select bucket from level 2 */ uiv_lvl2 = (unsigned char *) uiv_lvl1[IV[1]]; /* stop here if not even allocated */ if (uiv_lvl2 == NULL) return (IV_NOTHERE); /* check single bit from level 2 bucket */ if ((uiv_lvl2[BITWISE_OFFT(IV[0])] & BITWISE_MASK(IV[0])) == 0) return (IV_NOTHERE); else return (IV_PRESENT); } /* unallocate everything */ void uniqueiv_wipe(unsigned char ** uiv_root) { int i, j; unsigned char ** uiv_lvl1; unsigned char * uiv_lvl2; if (uiv_root == NULL) return; /* recursively wipe out allocated buckets */ for (i = 0; i < 256; ++i) { uiv_lvl1 = (unsigned char **) uiv_root[i]; if (uiv_lvl1 != NULL) { for (j = 0; j < 256; ++j) { uiv_lvl2 = (unsigned char *) uiv_lvl1[j]; if (uiv_lvl2 != NULL) { free(uiv_lvl2); uiv_lvl2 = NULL; } } free(uiv_lvl1); uiv_lvl1 = NULL; } } free(uiv_root); uiv_root = NULL; return; } unsigned char * data_init(void) { // It could eat up to (256*256*256) * 3 bytes = 48Mb :/ unsigned char * IVs = (unsigned char *) calloc(256 * 256 * 256 * 3, sizeof(unsigned char)); ALLEGE(IVs != NULL); return (IVs); } /* Checking WEP packet: * The 2 first bytes of 2 different data packets having the same IV (for the * same AP) * should be exactly the same due to the fact that unencrypted, they are always * the same: * AA AA */ int data_check(unsigned char * data_root, unsigned char IV[3], unsigned char data[2]) { int IV_position, cloaking; // Init vars cloaking = NO_CLOAKING; // Make sure it is allocated if (data_root != NULL) { // Try to find IV IV_position = (((IV[0] * 256) + IV[1]) * 256) + IV[2]; IV_position *= 3; // Check if existing if (*(data_root + IV_position) == 0) { // Not existing *(data_root + IV_position) = 1; // Add it *(data_root + IV_position + 1) = data[0]; *(data_root + IV_position + 2) = data[1]; } else { // Good, we found it, so check it now if (*(data_root + IV_position + 1) != data[0] || *(data_root + IV_position + 2) != data[1]) { cloaking = CLOAKING; } } } // else, cannot detect since it is not started return (cloaking); } void data_wipe(unsigned char * data) { if (data) free(data); } aircrack-ng-1.6/lib/ce-wpa/000077500000000000000000000000001361312141100154545ustar00rootroot00000000000000aircrack-ng-1.6/lib/ce-wpa/crypto_engine.c000066400000000000000000000354251361312141100204760ustar00rootroot00000000000000/* * Copyright (C) 2018 Joseph Benden * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * is provided AS IS, WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and * NON-INFRINGEMENT. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, * MA 02110-1301, USA. * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #define _GNU_SOURCE #include #include #include #include "aircrack-ng/ce-wpa/simd-intrinsics.h" #include "aircrack-ng/ce-wpa/wpapsk.h" #include "aircrack-ng/cpu/trampoline.h" #include "aircrack-ng/ce-wpa/crypto_engine.h" // #define XDEBUG #if defined(HAVE_OPENSSL_CMAC_H) || defined(GCRYPT_WITH_CMAC_AES) /* Code borrowed from https://w1.fi/wpa_supplicant/ starts */ #define CMAC_AES_128_MAC_LEN 16 #define SHA256_MAC_LEN 32 typedef uint16_t u16; typedef uint8_t u8; static inline void WPA_PUT_LE16(u8 * a, u16 val) { a[1] = (u8)(val >> 8u); a[0] = (u8)(val & 0xff); } static void sha256_vector(size_t num_elem, const u8 * addr[], const size_t * len, u8 * mac) { SHA256_CTX ctx; size_t i; SHA256_Init(&ctx); for (i = 0; i < num_elem; i++) { SHA256_Update(&ctx, addr[i], len[i]); } SHA256_Final(mac, &ctx); } static void hmac_sha256_vector(const u8 * key, size_t key_len, size_t num_elem, const u8 * addr[], const size_t * len, u8 * mac) { unsigned char k_pad[64]; /* padding - key XORd with ipad/opad */ const u8 * _addr[6]; size_t _len[6], i; /* the HMAC_SHA256 transform looks like: * * SHA256(K XOR opad, SHA256(K XOR ipad, text)) * * where K is an n byte key * ipad is the byte 0x36 repeated 64 times * opad is the byte 0x5c repeated 64 times * and text is the data being protected */ /* start out by storing key in ipad */ memset(k_pad, 0, sizeof(k_pad)); memcpy(k_pad, key, key_len); /* XOR key with ipad values */ for (i = 0; i < 64; i++) k_pad[i] ^= 0x36; /* perform inner SHA256 */ _addr[0] = k_pad; _len[0] = 64; for (i = 0; i < num_elem; i++) { _addr[i + 1] = addr[i]; _len[i + 1] = len[i]; } sha256_vector(1 + num_elem, _addr, _len, mac); memset(k_pad, 0, sizeof(k_pad)); memcpy(k_pad, key, key_len); /* XOR key with opad values */ for (i = 0; i < 64; i++) k_pad[i] ^= 0x5c; /* perform outer SHA256 */ _addr[0] = k_pad; _len[0] = 64; _addr[1] = mac; _len[1] = SHA256_MAC_LEN; sha256_vector(2, _addr, _len, mac); } static void sha256_prf_bits(const u8 * key, size_t key_len, const char * label, const u8 * data, size_t data_len, u8 * buf, size_t buf_len_bits) { u16 counter = 1; size_t pos, plen; u8 hash[SHA256_MAC_LEN]; const u8 * addr[4]; size_t len[4]; u8 counter_le[2], length_le[2]; size_t buf_len = (buf_len_bits + 7) / 8; addr[0] = counter_le; len[0] = 2; addr[1] = (u8 *) label; len[1] = strlen(label); addr[2] = data; len[2] = data_len; addr[3] = length_le; len[3] = sizeof(length_le); WPA_PUT_LE16(length_le, (u16) buf_len_bits); pos = 0; while (pos < buf_len) { plen = buf_len - pos; WPA_PUT_LE16(counter_le, counter); if (plen >= SHA256_MAC_LEN) { hmac_sha256_vector(key, key_len, 4, addr, len, &buf[pos]); pos += SHA256_MAC_LEN; } else { hmac_sha256_vector(key, key_len, 4, addr, len, hash); memcpy(&buf[pos], hash, plen); pos += plen; break; } counter++; } /* * Mask out unused bits in the last octet if it does not use all the * bits. */ if (buf_len_bits % 8) { u8 mask = (u8)(0xff << (8u - buf_len_bits % 8)); buf[pos - 1] &= mask; } } #endif /* HAVE_OPENSSL_CMAC_H || GCRYPT_WITH_CMAC_AES */ EXPORT int ac_crypto_engine_supported_features(void) { #if defined(JOHN_AVX512F) return SIMD_SUPPORTS_AVX512F; #elif defined(JOHN_AVX2) return SIMD_SUPPORTS_AVX2; #elif defined(JOHN_AVX) return SIMD_SUPPORTS_AVX; #elif defined(JOHN_SSE2) return SIMD_SUPPORTS_SSE2; #elif defined(JOHN_NEON) return SIMD_SUPPORTS_NEON; #elif defined(JOHN_ASIMD) return SIMD_SUPPORTS_ASIMD; #elif defined(JOHN_POWER8) return SIMD_SUPPORTS_POWER8; #elif defined(JOHN_ALTIVEC) return SIMD_SUPPORTS_ALTIVEC; #else return SIMD_SUPPORTS_NONE; #endif } EXPORT int ac_crypto_engine_simd_width() { #ifdef SIMD_COEF_32 return SIMD_COEF_32; #else return 1; #endif } EXPORT int ac_crypto_engine_init(ac_crypto_engine_t * engine) { assert(engine != NULL); #ifdef XDEBUG fprintf(stderr, "ac_crypto_engine_init(%p)\n", engine); #endif init_atoi(); engine->essid = mem_calloc_align(1, ESSID_LENGTH + 1, MEM_ALIGN_SIMD); engine->essid_length = 0; for (int i = 0; i < MAX_THREADS; ++i) engine->thread_data[i] = NULL; return 0; } EXPORT void ac_crypto_engine_destroy(ac_crypto_engine_t * engine) { assert(engine != NULL); #ifdef XDEBUG fprintf(stderr, "ac_crypto_engine_destroy(%p)\n", engine); #endif MEM_FREE(engine->essid); engine->essid = NULL; } EXPORT void ac_crypto_engine_set_essid(ac_crypto_engine_t * engine, const uint8_t * essid) { assert(engine != NULL); #ifdef XDEBUG fprintf(stderr, "ac_crypto_engine_set_essid(%p, %s)\n", engine, essid); #endif memccpy(engine->essid, essid, 0, ESSID_LENGTH); engine->essid_length = (uint32_t) strlen((char *) essid); } EXPORT int ac_crypto_engine_thread_init(ac_crypto_engine_t * engine, int threadid) { assert(engine != NULL); #ifdef XDEBUG fprintf(stderr, "ac_crypto_engine_thread_init(%p, %d)\n", engine, threadid); #endif // allocate per-thread data. engine->thread_data[threadid] = mem_calloc_align( 1, sizeof(struct ac_crypto_engine_perthread), MEM_ALIGN_SIMD); return 0; } EXPORT void ac_crypto_engine_thread_destroy(ac_crypto_engine_t * engine, int threadid) { assert(engine != NULL); #ifdef XDEBUG fprintf( stderr, "ac_crypto_engine_thread_destroy(%p, %d)\n", engine, threadid); #endif if (engine->thread_data[threadid] != NULL) { MEM_FREE(engine->thread_data[threadid]); engine->thread_data[threadid] = NULL; } } EXPORT uint8_t * ac_crypto_engine_get_pmk(ac_crypto_engine_t * engine, int threadid, int index) { return (uint8_t *) engine->thread_data[threadid]->pmk + (sizeof(wpapsk_hash) * index); } EXPORT uint8_t * ac_crypto_engine_get_ptk(ac_crypto_engine_t * engine, int threadid, int index) { return (uint8_t *) engine->thread_data[threadid]->ptk + (20 * index); } EXPORT void ac_crypto_engine_calc_pke(ac_crypto_engine_t * engine, const uint8_t bssid[6], const uint8_t stmac[6], const uint8_t anonce[32], const uint8_t snonce[32], int threadid) { uint8_t * pke = engine->thread_data[threadid]->pke; assert(pke != NULL); //-V547 /* pre-compute the key expansion buffer */ memcpy(pke, "Pairwise key expansion", 23); if (memcmp(stmac, bssid, 6) < 0) { memcpy(pke + 23, stmac, 6); memcpy(pke + 29, bssid, 6); } else { memcpy(pke + 23, bssid, 6); memcpy(pke + 29, stmac, 6); } if (memcmp(snonce, anonce, 32) < 0) { memcpy(pke + 35, snonce, 32); memcpy(pke + 67, anonce, 32); } else { memcpy(pke + 35, anonce, 32); memcpy(pke + 67, snonce, 32); } } /* derive the PMK from the passphrase and the essid */ EXPORT void ac_crypto_engine_calc_one_pmk(const uint8_t * key, const uint8_t * essid_pre, uint32_t essid_pre_len, uint8_t pmk[40]) { int i, j, slen; unsigned char buffer[65]; char essid[33 + 4]; SHA_CTX ctx_ipad; SHA_CTX ctx_opad; SHA_CTX sha1_ctx; assert(essid_pre != NULL); if (essid_pre_len > 32) { essid_pre_len = 32; } memset(essid, 0, sizeof(essid)); memcpy(essid, essid_pre, essid_pre_len); slen = (int) essid_pre_len + 4; /* setup the inner and outer contexts */ memset(buffer, 0, sizeof(buffer)); strncpy((char *) buffer, (char *) key, sizeof(buffer) - 1); for (i = 0; i < 64; i++) buffer[i] ^= 0x36; SHA1_Init(&ctx_ipad); SHA1_Update(&ctx_ipad, buffer, 64); for (i = 0; i < 64; i++) buffer[i] ^= 0x6A; SHA1_Init(&ctx_opad); SHA1_Update(&ctx_opad, buffer, 64); /* iterate HMAC-SHA1 over itself 8192 times */ essid[slen - 1] = '\1'; HMAC(EVP_sha1(), key, (int) strlen((char *) key), (unsigned char *) essid, (size_t) slen, pmk, NULL); memcpy(buffer, pmk, 20); //-V512 for (i = 1; i < 4096; i++) { memcpy(&sha1_ctx, &ctx_ipad, sizeof(sha1_ctx)); SHA1_Update(&sha1_ctx, buffer, 20); SHA1_Final(buffer, &sha1_ctx); memcpy(&sha1_ctx, &ctx_opad, sizeof(sha1_ctx)); SHA1_Update(&sha1_ctx, buffer, 20); SHA1_Final(buffer, &sha1_ctx); for (j = 0; j < 20; j++) pmk[j] ^= buffer[j]; } essid[slen - 1] = '\2'; HMAC(EVP_sha1(), (unsigned char *) key, (int) strlen((char *) key), (unsigned char *) essid, (size_t) slen, pmk + 20, NULL); memcpy(buffer, pmk + 20, 20); for (i = 1; i < 4096; i++) { memcpy(&sha1_ctx, &ctx_ipad, sizeof(sha1_ctx)); SHA1_Update(&sha1_ctx, buffer, 20); SHA1_Final(buffer, &sha1_ctx); memcpy(&sha1_ctx, &ctx_opad, sizeof(sha1_ctx)); SHA1_Update(&sha1_ctx, buffer, 20); SHA1_Final(buffer, &sha1_ctx); for (j = 0; j < 20; j++) pmk[j + 20] ^= buffer[j]; } } EXPORT void ac_crypto_engine_calc_pmk( ac_crypto_engine_t * engine, const wpapsk_password key[MAX_KEYS_PER_CRYPT_SUPPORTED], const int nparallel, const int threadid) { wpapsk_hash * pmk = engine->thread_data[threadid]->pmk; // PMK calculation #ifdef SIMD_CORE if (nparallel >= 4) { init_wpapsk(engine, key, nparallel, threadid); } else #endif for (int j = 0; j < nparallel; ++j) { #ifdef XDEBUG printf("%lu: Trying: %s\n", pthread_self(), (char *) key[j].v); #endif ac_crypto_engine_calc_one_pmk(key[j].v, (uint8_t *) engine->essid, engine->essid_length, (uint8_t *) (&pmk[j])); } } EXPORT void ac_crypto_engine_calc_ptk(ac_crypto_engine_t * engine, const uint8_t keyver, int vectorIdx, int threadid) { uint8_t * ptk = engine->thread_data[threadid]->ptk; wpapsk_hash * pmk = engine->thread_data[threadid]->pmk; if (keyver < 3) { for (int i = 0; i < 4; i++) { *(engine->thread_data[threadid]->pke + 99) = (unsigned char) i; HMAC(EVP_sha1(), (&pmk[vectorIdx]), 32, engine->thread_data[threadid]->pke, 100, &ptk[vectorIdx] + i * 20, NULL); } } #if defined(HAVE_OPENSSL_CMAC_H) || defined(GCRYPT_WITH_CMAC_AES) else { uint8_t data[64 + 12]; uint8_t * pke = &engine->thread_data[threadid]->pke[23]; memset(data, 0, sizeof(data)); memcpy(data, pke, 6); memcpy(data + 6, pke + 6, 6); memcpy(data + 12, pke + 35 - 23, 64); //-V512 sha256_prf_bits((unsigned char *) (pmk[vectorIdx].v), 32, "Pairwise key expansion", data, 76, ptk, 48 * 8); } #endif } EXPORT void ac_crypto_engine_calc_mic(ac_crypto_engine_t * engine, const uint8_t eapol[256], const uint32_t eapol_size, uint8_t mic[MAX_KEYS_PER_CRYPT_SUPPORTED] [20], const uint8_t keyver, const int vectorIdx, const int threadid) { uint8_t * ptk = engine->thread_data[threadid]->ptk; if (keyver == 1) HMAC(EVP_md5(), &ptk[vectorIdx], 16, eapol, eapol_size, mic[vectorIdx], NULL); else if (keyver == 2) HMAC(EVP_sha1(), &ptk[vectorIdx], 16, eapol, eapol_size, mic[vectorIdx], NULL); #if defined(HAVE_OPENSSL_CMAC_H) || defined(GCRYPT_WITH_CMAC_AES) else if (keyver == 3) { size_t miclen = CMAC_AES_128_MAC_LEN; CMAC_CTX * ctx = NULL; // Compute MIC ctx = CMAC_CTX_new(); CMAC_Init(ctx, ptk, 16, EVP_aes_128_cbc(), 0); CMAC_Update(ctx, eapol, eapol_size); CMAC_Final(ctx, mic[vectorIdx], &miclen); CMAC_CTX_free(ctx); } #else else if (keyver == 3) { fprintf(stderr, "Key version %d is only supported when OpenSSL (or similar) " "supports CMAC.\n", keyver); abort(); } #endif /* HAVE_OPENSSL_CMAC_H */ else { fprintf(stderr, "Unsupported key version %d encountered.\n", keyver); if (keyver == 0) fprintf(stderr, "May be WPA3 - not yet supported.\n"); abort(); } } EXPORT int ac_crypto_engine_wpa_crack( ac_crypto_engine_t * engine, const wpapsk_password key[MAX_KEYS_PER_CRYPT_SUPPORTED], const uint8_t eapol[256], const uint32_t eapol_size, uint8_t mic[MAX_KEYS_PER_CRYPT_SUPPORTED][20], const uint8_t keyver, const uint8_t cmpmic[20], const int nparallel, const int threadid) { ac_crypto_engine_calc_pmk(engine, key, nparallel, threadid); for (int j = 0; j < nparallel; ++j) { /* compute the pairwise transient key and the frame MIC */ ac_crypto_engine_calc_ptk(engine, keyver, j, threadid); ac_crypto_engine_calc_mic( engine, eapol, eapol_size, mic, keyver, j, threadid); /* did we successfully crack it? */ if (memcmp(mic[j], cmpmic, 16) == 0) //-V512 { return j; } } return -1; } EXPORT void ac_crypto_engine_set_pmkid_salt(ac_crypto_engine_t * engine, const uint8_t bssid[6], const uint8_t stmac[6], int threadid) { uint8_t * pke = engine->thread_data[threadid]->pke; assert(pke != NULL); //-V547 /* pre-compute the PMKID salt buffer */ memcpy(pke, "PMK Name", 8); memcpy(pke + 8, bssid, 6); memcpy(pke + 14, stmac, 6); } EXPORT int ac_crypto_engine_wpa_pmkid_crack( ac_crypto_engine_t * engine, const wpapsk_password key[MAX_KEYS_PER_CRYPT_SUPPORTED], const uint8_t pmkid[32], const int nparallel, const int threadid) { ac_crypto_engine_calc_pmk(engine, key, nparallel, threadid); uint8_t * pke = engine->thread_data[threadid]->pke; wpapsk_hash * pmk = engine->thread_data[threadid]->pmk; uint8_t l_pmkid[32]; for (int j = 0; j < nparallel; ++j) { HMAC(EVP_sha1(), &pmk[j], 32, pke, 20, l_pmkid, NULL); /* did we successfully crack it? */ if (memcmp(l_pmkid, pmkid, 16) == 0) //-V512 { return j; } } return -1; } aircrack-ng-1.6/lib/ce-wpa/memory.c000066400000000000000000000534431361312141100171410ustar00rootroot00000000000000/* * Based on John the Ripper and modified to integrate with aircrack * * John the Ripper copyright and license. * * John the Ripper password cracker, * Copyright (c) 1996-2013 by Solar Designer. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * As a special exception to the GNU General Public License terms, * permission is hereby granted to link the code of this program, with or * without modification, with any version of the OpenSSL library and/or any * version of unRAR, and to distribute such linked combinations. You must * obey the GNU GPL in all respects for all of the code used other than * OpenSSL and unRAR. If you modify this program, you may extend this * exception to your version of the program, but you are not obligated to * do so. (In other words, you may release your derived work under pure * GNU GPL version 2 or later as published by the FSF.) * * (This exception from the GNU GPL is not required for the core tree of * John the Ripper, but arguably it is required for -jumbo.) * * Relaxed terms for certain components. * * In addition or alternatively to the license above, many components are * available to you under more relaxed terms (most commonly under cut-down * BSD license) as specified in the corresponding source files. * * For more information on John the Ripper licensing please visit: * * http://www.openwall.com/john/doc/LICENSE.shtml * * This file is part of John the Ripper password cracker, * Copyright (c) 1996-98,2010,2012 by Solar Designer * * Redistribution and use in source and binary forms, with or without * modification, are permitted. * * There's ABSOLUTELY NO WARRANTY, express or implied. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include /* for isprint() */ #if HAVE_MEMALIGN && HAVE_MALLOC_H #include #endif #include "aircrack-ng/ce-wpa/arch.h" #include "aircrack-ng/ce-wpa/misc.h" #include "aircrack-ng/ce-wpa/memory.h" #include "aircrack-ng/ce-wpa/jcommon.h" #include "aircrack-ng/ce-wpa/johnswap.h" #include "aircrack-ng/ce-wpa/memdbg.h" #if defined(_MSC_VER) && !defined(MEMDBG_ON) #define malloc(a) _aligned_malloc(a, 16) #define realloc(a, b) _aligned_realloc(a, b, 16) #define calloc(a, b) memset(_aligned_malloc((a) * (b), 16), 0, (a) * (b)) #define free(a) _aligned_free(a) char * strdup_MSVC(const char * str) { char * s; s = (char *) mem_alloc_func(strlen(str) + 1); if (s != NULL) strcpy(s, str); return s; } #endif unsigned int mem_saving_level = 0; // Add 'cleanup' methods for the mem_alloc_tiny. VERY little cost, but // allows us to check for mem leaks easier. struct rm_list { void * mem; struct rm_list * next; }; static struct rm_list * mem_alloc_tiny_memory; static void add_memory_link(void * v) { struct rm_list * p = (struct rm_list *) mem_alloc(sizeof(struct rm_list)); p->next = mem_alloc_tiny_memory; p->mem = v; mem_alloc_tiny_memory = p; // mark these as 'tiny' memory, so that memory snapshot checking does not // flag these as leaks. At program exit, this memory will still get // checked, // but it should be freed, so will still be globally checked for leaks. MEMDBG_tag_mem_from_alloc_tiny(v); MEMDBG_tag_mem_from_alloc_tiny((void *) p); } // call at program exit. void cleanup_tiny_memory(void) { struct rm_list *p = mem_alloc_tiny_memory, *p2; for (;;) { if (!p) return; free(p->mem); p2 = p->next; free(p); p = p2; } } void * mem_alloc_func(size_t size #if defined(MEMDBG_ON) , char * file, int line #endif ) { void * res; if (!size) return NULL; #if defined(MEMDBG_ON) res = (char *) MEMDBG_alloc(size, file, line); #else res = malloc(size); #endif if (!res) { fprintf(stderr, "mem_alloc(): %s trying to allocate " Zu " bytes\n", strerror(ENOMEM), size); MEMDBG_PROGRAM_EXIT_CHECKS(stderr); perror("mem_alloc"); } return res; } void * mem_calloc_func(size_t count, size_t size #if defined(MEMDBG_ON) , char * file, int line #endif ) { void * res; if (!count || !size) return NULL; #if defined(MEMDBG_ON) size *= count; res = (char *) MEMDBG_alloc(size, file, line); memset(res, 0, size); #else res = calloc(count, size); #endif if (!res) { fprintf(stderr, "mem_calloc(): %s trying to allocate " Zu " bytes\n", strerror(ENOMEM), count * size); MEMDBG_PROGRAM_EXIT_CHECKS(stderr); perror("mem_calloc"); } return res; } /* * if -DDEBUG we turn mem_alloc_tiny() to essentially be just a malloc() * with additional alignment. The reason for this is it's way easier to * trace bugs that way. * Also, with -DDEBUG or -DMEMDBG we always return exactly the requested * alignment, in order to trigger bugs! */ #ifdef DEBUG #undef MEM_ALLOC_SIZE #define MEM_ALLOC_SIZE 0 #endif void * mem_alloc_tiny_func(size_t size, size_t align #if defined(MEMDBG_ON) , char * file, int line #endif ) { static char * buffer = NULL; static size_t bufree = 0; size_t mask; char * p; #if defined(DEBUG) || defined(MEMDBG) size += align; #endif #ifdef DEBUG /* * We may be called with size zero, for example from ldr_load_pw_line() * that calls mem_alloc_copy() with format->params.salt_size as size. * This causes problems with -DDEBUG without this fix because we never * get out of the while loop when MEM_ALLOC_SIZE is zero too. The * previous fix for this was returning NULL but that lead to other * problems that I did not bother digging into. This fix should be * 100% safe. */ if (size == 0) size = 1; #endif #if ARCH_ALLOWS_UNALIGNED if (mem_saving_level > 2 && align < MEM_ALIGN_SIMD) align = MEM_ALIGN_NONE; #endif mask = align - 1; do { if (buffer) { size_t need = size + mask - (((size_t) buffer + mask) & mask); if (bufree >= need) { p = buffer; p += mask; p -= (size_t) p & mask; bufree -= need; buffer = p + size; #if defined(DEBUG) || defined(MEMDBG) /* Ensure alignment is no better than requested */ if (((size_t) p & ((mask << 1) + 1)) == 0) p += align; #endif return p; } } if (size + mask > MEM_ALLOC_SIZE || bufree > MEM_ALLOC_MAX_WASTE) break; #if defined(MEMDBG_ON) buffer = (char *) mem_alloc_func(MEM_ALLOC_SIZE, file, line); #else buffer = (char *) mem_alloc(MEM_ALLOC_SIZE); #endif add_memory_link((void *) buffer); bufree = MEM_ALLOC_SIZE; } while (1); #if defined(MEMDBG_ON) p = (char *) mem_alloc_func(size + mask, file, line); #else p = (char *) mem_alloc(size + mask); #endif if (p == NULL) abort(); add_memory_link((void *) p); p += mask; p -= (size_t) p & mask; #if defined(DEBUG) || defined(MEMDBG) /* Ensure alignment is no better than requested */ if (((size_t) p & ((mask << 1) + 1)) == 0) p += align; #endif return p; } void * mem_calloc_tiny_func(size_t size, size_t align #if defined(MEMDBG_ON) , char * file, int line #endif ) { #if defined(MEMDBG_ON) char * cp = (char *) mem_alloc_tiny_func(size, align, file, line); #else char * cp = (char *) mem_alloc_tiny(size, align); #endif memset(cp, 0, size); return cp; } void * mem_alloc_copy_func(void * src, size_t size, size_t align #if defined(MEMDBG_ON) , char * file, int line #endif ) { #if defined(MEMDBG_ON) return memcpy(mem_alloc_tiny_func(size, align, file, line), src, size); #else return memcpy(mem_alloc_tiny(size, align), src, size); #endif } void * mem_alloc_align_func(size_t size, size_t align #if defined(MEMDBG_ON) , char * file, int line #endif ) { void * ptr = NULL; #if defined(MEMDBG_ON) ptr = (char *) MEMDBG_alloc_align(size, align, file, line); #elif HAVE_POSIX_MEMALIGN if (posix_memalign(&ptr, align, size)) pexit("posix_memalign"); #elif HAVE_ALIGNED_ALLOC /* According to the Linux man page, "size should be a multiple of alignment", whatever they mean with "should"... This does not make any sense whatsoever but we round it up to comply. */ size = ((size + (align - 1)) / align) * align; if (!(ptr = aligned_alloc(align, size))) pexit("aligned_alloc"); #elif HAVE_MEMALIGN /* Let's just pray this implementation can actually free it */ #if defined(__sparc__) || defined(__sparc) || defined(sparc) \ || defined(__sparcv9) if (!(ptr = memalign(align, size))) #else if (!(ptr = memalign(&ptr, align, size))) #endif perror("memalign"); #elif HAVE___MINGW_ALIGNED_MALLOC if (!(ptr = __mingw_aligned_malloc(size, align))) perror("__mingw_aligned_malloc"); #elif HAVE__ALIGNED_MALLOC if (!(ptr = _aligned_malloc(size, align))) perror("aligned_malloc"); #elif AC_BUILT #error No suitable aligned alloc found, please report to john-dev mailing list (state your OS details). /* we need an aligned alloc function for legacy builds */ #elif _ISOC11_SOURCE size = ((size + (align - 1)) / align) * align; if (!(ptr = aligned_alloc(align, size))) perror("aligned_alloc"); #else if (posix_memalign(&ptr, align, size)) perror("posix_memalign"); #endif return ptr; } void * mem_calloc_align_func(size_t count, size_t size, size_t align #if defined(MEMDBG_ON) , char * file, int line #endif ) { #if defined(MEMDBG_ON) void * ptr = mem_alloc_align_func(size * count, align, file, line); #else void * ptr = mem_alloc_align_func(size * count, align); #endif memset(ptr, 0, size * count); return ptr; } char * str_alloc_copy_func(char * src #if defined(MEMDBG_ON) , char * file, int line #endif ) { size_t size; if (!src) return ""; if (!*src) return ""; size = strlen(src) + 1; #if defined(MEMDBG_ON) return (char *) memcpy( mem_alloc_tiny_func(size, MEM_ALIGN_NONE, file, line), src, size); #else return (char *) memcpy(mem_alloc_tiny(size, MEM_ALIGN_NONE), src, size); #endif } void dump_text(void * in, int len) { unsigned char * p = (unsigned char *) in; while (len--) { fputc(isprint(*p) ? *p : '.', stdout); p++; } fputc('\n', stdout); } void dump_stuff_noeol(void * x, unsigned int size) { unsigned int i; for (i = 0; i < size; i++) { printf("%.2x", ((unsigned char *) x)[i]); if ((i % 4) == 3) printf(" "); } } void dump_stuff(void * x, unsigned int size) { dump_stuff_noeol(x, size); printf("\n"); } void dump_stuff_msg(const void * msg, void * x, unsigned int size) { printf("%s : ", (char *) msg); dump_stuff(x, size); } void dump_stuff_msg_sepline(const void * msg, void * x, unsigned int size) { printf("%s :\n", (char *) msg); dump_stuff(x, size); } void dump_stuff_be_noeol(void * x, unsigned int size) { unsigned int i; for (i = 0; i < size; i++) { printf("%.2x", ((unsigned char *) x)[i ^ 3]); if ((i % 4) == 3) printf(" "); } } void dump_stuff_be(void * x, unsigned int size) { dump_stuff_be_noeol(x, size); printf("\n"); } void dump_stuff_be_msg(const void * msg, void * x, unsigned int size) { printf("%s : ", (char *) msg); dump_stuff_be(x, size); } void dump_stuff_be_msg_sepline(const void * msg, void * x, unsigned int size) { printf("%s :\n", (char *) msg); dump_stuff_be(x, size); } void alter_endianity(void * _x, unsigned int size) { ARCH_WORD_32 * x = (ARCH_WORD_32 *) _x; // size is in octets size >>= 2; #if !ARCH_ALLOWS_UNALIGNED if (is_aligned(x, sizeof(ARCH_WORD_32))) { #endif while (size--) { *x = JOHNSWAP(*x); x++; } #if !ARCH_ALLOWS_UNALIGNED } else { unsigned char *cpX, c; cpX = (unsigned char *) x; while (size--) { c = *cpX; *cpX = cpX[3]; cpX[3] = c; c = cpX[1]; cpX[1] = cpX[2]; cpX[2] = c; cpX += 4; } } #endif } #if defined(SIMD_COEF_32) || defined(NT_X86_64) || defined(SIMD_PARA_MD5) \ || defined(SIMD_PARA_MD4) || defined(SIMD_PARA_SHA1) #ifndef SIMD_COEF_32 #define SIMD_COEF_32 4 #endif #ifndef SIMD_COEF_64 #define SIMD_COEF_64 2 #endif #ifndef SIMD_COEF_32 #define SIMD_COEF_32 4 #endif // These work for standard SIMD_COEF_32 buffers, AND for SSEi MMX_PARA multiple // SIMD_COEF_32 blocks, where index will be mod(X * SIMD_COEF_32) and not simply // mod(SIMD_COEF_32) #define SHAGETPOS(i, index) \ ((index & (SIMD_COEF_32 - 1)) * 4 \ + ((i) & (0xffffffff - 3)) * SIMD_COEF_32 \ + (3 - ((i) &3)) \ + (unsigned int) index / SIMD_COEF_32 * SHA_BUF_SIZ * 4 \ * SIMD_COEF_32) // for endianity conversion #define SHAGETOUTPOS(i, index) \ ((index & (SIMD_COEF_32 - 1)) * 4 \ + ((i) & (0xffffffff - 3)) * SIMD_COEF_32 \ + (3 - ((i) &3)) \ + (unsigned int) index / SIMD_COEF_32 * 20 \ * SIMD_COEF_32) // for endianity conversion // for MD4/MD5 or any 64 byte LE SSE interleaved hash #define GETPOS(i, index) \ ((index & (SIMD_COEF_32 - 1)) * 4 \ + ((i) & (0xffffffff - 3)) * SIMD_COEF_32 \ + ((i) &3) \ + (unsigned int) index / SIMD_COEF_32 * 64 * SIMD_COEF_32) #define GETOUTPOS(i, index) \ ((index & (SIMD_COEF_32 - 1)) * 4 \ + ((i) & (0xffffffff - 3)) * SIMD_COEF_32 \ + ((i) &3) \ + (unsigned int) index / SIMD_COEF_32 * 16 * SIMD_COEF_32) // for SHA384/SHA512 128 byte BE interleaved hash (arrays of 16 8 byte ints) #define SHA64GETPOS(i, index) \ ((index & (SIMD_COEF_64 - 1)) * 8 \ + ((i) & (0xffffffff - 7)) * SIMD_COEF_64 \ + (7 - ((i) &7)) \ + (unsigned int) index / SIMD_COEF_64 * SHA_BUF_SIZ * 8 * SIMD_COEF_64) #define SHA64GETOUTPOS(i, index) \ ((index & (SIMD_COEF_64 - 1)) * 8 \ + ((i) & (0xffffffff - 7)) * SIMD_COEF_64 \ + (7 - ((i) &7)) \ + (unsigned int) index / SIMD_COEF_64 * 64 * SIMD_COEF_64) // for SHA384/SHA512 128 byte FLAT interleaved hash (arrays of 16 8 byte ints), // but we do not BE interleave. #define SHA64GETPOSne(i, index) \ ((index & (SIMD_COEF_64 - 1)) * 8 \ + ((i) & (0xffffffff - 7)) * SIMD_COEF_64 \ + ((i) &7) \ + (unsigned int) index / SIMD_COEF_64 * SHA_BUF_SIZ * 8 * SIMD_COEF_64) void dump_stuff_mmx_noeol(void * buf, unsigned int size, unsigned int index) { unsigned int i; for (i = 0; i < size; i++) { printf("%.2x", ((unsigned char *) buf)[GETPOS(i, index)]); if ((i % 4) == 3) printf(" "); } } void dump_stuff_mmx(void * buf, unsigned int size, unsigned int index) { dump_stuff_mmx_noeol(buf, size, index); printf("\n"); } void dump_stuff_mmx_msg(const void * msg, void * buf, unsigned int size, unsigned int index) { printf("%s : ", (char *) msg); dump_stuff_mmx(buf, size, index); } void dump_stuff_mmx_msg_sepline(const void * msg, void * buf, unsigned int size, unsigned int index) { printf("%s :\n", (char *) msg); dump_stuff_mmx(buf, size, index); } void dump_out_mmx_noeol(void * buf, unsigned int size, unsigned int index) { unsigned int i; for (i = 0; i < size; i++) { printf("%.2x", ((unsigned char *) buf)[GETOUTPOS(i, index)]); if ((i % 4) == 3) printf(" "); } } void dump_out_mmx(void * buf, unsigned int size, unsigned int index) { dump_out_mmx_noeol(buf, size, index); printf("\n"); } void dump_out_mmx_msg(const void * msg, void * buf, unsigned int size, unsigned int index) { printf("%s : ", (char *) msg); dump_out_mmx(buf, size, index); } void dump_out_mmx_msg_sepline(const void * msg, void * buf, unsigned int size, unsigned int index) { printf("%s :\n", (char *) msg); dump_out_mmx(buf, size, index); } #if defined(SIMD_PARA_MD5) #define GETPOSMPARA(i, index) \ ((index & (SIMD_COEF_32 - 1)) * 4 \ + (((i) & (0xffffffff - 3)) % 64) * SIMD_COEF_32 \ + (i / 64) * SIMD_COEF_32 * SIMD_PARA_MD5 * 64 \ + ((i) &3) \ + (unsigned int) index / SIMD_COEF_32 * 64 * SIMD_COEF_32) // multiple para blocks void dump_stuff_mpara_mmx_noeol(void * buf, unsigned int size, unsigned int index) { unsigned int i; for (i = 0; i < size; i++) { printf("%.2x", ((unsigned char *) buf)[GETPOSMPARA(i, index)]); if ((i % 4) == 3) printf(" "); } } void dump_stuff_mpara_mmx(void * buf, unsigned int size, unsigned int index) { dump_stuff_mpara_mmx_noeol(buf, size, index); printf("\n"); } // obuf has to be at lease size long. This function will unwind the SSE-para // buffers into a flat. void getbuf_stuff_mpara_mmx(unsigned char * oBuf, void * buf, unsigned int size, unsigned int index) { unsigned int i; for (i = 0; i < size; i++) *oBuf++ = ((unsigned char *) buf)[GETPOSMPARA(i, index)]; } void dump_stuff_mpara_mmx_msg(const void * msg, void * buf, unsigned int size, unsigned int index) { printf("%s : ", (char *) msg); dump_stuff_mpara_mmx(buf, size, index); } void dump_stuff_mpara_mmx_msg_sepline(const void * msg, void * buf, unsigned int size, unsigned int index) { printf("%s :\n", (char *) msg); dump_stuff_mpara_mmx(buf, size, index); } #endif void dump_stuff_shammx(void * buf, unsigned int size, unsigned int index) { unsigned int i; for (i = 0; i < size; i++) { printf("%.2x", ((unsigned char *) buf)[SHAGETPOS(i, index)]); if ((i % 4) == 3) printf(" "); } printf("\n"); } void dump_stuff_shammx_msg(const void * msg, void * buf, unsigned int size, unsigned int index) { printf("%s : ", (char *) msg); dump_stuff_shammx(buf, size, index); } void dump_out_shammx(void * buf, unsigned int size, unsigned int index) { unsigned int i; for (i = 0; i < size; i++) { printf("%.2x", ((unsigned char *) buf)[SHAGETOUTPOS(i, index)]); if ((i % 4) == 3) printf(" "); } printf("\n"); } void dump_out_shammx_msg(const void * msg, void * buf, unsigned int size, unsigned int index) { printf("%s : ", (char *) msg); dump_out_shammx(buf, size, index); } void dump_stuff_shammx64(void * buf, unsigned int size, unsigned int index) { unsigned int i; for (i = 0; i < size; i++) { printf("%.2x", ((unsigned char *) buf)[SHA64GETPOS(i, index)]); if ((i % 4) == 3) printf(" "); } printf("\n"); } void dump_stuff_shammx64_msg(const void * msg, void * buf, unsigned int size, unsigned int index) { printf("%s : ", (char *) msg); dump_stuff_shammx64(buf, size, index); } void dump_stuff_mmx64(void * buf, unsigned int size, unsigned int index) { unsigned int i; for (i = 0; i < size; i++) { printf("%.2x", ((unsigned char *) buf)[SHA64GETPOSne(i, index)]); if ((i % 4) == 3) printf(" "); } printf("\n"); } void dump_stuff_mmx64_msg(const void * msg, void * buf, unsigned int size, unsigned int index) { printf("%s : ", (char *) msg); dump_stuff_mmx64(buf, size, index); } void dump_out_shammx64(void * buf, unsigned int size, unsigned int index) { unsigned int i; for (i = 0; i < size; i++) { printf("%.2x", ((unsigned char *) buf)[SHA64GETOUTPOS(i, index)]); if ((i % 4) == 3) printf(" "); } printf("\n"); } void dump_out_shammx64_msg(const void * msg, void * buf, unsigned int size, unsigned int index) { printf("%s : ", (char *) msg); dump_out_shammx64(buf, size, index); } #endif void alter_endianity_w(void * _x, unsigned int count) { int i = -1; ARCH_WORD_32 * x = (ARCH_WORD_32 *) _x; #if ARCH_ALLOWS_UNALIGNED while (++i < (int) count) { x[i] = JOHNSWAP(x[i]); } #else unsigned char *cpX, c; if (is_aligned(x, sizeof(ARCH_WORD_32))) { // we are in alignment. while (++i < (int) count) { x[i] = JOHNSWAP(x[i]); } return; } // non-aligned data :( cpX = (unsigned char *) x; while (++i < (int) count) { c = *cpX; *cpX = cpX[3]; cpX[3] = c; c = cpX[1]; cpX[1] = cpX[2]; cpX[2] = c; cpX += 4; } #endif } void alter_endianity_w64(void * _x, unsigned int count) { int i = -1; ARCH_WORD_64 * x = (ARCH_WORD_64 *) _x; #if ARCH_ALLOWS_UNALIGNED while (++i < (int) count) { x[i] = JOHNSWAP64(x[i]); } #else unsigned char *cpX, c; if (is_aligned(x, sizeof(ARCH_WORD_64))) { // we are in alignment. while (++i < (int) count) { x[i] = JOHNSWAP64(x[i]); } return; } // non-aligned data :( cpX = (unsigned char *) x; while (++i < (int) count) { c = *cpX; *cpX = cpX[7]; cpX[7] = c; c = cpX[1]; cpX[1] = cpX[6]; cpX[6] = c; c = cpX[2]; cpX[2] = cpX[5]; cpX[5] = c; c = cpX[3]; cpX[3] = cpX[4]; cpX[4] = c; cpX += 8; } #endif } aircrack-ng-1.6/lib/ce-wpa/simd-intrinsics.c000066400000000000000000002726331361312141100207540ustar00rootroot00000000000000/* * Based on John the Ripper and modified to integrate with aircrack * * John the Ripper copyright and license. * * John the Ripper password cracker, * Copyright (c) 1996-2013 by Solar Designer. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * As a special exception to the GNU General Public License terms, * permission is hereby granted to link the code of this program, with or * without modification, with any version of the OpenSSL library and/or any * version of unRAR, and to distribute such linked combinations. You must * obey the GNU GPL in all respects for all of the code used other than * OpenSSL and unRAR. If you modify this program, you may extend this * exception to your version of the program, but you are not obligated to * do so. (In other words, you may release your derived work under pure * GNU GPL version 2 or later as published by the FSF.) * * (This exception from the GNU GPL is not required for the core tree of * John the Ripper, but arguably it is required for -jumbo.) * * Relaxed terms for certain components. * * In addition or alternatively to the license above, many components are * available to you under more relaxed terms (most commonly under cut-down * BSD license) as specified in the corresponding source files. * * For more information on John the Ripper licensing please visit: * * http://www.openwall.com/john/doc/LICENSE.shtml * * This software is * Copyright (c) 2010 bartavelle, , * Copyright (c) 2012 Solar Designer, * Copyright (c) 2011-2015 JimF, * Copyright (c) 2011-2015 magnum, * and it is hereby released to the general public under the following terms: * Redistribution and use in source and binary forms, with or without * modification, are permitted. * * SHA-2 Copyright 2013, epixoip. Redistribution and use in source and binary * forms, with or without modification, are permitted provided that * redistribution of source retains the above copyright. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include "aircrack-ng/ce-wpa/arch.h" #include "aircrack-ng/ce-wpa/pseudo_intrinsics.h" #include "aircrack-ng/ce-wpa/memory.h" #include "aircrack-ng/ce-wpa/johnswap.h" #include "aircrack-ng/ce-wpa/simd-intrinsics-load-flags.h" #include "aircrack-ng/ce-wpa/aligned.h" #include "aircrack-ng/ce-wpa/misc.h" #include "aircrack-ng/ce-wpa/memdbg.h" /* Shorter names for use in index calculations */ #define VS32 SIMD_COEF_32 #define VS64 SIMD_COEF_64 #if SIMD_PARA_MD5 #define MD5_SSE_NUM_KEYS (SIMD_COEF_32 * SIMD_PARA_MD5) #define MD5_PARA_DO(x) for ((x) = 0; (x) < SIMD_PARA_MD5; (x)++) #define MD5_F(x, y, z) tmp[i] = vcmov((y[i]), (z[i]), (x[i])); #define MD5_G(x, y, z) tmp[i] = vcmov((x[i]), (y[i]), (z[i])); #if __AVX512F__ #define MD5_H(x, y, z) tmp[i] = vternarylogic(x[i], y[i], z[i], 0x96); #define MD5_H2(x, y, z) tmp[i] = vternarylogic(x[i], y[i], z[i], 0x96); #elif 1 #define MD5_H(x, y, z) \ tmp2[i] = vxor((x[i]), (y[i])); \ tmp[i] = vxor(tmp2[i], (z[i])); #define MD5_H2(x, y, z) tmp[i] = vxor((x[i]), tmp2[i]); #else #define MD5_H(x, y, z) \ tmp[i] = vxor((x[i]), (y[i])); \ tmp[i] = vxor((tmp[i]), (z[i])); #define MD5_H2(x, y, z) \ tmp[i] = vxor((y[i]), (z[i])); \ tmp[i] = vxor((tmp[i]), (x[i])); #endif #if __AVX512F__ #define MD5_I(x, y, z) tmp[i] = vternarylogic(x[i], y[i], z[i], 0x39); #elif __ARM_NEON__ #define MD5_I(x, y, z) \ tmp[i] = vorn((x[i]), (z[i])); \ tmp[i] = vxor((tmp[i]), (y[i])); #elif !VCMOV_EMULATED #define MD5_I(x, y, z) \ tmp[i] = vcmov((x[i]), mask, (z[i])); \ tmp[i] = vxor((tmp[i]), (y[i])); #else #define MD5_I(x, y, z) \ tmp[i] = vandnot((z[i]), mask); \ tmp[i] = vor((tmp[i]), (x[i])); \ tmp[i] = vxor((tmp[i]), (y[i])); #endif #define MD5_STEP(f, a, b, c, d, x, t, s) \ MD5_PARA_DO(i) \ { \ a[i] = vadd_epi32(a[i], vset1_epi32(t)); \ a[i] = vadd_epi32(a[i], data[i * 16 + x]); \ f((b), (c), (d)) a[i] = vadd_epi32(a[i], tmp[i]); \ a[i] = vroti_epi32(a[i], (s)); \ a[i] = vadd_epi32(a[i], b[i]); \ } #define MD5_STEP_r16(f, a, b, c, d, x, t, s) \ MD5_PARA_DO(i) \ { \ a[i] = vadd_epi32(a[i], vset1_epi32(t)); \ a[i] = vadd_epi32(a[i], data[i * 16 + x]); \ f((b), (c), (d)) a[i] = vadd_epi32(a[i], tmp[i]); \ a[i] = vroti16_epi32(a[i], (s)); \ a[i] = vadd_epi32(a[i], b[i]); \ } #define INIT_A 0x67452301 void md5_reverse(uint32_t * hash) { hash[0] -= INIT_A; } void md5_unreverse(uint32_t * hash) { hash[0] += INIT_A; } #undef INIT_A void SIMDmd5body(vtype * _data, unsigned int * out, ARCH_WORD_32 * reload_state, unsigned SSEi_flags) { vtype w[16 * SIMD_PARA_MD5]; vtype a[SIMD_PARA_MD5]; vtype b[SIMD_PARA_MD5]; vtype c[SIMD_PARA_MD5]; vtype d[SIMD_PARA_MD5]; vtype tmp[SIMD_PARA_MD5]; #if !__AVX512F__ vtype tmp2[SIMD_PARA_MD5]; #endif unsigned int i; vtype * data; #if !__AVX512F__ && !__ARM_NEON__ vtype mask; mask = vset1_epi32(0xffffffff); #endif if (SSEi_flags & SSEi_FLAT_IN) { // Move _data to __data, mixing it SIMD_COEF_32 wise. #if __SSE4_1__ || __MIC__ unsigned k; vtype * W = w; ARCH_WORD_32 * saved_key = (ARCH_WORD_32 *) _data; MD5_PARA_DO(k) { if (SSEi_flags & SSEi_4BUF_INPUT) { for (i = 0; i < 16; ++i) { GATHER_4x(W[i], saved_key, i); } saved_key += (VS32 << 6); } else if (SSEi_flags & SSEi_2BUF_INPUT) { for (i = 0; i < 16; ++i) { GATHER_2x(W[i], saved_key, i); } saved_key += (VS32 << 5); } else { for (i = 0; i < 16; ++i) { GATHER(W[i], saved_key, i); } saved_key += (VS32 << 4); } W += 16; } #else unsigned j, k; ARCH_WORD_32 * p = (ARCH_WORD_32 *) w; vtype * W = w; ARCH_WORD_32 * saved_key = (ARCH_WORD_32 *) _data; MD5_PARA_DO(k) { if (SSEi_flags & SSEi_4BUF_INPUT) { for (j = 0; j < 16; j++) for (i = 0; i < VS32; i++) *p++ = saved_key[(i << 6) + j]; saved_key += (VS32 << 6); } else if (SSEi_flags & SSEi_2BUF_INPUT) { for (j = 0; j < 16; j++) for (i = 0; i < VS32; i++) *p++ = saved_key[(i << 5) + j]; saved_key += (VS32 << 5); } else { for (j = 0; j < 16; j++) for (i = 0; i < VS32; i++) *p++ = saved_key[(i << 4) + j]; saved_key += (VS32 << 4); } W += 16; } #endif // now set our data pointer to point to this 'mixed' data. data = w; } else data = _data; if ((SSEi_flags & SSEi_RELOAD) == 0) { MD5_PARA_DO(i) { a[i] = vset1_epi32(0x67452301); b[i] = vset1_epi32(0xefcdab89); c[i] = vset1_epi32(0x98badcfe); d[i] = vset1_epi32(0x10325476); } } else { if ((SSEi_flags & SSEi_RELOAD_INP_FMT) == SSEi_RELOAD_INP_FMT) { MD5_PARA_DO(i) { a[i] = vload((vtype *) &reload_state[i * 16 * VS32 + 0 * VS32]); b[i] = vload((vtype *) &reload_state[i * 16 * VS32 + 1 * VS32]); c[i] = vload((vtype *) &reload_state[i * 16 * VS32 + 2 * VS32]); d[i] = vload((vtype *) &reload_state[i * 16 * VS32 + 3 * VS32]); } } else { MD5_PARA_DO(i) { a[i] = vload((vtype *) &reload_state[i * 4 * VS32 + 0 * VS32]); b[i] = vload((vtype *) &reload_state[i * 4 * VS32 + 1 * VS32]); c[i] = vload((vtype *) &reload_state[i * 4 * VS32 + 2 * VS32]); d[i] = vload((vtype *) &reload_state[i * 4 * VS32 + 3 * VS32]); } } } /* Round 1 */ MD5_STEP(MD5_F, a, b, c, d, 0, 0xd76aa478, 7) MD5_STEP(MD5_F, d, a, b, c, 1, 0xe8c7b756, 12) MD5_STEP(MD5_F, c, d, a, b, 2, 0x242070db, 17) MD5_STEP(MD5_F, b, c, d, a, 3, 0xc1bdceee, 22) MD5_STEP(MD5_F, a, b, c, d, 4, 0xf57c0faf, 7) MD5_STEP(MD5_F, d, a, b, c, 5, 0x4787c62a, 12) MD5_STEP(MD5_F, c, d, a, b, 6, 0xa8304613, 17) MD5_STEP(MD5_F, b, c, d, a, 7, 0xfd469501, 22) MD5_STEP(MD5_F, a, b, c, d, 8, 0x698098d8, 7) MD5_STEP(MD5_F, d, a, b, c, 9, 0x8b44f7af, 12) MD5_STEP(MD5_F, c, d, a, b, 10, 0xffff5bb1, 17) MD5_STEP(MD5_F, b, c, d, a, 11, 0x895cd7be, 22) MD5_STEP(MD5_F, a, b, c, d, 12, 0x6b901122, 7) MD5_STEP(MD5_F, d, a, b, c, 13, 0xfd987193, 12) MD5_STEP(MD5_F, c, d, a, b, 14, 0xa679438e, 17) MD5_STEP(MD5_F, b, c, d, a, 15, 0x49b40821, 22) /* Round 2 */ MD5_STEP(MD5_G, a, b, c, d, 1, 0xf61e2562, 5) MD5_STEP(MD5_G, d, a, b, c, 6, 0xc040b340, 9) MD5_STEP(MD5_G, c, d, a, b, 11, 0x265e5a51, 14) MD5_STEP(MD5_G, b, c, d, a, 0, 0xe9b6c7aa, 20) MD5_STEP(MD5_G, a, b, c, d, 5, 0xd62f105d, 5) MD5_STEP(MD5_G, d, a, b, c, 10, 0x02441453, 9) MD5_STEP(MD5_G, c, d, a, b, 15, 0xd8a1e681, 14) MD5_STEP(MD5_G, b, c, d, a, 4, 0xe7d3fbc8, 20) MD5_STEP(MD5_G, a, b, c, d, 9, 0x21e1cde6, 5) MD5_STEP(MD5_G, d, a, b, c, 14, 0xc33707d6, 9) MD5_STEP(MD5_G, c, d, a, b, 3, 0xf4d50d87, 14) MD5_STEP(MD5_G, b, c, d, a, 8, 0x455a14ed, 20) MD5_STEP(MD5_G, a, b, c, d, 13, 0xa9e3e905, 5) MD5_STEP(MD5_G, d, a, b, c, 2, 0xfcefa3f8, 9) MD5_STEP(MD5_G, c, d, a, b, 7, 0x676f02d9, 14) MD5_STEP(MD5_G, b, c, d, a, 12, 0x8d2a4c8a, 20) /* Round 3 */ MD5_STEP(MD5_H, a, b, c, d, 5, 0xfffa3942, 4) MD5_STEP(MD5_H2, d, a, b, c, 8, 0x8771f681, 11) MD5_STEP_r16(MD5_H, c, d, a, b, 11, 0x6d9d6122, 16) MD5_STEP( MD5_H2, b, c, d, a, 14, 0xfde5380c, 23) MD5_STEP(MD5_H, a, b, c, d, 1, 0xa4beea44, 4) MD5_STEP( MD5_H2, d, a, b, c, 4, 0x4bdecfa9, 11) MD5_STEP_r16(MD5_H, c, d, a, b, 7, 0xf6bb4b60, 16) MD5_STEP( MD5_H2, b, c, d, a, 10, 0xbebfbc70, 23) MD5_STEP(MD5_H, a, b, c, d, 13, 0x289b7ec6, 4) MD5_STEP( MD5_H2, d, a, b, c, 0, 0xeaa127fa, 11) MD5_STEP_r16(MD5_H, c, d, a, b, 3, 0xd4ef3085, 16) MD5_STEP( MD5_H2, b, c, d, a, 6, 0x04881d05, 23) MD5_STEP(MD5_H, a, b, c, d, 9, 0xd9d4d039, 4) MD5_STEP( MD5_H2, d, a, b, c, 12, 0xe6db99e5, 11) MD5_STEP_r16(MD5_H, c, d, a, b, 15, 0x1fa27cf8, 16) MD5_STEP(MD5_H2, b, c, d, a, 2, 0xc4ac5665, 23) /* Round 4 */ MD5_STEP(MD5_I, a, b, c, d, 0, 0xf4292244, 6) MD5_STEP( MD5_I, d, a, b, c, 7, 0x432aff97, 10) MD5_STEP(MD5_I, c, d, a, b, 14, 0xab9423a7, 15) MD5_STEP( MD5_I, b, c, d, a, 5, 0xfc93a039, 21) MD5_STEP(MD5_I, a, b, c, d, 12, 0x655b59c3, 6) MD5_STEP( MD5_I, d, a, b, c, 3, 0x8f0ccc92, 10) MD5_STEP(MD5_I, c, d, a, b, 10, 0xffeff47d, 15) MD5_STEP( MD5_I, b, c, d, a, 1, 0x85845dd1, 21) MD5_STEP(MD5_I, a, b, c, d, 8, 0x6fa87e4f, 6) MD5_STEP( MD5_I, d, a, b, c, 15, 0xfe2ce6e0, 10) MD5_STEP(MD5_I, c, d, a, b, 6, 0xa3014314, 15) MD5_STEP(MD5_I, b, c, d, a, 13, 0x4e0811a1, 21) MD5_STEP( MD5_I, a, b, c, d, 4, 0xf7537e82, 6) if (SSEi_flags & SSEi_REVERSE_STEPS) { MD5_PARA_DO(i) { vstore((vtype *) &out[i * 4 * VS32 + 0 * VS32], a[i]); } return; } MD5_STEP(MD5_I, d, a, b, c, 11, 0xbd3af235, 10) MD5_STEP(MD5_I, c, d, a, b, 2, 0x2ad7d2bb, 15) MD5_STEP(MD5_I, b, c, d, a, 9, 0xeb86d391, 21) if ((SSEi_flags & SSEi_RELOAD) == 0) { MD5_PARA_DO(i) { a[i] = vadd_epi32(a[i], vset1_epi32(0x67452301)); b[i] = vadd_epi32(b[i], vset1_epi32(0xefcdab89)); c[i] = vadd_epi32(c[i], vset1_epi32(0x98badcfe)); d[i] = vadd_epi32(d[i], vset1_epi32(0x10325476)); } } else { if ((SSEi_flags & SSEi_RELOAD_INP_FMT) == SSEi_RELOAD_INP_FMT) { MD5_PARA_DO(i) { a[i] = vadd_epi32( a[i], vload((vtype *) &reload_state[i * 16 * VS32 + 0 * VS32])); b[i] = vadd_epi32( b[i], vload((vtype *) &reload_state[i * 16 * VS32 + 1 * VS32])); c[i] = vadd_epi32( c[i], vload((vtype *) &reload_state[i * 16 * VS32 + 2 * VS32])); d[i] = vadd_epi32( d[i], vload((vtype *) &reload_state[i * 16 * VS32 + 3 * VS32])); } } else { MD5_PARA_DO(i) { a[i] = vadd_epi32( a[i], vload((vtype *) &reload_state[i * 4 * VS32 + 0 * VS32])); b[i] = vadd_epi32( b[i], vload((vtype *) &reload_state[i * 4 * VS32 + 1 * VS32])); c[i] = vadd_epi32( c[i], vload((vtype *) &reload_state[i * 4 * VS32 + 2 * VS32])); d[i] = vadd_epi32( d[i], vload((vtype *) &reload_state[i * 4 * VS32 + 3 * VS32])); } } } #if USE_EXPERIMENTAL /* * This is currently not used for MD5, and was observed to result * in a significant performance regression (at least on XOP) just by sitting * here. http://www.openwall.com/lists/john-dev/2015/09/05/5 * NOTE the regression might be gone now anyway since we went from -O3 to -O2. */ if (SSEi_flags & SSEi_FLAT_OUT) { MD5_PARA_DO(i) { uint32_t * o = (uint32_t *) &out[i * 4 * VS32]; #if __AVX512F__ || __MIC__ vtype idxs = vset_epi32(15 * 4, 14 * 4, 13 * 4, 12 * 4, 11 * 4, 10 * 4, 9 * 4, 8 * 4, 7 * 4, 6 * 4, 5 * 4, 4 * 4, 3 * 4, 2 * 4, 1 * 4, 0 * 4); vscatter_epi32(o + 0, idxs, a[i], 4); vscatter_epi32(o + 1, idxs, b[i], 4); vscatter_epi32(o + 2, idxs, c[i], 4); vscatter_epi32(o + 3, idxs, d[i], 4); #else uint32_t j, k; union { vtype v[4]; uint32_t s[4 * VS32]; } tmp; tmp.v[0] = a[i]; tmp.v[1] = b[i]; tmp.v[2] = c[i]; tmp.v[3] = d[i]; for (j = 0; j < VS32; j++) for (k = 0; k < 4; k++) o[j * 4 + k] = tmp.s[k * VS32 + j]; #endif } } else #endif if (SSEi_flags & SSEi_OUTPUT_AS_INP_FMT) { if ((SSEi_flags & SSEi_OUTPUT_AS_2BUF_INP_FMT) == SSEi_OUTPUT_AS_2BUF_INP_FMT) { MD5_PARA_DO(i) { vstore((vtype *) &out[i * 32 * VS32 + 0 * VS32], a[i]); vstore((vtype *) &out[i * 32 * VS32 + 1 * VS32], b[i]); vstore((vtype *) &out[i * 32 * VS32 + 2 * VS32], c[i]); vstore((vtype *) &out[i * 32 * VS32 + 3 * VS32], d[i]); } } else { MD5_PARA_DO(i) { vstore((vtype *) &out[i * 16 * VS32 + 0 * VS32], a[i]); vstore((vtype *) &out[i * 16 * VS32 + 1 * VS32], b[i]); vstore((vtype *) &out[i * 16 * VS32 + 2 * VS32], c[i]); vstore((vtype *) &out[i * 16 * VS32 + 3 * VS32], d[i]); } } } else { MD5_PARA_DO(i) { vstore((vtype *) &out[i * 4 * VS32 + 0 * VS32], a[i]); vstore((vtype *) &out[i * 4 * VS32 + 1 * VS32], b[i]); vstore((vtype *) &out[i * 4 * VS32 + 2 * VS32], c[i]); vstore((vtype *) &out[i * 4 * VS32 + 3 * VS32], d[i]); } } } #define GETPOS(i, index) \ ((index & (VS32 - 1)) * 4 + (i & (0xffffffff - 3)) * VS32 + ((i) &3)) static MAYBE_INLINE void mmxput(void * buf, unsigned int index, unsigned int bid, unsigned int offset, unsigned char * src, unsigned int len) { unsigned char * nbuf; unsigned int i; nbuf = ((unsigned char *) buf) + index / VS32 * 64 * VS32 + bid * 64 * MD5_SSE_NUM_KEYS; for (i = 0; i < len; i++) nbuf[GETPOS((offset + i), index)] = src[i]; } static MAYBE_INLINE void mmxput2(void * buf, unsigned int bid, void * src) { unsigned char * nbuf; unsigned int i; nbuf = ((unsigned char *) buf) + bid * 64 * MD5_SSE_NUM_KEYS; MD5_PARA_DO(i) memcpy(nbuf + i * 64 * VS32, ((unsigned char *) src) + i * 16 * VS32, 16 * VS32); } #if (ARCH_SIZE >= 8) || defined(__i386__) || defined(__ARM_NEON__) #define BITALIGN(hi, lo, s) ((((uint64_t)(hi) << 32) | (lo)) >> (s)) #else #define BITALIGN(hi, lo, s) (((hi) << (32 - (s))) | ((lo) >> (s))) #endif static MAYBE_INLINE void mmxput3(void * buf, unsigned int bid, unsigned int * offset, unsigned int mult, unsigned int saltlen, void * src) { unsigned int j; MD5_PARA_DO(j) { unsigned int i; unsigned int jm = j * VS32 * 4; unsigned char * nbuf = ((unsigned char *) buf) + bid * (64 * MD5_SSE_NUM_KEYS) + jm * 16; unsigned int * s = (unsigned int *) src + jm; for (i = 0; i < VS32; i++, s++) { unsigned int n = offset[i + jm / 4] * mult + saltlen; unsigned int * d = (unsigned int *) (nbuf + (n & ~3U) * VS32) + i; switch (n &= 3) { case 0: d[0] = s[0]; d[1 * VS32] = s[1 * VS32]; d[2 * VS32] = s[2 * VS32]; d[3 * VS32] = s[3 * VS32]; break; #if 0 default: n <<= 3; { unsigned int m = 32 - n; d[0] = (d[0] & (0xffffffffU >> m)) | (s[0] << n); d[1 * VS32] = BITALIGN(s[1 * VS32], s[0], m); d[2 * VS32] = BITALIGN(s[2 * VS32], s[1 * VS32], m); d[3 * VS32] = BITALIGN(s[3 * VS32], s[2 * VS32], m); d[4 * VS32] = (d[4 * VS32] & (0xffffffffU << n)) | (s[3 * VS32] >> m); } #else case 1: d[0] = (d[0] & 0xffU) | (s[0] << 8); d[1 * VS32] = BITALIGN(s[1 * VS32], s[0], 24); d[2 * VS32] = BITALIGN(s[2 * VS32], s[1 * VS32], 24); d[3 * VS32] = BITALIGN(s[3 * VS32], s[2 * VS32], 24); d[4 * VS32] = (d[4 * VS32] & 0xffffff00U) | (s[3 * VS32] >> 24); break; case 2: d[0] = (d[0] & 0xffffU) | (s[0] << 16); d[1 * VS32] = BITALIGN(s[1 * VS32], s[0], 16); d[2 * VS32] = BITALIGN(s[2 * VS32], s[1 * VS32], 16); d[3 * VS32] = BITALIGN(s[3 * VS32], s[2 * VS32], 16); d[4 * VS32] = (d[4 * VS32] & 0xffff0000U) | (s[3 * VS32] >> 16); break; case 3: d[0] = (d[0] & 0xffffffU) | (s[0] << 24); d[1 * VS32] = BITALIGN(s[1 * VS32], s[0], 8); d[2 * VS32] = BITALIGN(s[2 * VS32], s[1 * VS32], 8); d[3 * VS32] = BITALIGN(s[3 * VS32], s[2 * VS32], 8); d[4 * VS32] = (d[4 * VS32] & 0xff000000U) | (s[3 * VS32] >> 8); #endif } } } } static MAYBE_INLINE void dispatch(unsigned char buffers[8] [64 * MD5_SSE_NUM_KEYS], unsigned int f[4 * MD5_SSE_NUM_KEYS], unsigned int length[MD5_SSE_NUM_KEYS], unsigned int saltlen) { unsigned int i, j; unsigned int bufferid; i = 1000 / 42; j = 0; do { switch (j) { case 0: bufferid = 0; mmxput2(buffers, bufferid, f); break; case 21: bufferid = 1; mmxput3(buffers, bufferid, length, 1, 0, f); break; case 3: case 9: case 15: case 27: case 33: case 39: bufferid = 2; mmxput3(buffers, bufferid, length, 2, 0, f); break; case 6: case 12: case 18: case 24: case 30: case 36: bufferid = 3; mmxput2(buffers, bufferid, f); break; case 7: case 35: bufferid = 4; mmxput3(buffers, bufferid, length, 1, saltlen, f); break; case 14: case 28: bufferid = 5; mmxput2(buffers, bufferid, f); break; case 2: case 4: case 8: case 10: case 16: case 20: case 22: case 26: case 32: case 34: case 38: case 40: bufferid = 6; mmxput2(buffers, bufferid, f); break; default: bufferid = 7; mmxput3(buffers, bufferid, length, 2, saltlen, f); break; } SIMDmd5body((vtype *) &buffers[bufferid], f, NULL, SSEi_MIXED_IN); if (j++ < 1000 % 42 - 1) continue; if (j == 1000 % 42) { if (!i) break; i--; continue; } if (j >= 42) j = 0; } while (1); } void md5cryptsse(unsigned char pwd[MD5_SSE_NUM_KEYS][16], unsigned char * salt, char * out, unsigned int md5_type) { unsigned int length[MD5_SSE_NUM_KEYS]; unsigned int saltlen; unsigned int i, j; MD5_CTX ctx; MD5_CTX tctx; JTR_ALIGN(MEM_ALIGN_SIMD) unsigned char buffers[8][64 * MD5_SSE_NUM_KEYS] = {{0}}; JTR_ALIGN(MEM_ALIGN_SIMD) unsigned int F[4 * MD5_SSE_NUM_KEYS]; saltlen = strlen((char *) salt); for (i = 0; i < MD5_SSE_NUM_KEYS; i++) { unsigned int length_i = strlen((char *) pwd[i]); unsigned int * bt; unsigned int tf[4]; /* cas 0 fs */ mmxput(buffers, i, 0, 16, pwd[i], length_i); mmxput(buffers, i, 0, length_i + 16, (unsigned char *) "\x80", 1); /* cas 1 sf */ mmxput(buffers, i, 1, 0, pwd[i], length_i); mmxput(buffers, i, 1, length_i + 16, (unsigned char *) "\x80", 1); /* cas 2 ssf */ mmxput(buffers, i, 2, 0, pwd[i], length_i); mmxput(buffers, i, 2, length_i, pwd[i], length_i); mmxput(buffers, i, 2, length_i * 2 + 16, (unsigned char *) "\x80", 1); /* cas 3 fss */ mmxput(buffers, i, 3, 16, pwd[i], length_i); mmxput(buffers, i, 3, 16 + length_i, pwd[i], length_i); mmxput(buffers, i, 3, length_i * 2 + 16, (unsigned char *) "\x80", 1); /* cas 4 scf */ mmxput(buffers, i, 4, 0, pwd[i], length_i); mmxput(buffers, i, 4, length_i, salt, saltlen); mmxput(buffers, i, 4, saltlen + length_i + 16, (unsigned char *) "\x80", 1); /* cas 5 fcs */ mmxput(buffers, i, 5, 16, salt, saltlen); mmxput(buffers, i, 5, 16 + saltlen, pwd[i], length_i); mmxput(buffers, i, 5, saltlen + length_i + 16, (unsigned char *) "\x80", 1); /* cas 6 fcss */ mmxput(buffers, i, 6, 16, salt, saltlen); mmxput(buffers, i, 6, 16 + saltlen, pwd[i], length_i); mmxput(buffers, i, 6, 16 + saltlen + length_i, pwd[i], length_i); mmxput(buffers, i, 6, saltlen + 2 * length_i + 16, (unsigned char *) "\x80", 1); /* cas 7 scsf */ mmxput(buffers, i, 7, 0, pwd[i], length_i); mmxput(buffers, i, 7, length_i, salt, saltlen); mmxput(buffers, i, 7, length_i + saltlen, pwd[i], length_i); mmxput(buffers, i, 7, saltlen + 2 * length_i + 16, (unsigned char *) "\x80", 1); bt = (unsigned int *) &buffers[0]; bt[14 * VS32 + (i & (VS32 - 1)) + i / VS32 * 16 * VS32] = (length_i + 16) << 3; bt = (unsigned int *) &buffers[1]; bt[14 * VS32 + (i & (VS32 - 1)) + i / VS32 * 16 * VS32] = (length_i + 16) << 3; bt = (unsigned int *) &buffers[2]; bt[14 * VS32 + (i & (VS32 - 1)) + i / VS32 * 16 * VS32] = (length_i * 2 + 16) << 3; bt = (unsigned int *) &buffers[3]; bt[14 * VS32 + (i & (VS32 - 1)) + i / VS32 * 16 * VS32] = (length_i * 2 + 16) << 3; bt = (unsigned int *) &buffers[4]; bt[14 * VS32 + (i & (VS32 - 1)) + i / VS32 * 16 * VS32] = (length_i + saltlen + 16) << 3; bt = (unsigned int *) &buffers[5]; bt[14 * VS32 + (i & (VS32 - 1)) + i / VS32 * 16 * VS32] = (length_i + saltlen + 16) << 3; bt = (unsigned int *) &buffers[6]; bt[14 * VS32 + (i & (VS32 - 1)) + i / VS32 * 16 * VS32] = (length_i * 2 + saltlen + 16) << 3; bt = (unsigned int *) &buffers[7]; bt[14 * VS32 + (i & (VS32 - 1)) + i / VS32 * 16 * VS32] = (length_i * 2 + saltlen + 16) << 3; MD5_Init(&ctx); MD5_Update(&ctx, pwd[i], length_i); if (md5_type == MD5_TYPE_STD) MD5_Update(&ctx, "$1$", 3); else if (md5_type == MD5_TYPE_APACHE) MD5_Update(&ctx, "$apr1$", 6); // else it's AIX and no prefix included MD5_Update(&ctx, salt, saltlen); MD5_Init(&tctx); MD5_Update(&tctx, pwd[i], length_i); MD5_Update(&tctx, salt, saltlen); MD5_Update(&tctx, pwd[i], length_i); MD5_Final((unsigned char *) tf, &tctx); MD5_Update(&ctx, tf, length_i); length[i] = length_i; for (j = length_i; j; j >>= 1) if (j & 1) MD5_Update(&ctx, "\0", 1); else MD5_Update(&ctx, pwd[i], 1); MD5_Final((unsigned char *) tf, &ctx); F[i / VS32 * 4 * VS32 + (i & (VS32 - 1)) + 0 * VS32] = tf[0]; F[i / VS32 * 4 * VS32 + (i & (VS32 - 1)) + 1 * VS32] = tf[1]; F[i / VS32 * 4 * VS32 + (i & (VS32 - 1)) + 2 * VS32] = tf[2]; F[i / VS32 * 4 * VS32 + (i & (VS32 - 1)) + 3 * VS32] = tf[3]; } dispatch(buffers, F, length, saltlen); memcpy(out, F, MD5_SSE_NUM_KEYS * 16); } #endif /* SIMD_PARA_MD5 */ #if SIMD_PARA_MD4 #define MD4_SSE_NUM_KEYS (SIMD_COEF_32 * SIMD_PARA_MD4) #define MD4_PARA_DO(x) for ((x) = 0; (x) < SIMD_PARA_MD4; (x)++) #define MD4_F(x, y, z) tmp[i] = vcmov((y[i]), (z[i]), (x[i])); #if __AVX512F__ #define MD4_G(x, y, z) tmp[i] = vternarylogic(x[i], y[i], z[i], 0xE8); #elif !VCMOV_EMULATED #define MD4_G(x, y, z) \ tmp[i] = vxor((y[i]), (z[i])); \ tmp[i] = vcmov((x[i]), (z[i]), (tmp[i])); #else #define MD4_G(x, y, z) \ tmp[i] = vor((y[i]), (z[i])); \ tmp2[i] = vand((y[i]), (z[i])); \ tmp[i] = vand((tmp[i]), (x[i])); \ tmp[i] = vor((tmp[i]), (tmp2[i])); #endif #if __AVX512F__ #define MD4_H(x, y, z) tmp[i] = vternarylogic(x[i], y[i], z[i], 0x96); #define MD4_H2(x, y, z) tmp[i] = vternarylogic(x[i], y[i], z[i], 0x96); #elif SIMD_PARA_MD4 < 3 #define MD4_H(x, y, z) \ tmp2[i] = vxor((x[i]), (y[i])); \ tmp[i] = vxor(tmp2[i], (z[i])); #define MD4_H2(x, y, z) tmp[i] = vxor((x[i]), tmp2[i]); #else #define MD4_H(x, y, z) \ tmp[i] = vxor((x[i]), (y[i])); \ tmp[i] = vxor((tmp[i]), (z[i])); #define MD4_H2(x, y, z) \ tmp[i] = vxor((y[i]), (z[i])); \ tmp[i] = vxor((tmp[i]), (x[i])); #endif #define MD4_STEP(f, a, b, c, d, x, t, s) \ MD4_PARA_DO(i) \ { \ a[i] = vadd_epi32(a[i], t); \ f((b), (c), (d)) a[i] = vadd_epi32(a[i], tmp[i]); \ a[i] = vadd_epi32(a[i], data[i * 16 + x]); \ a[i] = vroti_epi32(a[i], (s)); \ } #define MD4_REV_STEP(f, a, b, c, d, x, t, s) \ MD4_PARA_DO(i) \ { \ f((b), (c), (d)) a[i] = vadd_epi32(a[i], tmp[i]); \ a[i] = vadd_epi32(a[i], data[i * 16 + x]); \ } #define INIT_A 0x67452301 #define INIT_B 0xefcdab89 #define INIT_C 0x98badcfe #define INIT_D 0x10325476 #define SQRT_3 0x6ed9eba1 void md4_reverse(uint32_t * hash) { hash[0] -= INIT_A; hash[1] -= INIT_B; hash[2] -= INIT_C; hash[3] -= INIT_D; hash[1] = (hash[1] >> 15) | (hash[1] << 17); hash[1] -= SQRT_3 + (hash[2] ^ hash[3] ^ hash[0]); hash[1] = (hash[1] >> 15) | (hash[1] << 17); hash[1] -= SQRT_3; } void md4_unreverse(uint32_t * hash) { hash[1] += SQRT_3; hash[1] = (hash[1] >> 17) | (hash[1] << 15); hash[1] += SQRT_3 + (hash[2] ^ hash[3] ^ hash[0]); hash[1] = (hash[1] >> 17) | (hash[1] << 15); hash[3] += INIT_D; hash[2] += INIT_C; hash[1] += INIT_B; hash[0] += INIT_A; } #undef SQRT_3 #undef INIT_D #undef INIT_C #undef INIT_B #undef INIT_A void SIMDmd4body(vtype * _data, unsigned int * out, ARCH_WORD_32 * reload_state, unsigned SSEi_flags) { vtype w[16 * SIMD_PARA_MD4]; vtype a[SIMD_PARA_MD4]; vtype b[SIMD_PARA_MD4]; vtype c[SIMD_PARA_MD4]; vtype d[SIMD_PARA_MD4]; vtype tmp[SIMD_PARA_MD4]; #if (SIMD_PARA_MD4 < 3 || VCMOV_EMULATED) && !__AVX512F__ vtype tmp2[SIMD_PARA_MD4]; #endif vtype cst; unsigned int i; vtype * data; if (SSEi_flags & SSEi_FLAT_IN) { // Move _data to __data, mixing it SIMD_COEF_32 wise. #if __SSE4_1__ || __MIC__ unsigned k; vtype * W = w; ARCH_WORD_32 * saved_key = (ARCH_WORD_32 *) _data; MD4_PARA_DO(k) { if (SSEi_flags & SSEi_4BUF_INPUT) { for (i = 0; i < 16; ++i) { GATHER_4x(W[i], saved_key, i); } saved_key += (VS32 << 6); } else if (SSEi_flags & SSEi_2BUF_INPUT) { for (i = 0; i < 16; ++i) { GATHER_2x(W[i], saved_key, i); } saved_key += (VS32 << 5); } else { for (i = 0; i < 16; ++i) { GATHER(W[i], saved_key, i); } saved_key += (VS32 << 4); } W += 16; } #else unsigned j, k; ARCH_WORD_32 * p = (ARCH_WORD_32 *) w; vtype * W = w; ARCH_WORD_32 * saved_key = (ARCH_WORD_32 *) _data; MD4_PARA_DO(k) { if (SSEi_flags & SSEi_4BUF_INPUT) { for (j = 0; j < 16; j++) for (i = 0; i < VS32; i++) *p++ = saved_key[(i << 6) + j]; saved_key += (VS32 << 6); } else if (SSEi_flags & SSEi_2BUF_INPUT) { for (j = 0; j < 16; j++) for (i = 0; i < VS32; i++) *p++ = saved_key[(i << 5) + j]; saved_key += (VS32 << 5); } else { for (j = 0; j < 16; j++) for (i = 0; i < VS32; i++) *p++ = saved_key[(i << 4) + j]; saved_key += (VS32 << 4); } W += 16; } #endif // now set our data pointer to point to this 'mixed' data. data = w; } else data = _data; if ((SSEi_flags & SSEi_RELOAD) == 0) { MD4_PARA_DO(i) { a[i] = vset1_epi32(0x67452301); b[i] = vset1_epi32(0xefcdab89); c[i] = vset1_epi32(0x98badcfe); d[i] = vset1_epi32(0x10325476); } } else { if ((SSEi_flags & SSEi_RELOAD_INP_FMT) == SSEi_RELOAD_INP_FMT) { MD4_PARA_DO(i) { a[i] = vload((vtype *) &reload_state[i * 16 * VS32 + 0 * VS32]); b[i] = vload((vtype *) &reload_state[i * 16 * VS32 + 1 * VS32]); c[i] = vload((vtype *) &reload_state[i * 16 * VS32 + 2 * VS32]); d[i] = vload((vtype *) &reload_state[i * 16 * VS32 + 3 * VS32]); } } else { MD4_PARA_DO(i) { a[i] = vload((vtype *) &reload_state[i * 4 * VS32 + 0 * VS32]); b[i] = vload((vtype *) &reload_state[i * 4 * VS32 + 1 * VS32]); c[i] = vload((vtype *) &reload_state[i * 4 * VS32 + 2 * VS32]); d[i] = vload((vtype *) &reload_state[i * 4 * VS32 + 3 * VS32]); } } } /* Round 1 */ cst = vsetzero(); MD4_STEP(MD4_F, a, b, c, d, 0, cst, 3) MD4_STEP(MD4_F, d, a, b, c, 1, cst, 7) MD4_STEP(MD4_F, c, d, a, b, 2, cst, 11) MD4_STEP(MD4_F, b, c, d, a, 3, cst, 19) MD4_STEP(MD4_F, a, b, c, d, 4, cst, 3) MD4_STEP(MD4_F, d, a, b, c, 5, cst, 7) MD4_STEP(MD4_F, c, d, a, b, 6, cst, 11) MD4_STEP(MD4_F, b, c, d, a, 7, cst, 19) MD4_STEP(MD4_F, a, b, c, d, 8, cst, 3) MD4_STEP(MD4_F, d, a, b, c, 9, cst, 7) MD4_STEP(MD4_F, c, d, a, b, 10, cst, 11) MD4_STEP(MD4_F, b, c, d, a, 11, cst, 19) MD4_STEP(MD4_F, a, b, c, d, 12, cst, 3) MD4_STEP(MD4_F, d, a, b, c, 13, cst, 7) MD4_STEP(MD4_F, c, d, a, b, 14, cst, 11) MD4_STEP(MD4_F, b, c, d, a, 15, cst, 19) /* Round 2 */ cst = vset1_epi32(0x5A827999L); MD4_STEP(MD4_G, a, b, c, d, 0, cst, 3) MD4_STEP(MD4_G, d, a, b, c, 4, cst, 5) MD4_STEP(MD4_G, c, d, a, b, 8, cst, 9) MD4_STEP(MD4_G, b, c, d, a, 12, cst, 13) MD4_STEP(MD4_G, a, b, c, d, 1, cst, 3) MD4_STEP(MD4_G, d, a, b, c, 5, cst, 5) MD4_STEP(MD4_G, c, d, a, b, 9, cst, 9) MD4_STEP(MD4_G, b, c, d, a, 13, cst, 13) MD4_STEP(MD4_G, a, b, c, d, 2, cst, 3) MD4_STEP(MD4_G, d, a, b, c, 6, cst, 5) MD4_STEP(MD4_G, c, d, a, b, 10, cst, 9) MD4_STEP(MD4_G, b, c, d, a, 14, cst, 13) MD4_STEP(MD4_G, a, b, c, d, 3, cst, 3) MD4_STEP(MD4_G, d, a, b, c, 7, cst, 5) MD4_STEP(MD4_G, c, d, a, b, 11, cst, 9) MD4_STEP(MD4_G, b, c, d, a, 15, cst, 13) /* Round 3 */ cst = vset1_epi32(0x6ED9EBA1L); MD4_STEP(MD4_H, a, b, c, d, 0, cst, 3) MD4_STEP(MD4_H2, d, a, b, c, 8, cst, 9) MD4_STEP(MD4_H, c, d, a, b, 4, cst, 11) MD4_STEP(MD4_H2, b, c, d, a, 12, cst, 15) MD4_STEP(MD4_H, a, b, c, d, 2, cst, 3) MD4_STEP(MD4_H2, d, a, b, c, 10, cst, 9) MD4_STEP(MD4_H, c, d, a, b, 6, cst, 11) MD4_STEP(MD4_H2, b, c, d, a, 14, cst, 15) MD4_STEP(MD4_H, a, b, c, d, 1, cst, 3) MD4_STEP(MD4_H2, d, a, b, c, 9, cst, 9) MD4_STEP(MD4_H, c, d, a, b, 5, cst, 11) if (SSEi_flags & SSEi_REVERSE_STEPS) { MD4_REV_STEP(MD4_H2, b, c, d, a, 13, cst, 15) MD4_PARA_DO(i) { vstore((vtype *) &out[i * 4 * VS32 + 1 * VS32], b[i]); } return; } MD4_STEP(MD4_H2, b, c, d, a, 13, cst, 15) MD4_STEP(MD4_H, a, b, c, d, 3, cst, 3) MD4_STEP(MD4_H2, d, a, b, c, 11, cst, 9) MD4_STEP(MD4_H, c, d, a, b, 7, cst, 11) MD4_STEP(MD4_H2, b, c, d, a, 15, cst, 15) if ((SSEi_flags & SSEi_RELOAD) == 0) { MD4_PARA_DO(i) { a[i] = vadd_epi32(a[i], vset1_epi32(0x67452301)); b[i] = vadd_epi32(b[i], vset1_epi32(0xefcdab89)); c[i] = vadd_epi32(c[i], vset1_epi32(0x98badcfe)); d[i] = vadd_epi32(d[i], vset1_epi32(0x10325476)); } } else { if ((SSEi_flags & SSEi_RELOAD_INP_FMT) == SSEi_RELOAD_INP_FMT) { MD4_PARA_DO(i) { a[i] = vadd_epi32( a[i], vload((vtype *) &reload_state[i * 16 * VS32 + 0 * VS32])); b[i] = vadd_epi32( b[i], vload((vtype *) &reload_state[i * 16 * VS32 + 1 * VS32])); c[i] = vadd_epi32( c[i], vload((vtype *) &reload_state[i * 16 * VS32 + 2 * VS32])); d[i] = vadd_epi32( d[i], vload((vtype *) &reload_state[i * 16 * VS32 + 3 * VS32])); } } else { MD4_PARA_DO(i) { a[i] = vadd_epi32( a[i], vload((vtype *) &reload_state[i * 4 * VS32 + 0 * VS32])); b[i] = vadd_epi32( b[i], vload((vtype *) &reload_state[i * 4 * VS32 + 1 * VS32])); c[i] = vadd_epi32( c[i], vload((vtype *) &reload_state[i * 4 * VS32 + 2 * VS32])); d[i] = vadd_epi32( d[i], vload((vtype *) &reload_state[i * 4 * VS32 + 3 * VS32])); } } } #if USE_EXPERIMENTAL /* * This is currently not used for MD4, and was observed to result * in a significant performance regression (at least on XOP) just by sitting * here. http://www.openwall.com/lists/john-dev/2015/09/05/5 * NOTE the regression might be gone now anyway since we went from -O3 to -O2. */ if (SSEi_flags & SSEi_FLAT_OUT) { MD4_PARA_DO(i) { uint32_t * o = (uint32_t *) &out[i * 4 * VS32]; #if __AVX512F__ || __MIC__ vtype idxs = vset_epi32(15 * 4, 14 * 4, 13 * 4, 12 * 4, 11 * 4, 10 * 4, 9 * 4, 8 * 4, 7 * 4, 6 * 4, 5 * 4, 4 * 4, 3 * 4, 2 * 4, 1 * 4, 0 * 4); vscatter_epi32(o + 0, idxs, a[i], 4); vscatter_epi32(o + 1, idxs, b[i], 4); vscatter_epi32(o + 2, idxs, c[i], 4); vscatter_epi32(o + 3, idxs, d[i], 4); #else uint32_t j, k; union { vtype v[4]; uint32_t s[4 * VS32]; } tmp; tmp.v[0] = a[i]; tmp.v[1] = b[i]; tmp.v[2] = c[i]; tmp.v[3] = d[i]; for (j = 0; j < VS32; j++) for (k = 0; k < 4; k++) o[j * 4 + k] = tmp.s[k * VS32 + j]; #endif } } else #endif if (SSEi_flags & SSEi_OUTPUT_AS_INP_FMT) { if ((SSEi_flags & SSEi_OUTPUT_AS_2BUF_INP_FMT) == SSEi_OUTPUT_AS_2BUF_INP_FMT) { MD4_PARA_DO(i) { vstore((vtype *) &out[i * 32 * VS32 + 0 * VS32], a[i]); vstore((vtype *) &out[i * 32 * VS32 + 1 * VS32], b[i]); vstore((vtype *) &out[i * 32 * VS32 + 2 * VS32], c[i]); vstore((vtype *) &out[i * 32 * VS32 + 3 * VS32], d[i]); } } else { MD4_PARA_DO(i) { vstore((vtype *) &out[i * 16 * VS32 + 0 * VS32], a[i]); vstore((vtype *) &out[i * 16 * VS32 + 1 * VS32], b[i]); vstore((vtype *) &out[i * 16 * VS32 + 2 * VS32], c[i]); vstore((vtype *) &out[i * 16 * VS32 + 3 * VS32], d[i]); } } } else { MD4_PARA_DO(i) { vstore((vtype *) &out[i * 4 * VS32 + 0 * VS32], a[i]); vstore((vtype *) &out[i * 4 * VS32 + 1 * VS32], b[i]); vstore((vtype *) &out[i * 4 * VS32 + 2 * VS32], c[i]); vstore((vtype *) &out[i * 4 * VS32 + 3 * VS32], d[i]); } } } #endif /* SIMD_PARA_MD4 */ #if SIMD_PARA_SHA1 #define SHA1_SSE_NUM_KEYS (SIMD_COEF_32 * SIMD_PARA_SHA1) #define SHA1_PARA_DO(x) for ((x) = 0; (x) < SIMD_PARA_SHA1; (x)++) #define SHA1_F(x, y, z) tmp[i] = vcmov((y[i]), (z[i]), (x[i])); #if __AVX512F__ #define SHA1_G(x, y, z) tmp[i] = vternarylogic(x[i], y[i], z[i], 0x96); #else #define SHA1_G(x, y, z) \ tmp[i] = vxor((y[i]), (z[i])); \ tmp[i] = vxor((tmp[i]), (x[i])); #endif #if __AVX512F__ #define SHA1_H(x, y, z) tmp[i] = vternarylogic(x[i], y[i], z[i], 0xE8); #elif !VCMOV_EMULATED #define SHA1_H(x, y, z) \ tmp[i] = vxor((z[i]), (y[i])); \ tmp[i] = vcmov((x[i]), (y[i]), tmp[i]); #else #define SHA1_H(x, y, z) \ tmp[i] = vand((x[i]), (y[i])); \ tmp[i] = vor((tmp[i]), vand(vor((x[i]), (y[i])), (z[i]))); #endif #define SHA1_I(x, y, z) SHA1_G(x, y, z) #define SHA1_EXPAND2a(t) \ tmp[i] = vxor(data[i * 16 + t - 3], data[i * 16 + t - 8]); \ tmp[i] = vxor(tmp[i], data[i * 16 + t - 14]); \ tmp[i] = vxor(tmp[i], data[i * 16 + t - 16]); \ w[i * 16 + ((t) &0xF)] = vroti_epi32(tmp[i], 1); #define SHA1_EXPAND2b(t) \ tmp[i] = vxor(w[i * 16 + ((t - 3) & 0xF)], data[i * 16 + t - 8]); \ tmp[i] = vxor(tmp[i], data[i * 16 + t - 14]); \ tmp[i] = vxor(tmp[i], data[i * 16 + t - 16]); \ w[i * 16 + ((t) &0xF)] = vroti_epi32(tmp[i], 1); #define SHA1_EXPAND2c(t) \ tmp[i] = vxor(w[i * 16 + ((t - 3) & 0xF)], w[i * 16 + ((t - 8) & 0xF)]); \ tmp[i] = vxor(tmp[i], data[i * 16 + t - 14]); \ tmp[i] = vxor(tmp[i], data[i * 16 + t - 16]); \ w[i * 16 + ((t) &0xF)] = vroti_epi32(tmp[i], 1); #define SHA1_EXPAND2d(t) \ tmp[i] = vxor(w[i * 16 + ((t - 3) & 0xF)], w[i * 16 + ((t - 8) & 0xF)]); \ tmp[i] = vxor(tmp[i], w[i * 16 + ((t - 14) & 0xF)]); \ tmp[i] = vxor(tmp[i], data[i * 16 + t - 16]); \ w[i * 16 + ((t) &0xF)] = vroti_epi32(tmp[i], 1); #define SHA1_EXPAND2(t) \ tmp[i] = vxor(w[i * 16 + ((t - 3) & 0xF)], w[i * 16 + ((t - 8) & 0xF)]); \ tmp[i] = vxor(tmp[i], w[i * 16 + ((t - 14) & 0xF)]); \ tmp[i] = vxor(tmp[i], w[i * 16 + ((t - 16) & 0xF)]); \ w[i * 16 + ((t) &0xF)] = vroti_epi32(tmp[i], 1); #define SHA1_ROUND2a(a, b, c, d, e, F, t) \ SHA1_PARA_DO(i) \ { \ F(b, c, d) \ e[i] = vadd_epi32(e[i], tmp[i]); \ tmp[i] = vroti_epi32(a[i], 5); \ e[i] = vadd_epi32(e[i], tmp[i]); \ e[i] = vadd_epi32(e[i], cst); \ e[i] = vadd_epi32(e[i], data[i * 16 + t]); \ b[i] = vroti_epi32(b[i], 30); \ SHA1_EXPAND2a(t + 16) \ } #define SHA1_ROUND2b(a, b, c, d, e, F, t) \ SHA1_PARA_DO(i) \ { \ F(b, c, d) \ e[i] = vadd_epi32(e[i], tmp[i]); \ tmp[i] = vroti_epi32(a[i], 5); \ e[i] = vadd_epi32(e[i], tmp[i]); \ e[i] = vadd_epi32(e[i], cst); \ e[i] = vadd_epi32(e[i], data[i * 16 + t]); \ b[i] = vroti_epi32(b[i], 30); \ SHA1_EXPAND2b(t + 16) \ } #define SHA1_ROUND2c(a, b, c, d, e, F, t) \ SHA1_PARA_DO(i) \ { \ F(b, c, d) \ e[i] = vadd_epi32(e[i], tmp[i]); \ tmp[i] = vroti_epi32(a[i], 5); \ e[i] = vadd_epi32(e[i], tmp[i]); \ e[i] = vadd_epi32(e[i], cst); \ e[i] = vadd_epi32(e[i], data[i * 16 + t]); \ b[i] = vroti_epi32(b[i], 30); \ SHA1_EXPAND2c(t + 16) \ } #define SHA1_ROUND2d(a, b, c, d, e, F, t) \ SHA1_PARA_DO(i) \ { \ F(b, c, d) \ e[i] = vadd_epi32(e[i], tmp[i]); \ tmp[i] = vroti_epi32(a[i], 5); \ e[i] = vadd_epi32(e[i], tmp[i]); \ e[i] = vadd_epi32(e[i], cst); \ e[i] = vadd_epi32(e[i], data[i * 16 + t]); \ b[i] = vroti_epi32(b[i], 30); \ SHA1_EXPAND2d(t + 16) \ } #define SHA1_ROUND2(a, b, c, d, e, F, t) \ SHA1_PARA_DO(i) \ { \ F(b, c, d) \ e[i] = vadd_epi32(e[i], tmp[i]); \ tmp[i] = vroti_epi32(a[i], 5); \ e[i] = vadd_epi32(e[i], tmp[i]); \ e[i] = vadd_epi32(e[i], cst); \ e[i] = vadd_epi32(e[i], w[i * 16 + (t & 0xF)]); \ b[i] = vroti_epi32(b[i], 30); \ SHA1_EXPAND2(t + 16) \ } #define SHA1_ROUND2x(a, b, c, d, e, F, t) \ SHA1_PARA_DO(i) \ { \ F(b, c, d) \ e[i] = vadd_epi32(e[i], tmp[i]); \ tmp[i] = vroti_epi32(a[i], 5); \ e[i] = vadd_epi32(e[i], tmp[i]); \ e[i] = vadd_epi32(e[i], cst); \ e[i] = vadd_epi32(e[i], w[i * 16 + (t & 0xF)]); \ b[i] = vroti_epi32(b[i], 30); \ } #define INIT_E 0xC3D2E1F0 void sha1_reverse(uint32_t * hash) { hash[4] -= INIT_E; hash[4] = (hash[4] << 2) | (hash[4] >> 30); } void sha1_unreverse(uint32_t * hash) { hash[4] = (hash[4] << 30) | (hash[4] >> 2); hash[4] += INIT_E; } #undef INIT_E // SSEi_MIXED_IN | SSEi_RELOAD | SSEi_OUTPUT_AS_INP_FMT void SIMDSHA1body(vtype * _data, ARCH_WORD_32 * out, ARCH_WORD_32 * reload_state, unsigned SSEi_flags) { vtype w[16 * SIMD_PARA_SHA1]; vtype a[SIMD_PARA_SHA1]; vtype b[SIMD_PARA_SHA1]; vtype c[SIMD_PARA_SHA1]; vtype d[SIMD_PARA_SHA1]; vtype e[SIMD_PARA_SHA1]; vtype tmp[SIMD_PARA_SHA1]; vtype cst; unsigned int i; vtype * data; #if 0 if (SSEi_flags & SSEi_FLAT_IN) { // Move _data to __data, mixing it SIMD_COEF_32 wise. #if __SSE4_1__ || __MIC__ unsigned k; vtype * W = w; ARCH_WORD_32 * saved_key = (ARCH_WORD_32 *) _data; SHA1_PARA_DO(k) { if (SSEi_flags & SSEi_4BUF_INPUT) { for (i = 0; i < 14; ++i) { GATHER_4x(W[i], saved_key, i); vswap32(W[i]); } GATHER_4x(W[14], saved_key, 14); GATHER_4x(W[15], saved_key, 15); saved_key += (VS32 << 6); } else if (SSEi_flags & SSEi_2BUF_INPUT) { for (i = 0; i < 14; ++i) { GATHER_2x(W[i], saved_key, i); vswap32(W[i]); } GATHER_2x(W[14], saved_key, 14); GATHER_2x(W[15], saved_key, 15); saved_key += (VS32 << 5); } else { for (i = 0; i < 14; ++i) { GATHER(W[i], saved_key, i); vswap32(W[i]); } GATHER(W[14], saved_key, 14); GATHER(W[15], saved_key, 15); saved_key += (VS32 << 4); } if (((SSEi_flags & SSEi_2BUF_INPUT_FIRST_BLK) == SSEi_2BUF_INPUT_FIRST_BLK) || ((SSEi_flags & SSEi_4BUF_INPUT_FIRST_BLK) == SSEi_4BUF_INPUT_FIRST_BLK) || ((SSEi_flags & SSEi_FLAT_RELOAD_SWAPLAST) == SSEi_FLAT_RELOAD_SWAPLAST)) { vswap32(W[14]); vswap32(W[15]); } W += 16; } #else unsigned j, k; ARCH_WORD_32 * p = (ARCH_WORD_32 *) w; vtype * W = w; ARCH_WORD_32 * saved_key = (ARCH_WORD_32 *) _data; SHA1_PARA_DO(k) { if (SSEi_flags & SSEi_4BUF_INPUT) { for (j = 0; j < 16; j++) for (i = 0; i < VS32; i++) *p++ = saved_key[(i << 6) + j]; saved_key += (VS32 << 6); } else if (SSEi_flags & SSEi_2BUF_INPUT) { for (j = 0; j < 16; j++) for (i = 0; i < VS32; i++) *p++ = saved_key[(i << 5) + j]; saved_key += (VS32 << 5); } else { for (j = 0; j < 16; j++) for (i = 0; i < VS32; i++) *p++ = saved_key[(i << 4) + j]; saved_key += (VS32 << 4); } for (i = 0; i < 14; i++) vswap32(W[i]); if (((SSEi_flags & SSEi_2BUF_INPUT_FIRST_BLK) == SSEi_2BUF_INPUT_FIRST_BLK) || ((SSEi_flags & SSEi_4BUF_INPUT_FIRST_BLK) == SSEi_4BUF_INPUT_FIRST_BLK) || ((SSEi_flags & SSEi_FLAT_RELOAD_SWAPLAST) == SSEi_FLAT_RELOAD_SWAPLAST)) { vswap32(W[14]); vswap32(W[15]); } W += 16; } #endif // now set our data pointer to point to this 'mixed' data. data = w; } else #else assert((SSEi_flags & SSEi_FLAT_IN) == 0); #endif data = _data; #if 0 if ((SSEi_flags & SSEi_RELOAD) == 0) { SHA1_PARA_DO(i) { a[i] = vset1_epi32(0x67452301); b[i] = vset1_epi32(0xefcdab89); c[i] = vset1_epi32(0x98badcfe); d[i] = vset1_epi32(0x10325476); e[i] = vset1_epi32(0xC3D2E1F0); } } else { #endif assert((SSEi_flags & SSEi_RELOAD) != 0); #if 0 if ((SSEi_flags & SSEi_RELOAD_INP_FMT) == SSEi_RELOAD_INP_FMT) { SHA1_PARA_DO(i) { a[i] = vload((vtype *) &reload_state[i * 16 * VS32 + 0 * VS32]); b[i] = vload((vtype *) &reload_state[i * 16 * VS32 + 1 * VS32]); c[i] = vload((vtype *) &reload_state[i * 16 * VS32 + 2 * VS32]); d[i] = vload((vtype *) &reload_state[i * 16 * VS32 + 3 * VS32]); e[i] = vload((vtype *) &reload_state[i * 16 * VS32 + 4 * VS32]); } } else { #endif SHA1_PARA_DO(i) { a[i] = vload((vtype *) &reload_state[i * 5 * VS32 + 0 * VS32]); b[i] = vload((vtype *) &reload_state[i * 5 * VS32 + 1 * VS32]); c[i] = vload((vtype *) &reload_state[i * 5 * VS32 + 2 * VS32]); d[i] = vload((vtype *) &reload_state[i * 5 * VS32 + 3 * VS32]); e[i] = vload((vtype *) &reload_state[i * 5 * VS32 + 4 * VS32]); } #if 0 } #endif #if 0 } #endif cst = vset1_epi32(0x5A827999); SHA1_ROUND2a(a, b, c, d, e, SHA1_F, 0); SHA1_ROUND2a(e, a, b, c, d, SHA1_F, 1); SHA1_ROUND2a(d, e, a, b, c, SHA1_F, 2); SHA1_ROUND2b(c, d, e, a, b, SHA1_F, 3); SHA1_ROUND2b(b, c, d, e, a, SHA1_F, 4); SHA1_ROUND2b(a, b, c, d, e, SHA1_F, 5); SHA1_ROUND2b(e, a, b, c, d, SHA1_F, 6); SHA1_ROUND2b(d, e, a, b, c, SHA1_F, 7); SHA1_ROUND2c(c, d, e, a, b, SHA1_F, 8); SHA1_ROUND2c(b, c, d, e, a, SHA1_F, 9); SHA1_ROUND2c(a, b, c, d, e, SHA1_F, 10); SHA1_ROUND2c(e, a, b, c, d, SHA1_F, 11); SHA1_ROUND2c(d, e, a, b, c, SHA1_F, 12); SHA1_ROUND2c(c, d, e, a, b, SHA1_F, 13); SHA1_ROUND2d(b, c, d, e, a, SHA1_F, 14); SHA1_ROUND2d(a, b, c, d, e, SHA1_F, 15); SHA1_ROUND2(e, a, b, c, d, SHA1_F, 16); SHA1_ROUND2(d, e, a, b, c, SHA1_F, 17); SHA1_ROUND2(c, d, e, a, b, SHA1_F, 18); SHA1_ROUND2(b, c, d, e, a, SHA1_F, 19); cst = vset1_epi32(0x6ED9EBA1); SHA1_ROUND2(a, b, c, d, e, SHA1_G, 20); SHA1_ROUND2(e, a, b, c, d, SHA1_G, 21); SHA1_ROUND2(d, e, a, b, c, SHA1_G, 22); SHA1_ROUND2(c, d, e, a, b, SHA1_G, 23); SHA1_ROUND2(b, c, d, e, a, SHA1_G, 24); SHA1_ROUND2(a, b, c, d, e, SHA1_G, 25); SHA1_ROUND2(e, a, b, c, d, SHA1_G, 26); SHA1_ROUND2(d, e, a, b, c, SHA1_G, 27); SHA1_ROUND2(c, d, e, a, b, SHA1_G, 28); SHA1_ROUND2(b, c, d, e, a, SHA1_G, 29); SHA1_ROUND2(a, b, c, d, e, SHA1_G, 30); SHA1_ROUND2(e, a, b, c, d, SHA1_G, 31); SHA1_ROUND2(d, e, a, b, c, SHA1_G, 32); SHA1_ROUND2(c, d, e, a, b, SHA1_G, 33); SHA1_ROUND2(b, c, d, e, a, SHA1_G, 34); SHA1_ROUND2(a, b, c, d, e, SHA1_G, 35); SHA1_ROUND2(e, a, b, c, d, SHA1_G, 36); SHA1_ROUND2(d, e, a, b, c, SHA1_G, 37); SHA1_ROUND2(c, d, e, a, b, SHA1_G, 38); SHA1_ROUND2(b, c, d, e, a, SHA1_G, 39); cst = vset1_epi32(0x8F1BBCDC); SHA1_ROUND2(a, b, c, d, e, SHA1_H, 40); SHA1_ROUND2(e, a, b, c, d, SHA1_H, 41); SHA1_ROUND2(d, e, a, b, c, SHA1_H, 42); SHA1_ROUND2(c, d, e, a, b, SHA1_H, 43); SHA1_ROUND2(b, c, d, e, a, SHA1_H, 44); SHA1_ROUND2(a, b, c, d, e, SHA1_H, 45); SHA1_ROUND2(e, a, b, c, d, SHA1_H, 46); SHA1_ROUND2(d, e, a, b, c, SHA1_H, 47); SHA1_ROUND2(c, d, e, a, b, SHA1_H, 48); SHA1_ROUND2(b, c, d, e, a, SHA1_H, 49); SHA1_ROUND2(a, b, c, d, e, SHA1_H, 50); SHA1_ROUND2(e, a, b, c, d, SHA1_H, 51); SHA1_ROUND2(d, e, a, b, c, SHA1_H, 52); SHA1_ROUND2(c, d, e, a, b, SHA1_H, 53); SHA1_ROUND2(b, c, d, e, a, SHA1_H, 54); SHA1_ROUND2(a, b, c, d, e, SHA1_H, 55); SHA1_ROUND2(e, a, b, c, d, SHA1_H, 56); SHA1_ROUND2(d, e, a, b, c, SHA1_H, 57); SHA1_ROUND2(c, d, e, a, b, SHA1_H, 58); SHA1_ROUND2(b, c, d, e, a, SHA1_H, 59); cst = vset1_epi32(0xCA62C1D6); SHA1_ROUND2(a, b, c, d, e, SHA1_I, 60); SHA1_ROUND2(e, a, b, c, d, SHA1_I, 61); SHA1_ROUND2(d, e, a, b, c, SHA1_I, 62); SHA1_ROUND2(c, d, e, a, b, SHA1_I, 63); SHA1_ROUND2x(b, c, d, e, a, SHA1_I, 64); SHA1_ROUND2x(a, b, c, d, e, SHA1_I, 65); SHA1_ROUND2x(e, a, b, c, d, SHA1_I, 66); SHA1_ROUND2x(d, e, a, b, c, SHA1_I, 67); SHA1_ROUND2x(c, d, e, a, b, SHA1_I, 68); SHA1_ROUND2x(b, c, d, e, a, SHA1_I, 69); SHA1_ROUND2x(a, b, c, d, e, SHA1_I, 70); SHA1_ROUND2x(e, a, b, c, d, SHA1_I, 71); SHA1_ROUND2x(d, e, a, b, c, SHA1_I, 72); SHA1_ROUND2x(c, d, e, a, b, SHA1_I, 73); SHA1_ROUND2x(b, c, d, e, a, SHA1_I, 74); SHA1_ROUND2x(a, b, c, d, e, SHA1_I, 75); #if 0 if (SSEi_flags & SSEi_REVERSE_STEPS) { SHA1_PARA_DO(i) { vstore((vtype *) &out[i * 5 * VS32 + 4 * VS32], e[i]); } return; } #endif SHA1_ROUND2x(e, a, b, c, d, SHA1_I, 76); SHA1_ROUND2x(d, e, a, b, c, SHA1_I, 77); SHA1_ROUND2x(c, d, e, a, b, SHA1_I, 78); SHA1_ROUND2x(b, c, d, e, a, SHA1_I, 79); #if 0 if ((SSEi_flags & SSEi_RELOAD) == 0) { SHA1_PARA_DO(i) { a[i] = vadd_epi32(a[i], vset1_epi32(0x67452301)); b[i] = vadd_epi32(b[i], vset1_epi32(0xefcdab89)); c[i] = vadd_epi32(c[i], vset1_epi32(0x98badcfe)); d[i] = vadd_epi32(d[i], vset1_epi32(0x10325476)); e[i] = vadd_epi32(e[i], vset1_epi32(0xC3D2E1F0)); } } else { if ((SSEi_flags & SSEi_RELOAD_INP_FMT) == SSEi_RELOAD_INP_FMT) { SHA1_PARA_DO(i) { a[i] = vadd_epi32( a[i], vload((vtype *) &reload_state[i * 16 * VS32 + 0 * VS32])); b[i] = vadd_epi32( b[i], vload((vtype *) &reload_state[i * 16 * VS32 + 1 * VS32])); c[i] = vadd_epi32( c[i], vload((vtype *) &reload_state[i * 16 * VS32 + 2 * VS32])); d[i] = vadd_epi32( d[i], vload((vtype *) &reload_state[i * 16 * VS32 + 3 * VS32])); e[i] = vadd_epi32( e[i], vload((vtype *) &reload_state[i * 16 * VS32 + 4 * VS32])); } } else { #endif SHA1_PARA_DO(i) { a[i] = vadd_epi32( a[i], vload((vtype *) &reload_state[i * 5 * VS32 + 0 * VS32])); b[i] = vadd_epi32( b[i], vload((vtype *) &reload_state[i * 5 * VS32 + 1 * VS32])); c[i] = vadd_epi32( c[i], vload((vtype *) &reload_state[i * 5 * VS32 + 2 * VS32])); d[i] = vadd_epi32( d[i], vload((vtype *) &reload_state[i * 5 * VS32 + 3 * VS32])); e[i] = vadd_epi32( e[i], vload((vtype *) &reload_state[i * 5 * VS32 + 4 * VS32])); } #if 0 } } #endif #if 0 if (SSEi_flags & SSEi_FLAT_OUT) { SHA1_PARA_DO(i) { uint32_t * o = (uint32_t *) &out[i * 5 * VS32]; #if __AVX512F__ || __MIC__ vtype idxs = vset_epi32(15 * 5, 14 * 5, 13 * 5, 12 * 5, 11 * 5, 10 * 5, 9 * 5, 8 * 5, 7 * 5, 6 * 5, 5 * 5, 4 * 5, 3 * 5, 2 * 5, 1 * 5, 0 * 5); vscatter_epi32((((uint32_t *) o) + 0), idxs, vswap32(a[i]), 4); vscatter_epi32((((uint32_t *) o) + 1), idxs, vswap32(b[i]), 4); vscatter_epi32((((uint32_t *) o) + 2), idxs, vswap32(c[i]), 4); vscatter_epi32((((uint32_t *) o) + 3), idxs, vswap32(d[i]), 4); vscatter_epi32((((uint32_t *) o) + 4), idxs, vswap32(e[i]), 4); #else uint32_t j, k; union { vtype v[5]; uint32_t s[5 * VS32]; } tmp; tmp.v[0] = vswap32(a[i]); tmp.v[1] = vswap32(b[i]); tmp.v[2] = vswap32(c[i]); tmp.v[3] = vswap32(d[i]); tmp.v[4] = vswap32(e[i]); for (j = 0; j < VS32; j++) for (k = 0; k < 5; k++) o[j * 5 + k] = tmp.s[k * VS32 + j]; #endif } } else if (SSEi_flags & SSEi_OUTPUT_AS_INP_FMT) { if ((SSEi_flags & SSEi_OUTPUT_AS_2BUF_INP_FMT) == SSEi_OUTPUT_AS_2BUF_INP_FMT) { SHA1_PARA_DO(i) { vstore((vtype *) &out[i * 32 * VS32 + 0 * VS32], a[i]); vstore((vtype *) &out[i * 32 * VS32 + 1 * VS32], b[i]); vstore((vtype *) &out[i * 32 * VS32 + 2 * VS32], c[i]); vstore((vtype *) &out[i * 32 * VS32 + 3 * VS32], d[i]); vstore((vtype *) &out[i * 32 * VS32 + 4 * VS32], e[i]); } } else { #endif assert((SSEi_flags & SSEi_OUTPUT_AS_INP_FMT) != 0 && (SSEi_flags & SSEi_OUTPUT_AS_2BUF_INP_FMT) != SSEi_OUTPUT_AS_2BUF_INP_FMT); SHA1_PARA_DO(i) { vstore((vtype *) &out[i * 16 * VS32 + 0 * VS32], a[i]); vstore((vtype *) &out[i * 16 * VS32 + 1 * VS32], b[i]); vstore((vtype *) &out[i * 16 * VS32 + 2 * VS32], c[i]); vstore((vtype *) &out[i * 16 * VS32 + 3 * VS32], d[i]); vstore((vtype *) &out[i * 16 * VS32 + 4 * VS32], e[i]); } #if 0 } } else { SHA1_PARA_DO(i) { vstore((vtype *) &out[i * 5 * VS32 + 0 * VS32], a[i]); vstore((vtype *) &out[i * 5 * VS32 + 1 * VS32], b[i]); vstore((vtype *) &out[i * 5 * VS32 + 2 * VS32], c[i]); vstore((vtype *) &out[i * 5 * VS32 + 3 * VS32], d[i]); vstore((vtype *) &out[i * 5 * VS32 + 4 * VS32], e[i]); } } #endif #if defined(__AVX2__) || defined(__AVX512F__) /* The fix for known issues with mixing AVX2+ and SSE. */ _mm256_zeroupper(); #endif } #endif /* SIMD_PARA_SHA1 */ #if SIMD_PARA_SHA256 /* * These optimized Sigma alternatives are from "Fast SHA-256 Implementations * on Intel Architecture Processors" whitepaper by Intel. They should result * in less register copy operations but in our case they definitely cause a * regression. Not sure why. */ #if 0 #define S0(x) \ vroti_epi32(vxor(vroti_epi32(vxor(vroti_epi32(x, -9), x), -11), x), -2) #define S1(x) \ vroti_epi32(vxor(vroti_epi32(vxor(vroti_epi32(x, -14), x), -5), x), -6) #else #define S0(x) \ (vxor(vroti_epi32(x, -22), vxor(vroti_epi32(x, -2), vroti_epi32(x, -13)))) #define S1(x) \ (vxor(vroti_epi32(x, -25), vxor(vroti_epi32(x, -6), vroti_epi32(x, -11)))) #endif #define s0(x) \ (vxor(vsrli_epi32(x, 3), vxor(vroti_epi32(x, -7), vroti_epi32(x, -18)))) #define s1(x) \ (vxor(vsrli_epi32(x, 10), vxor(vroti_epi32(x, -17), vroti_epi32(x, -19)))) #if __AVX512F__ #define Maj(x, y, z) vternarylogic(x, y, z, 0xE8) #elif !VCMOV_EMULATED #define Maj(x, y, z) vcmov(x, y, vxor(z, y)) #else #define Maj(x, y, z) vor(vand(x, y), vand(vor(x, y), z)) #endif #define Ch(x, y, z) vcmov(y, z, x) #undef R #define R(t) \ { \ tmp1[i] = vadd_epi32(s1(w[(t - 2) & 0xf]), w[(t - 7) & 0xf]); \ tmp2[i] = vadd_epi32(s0(w[(t - 15) & 0xf]), w[(t - 16) & 0xf]); \ w[(t) &0xf] = vadd_epi32(tmp1[i], tmp2[i]); \ } #define SHA256_PARA_DO(x) for (x = 0; x < SIMD_PARA_SHA256; ++x) #define SHA256_STEP(a, b, c, d, e, f, g, h, x, K) \ { \ SHA256_PARA_DO(i) \ { \ w = _w[i].w; \ tmp1[i] = vadd_epi32(h[i], S1(e[i])); \ tmp1[i] = vadd_epi32(tmp1[i], Ch(e[i], f[i], g[i])); \ tmp1[i] = vadd_epi32(tmp1[i], vset1_epi32(K)); \ tmp1[i] = vadd_epi32(tmp1[i], w[(x) &0xf]); \ tmp2[i] = vadd_epi32(S0(a[i]), Maj(a[i], b[i], c[i])); \ d[i] = vadd_epi32(tmp1[i], d[i]); \ h[i] = vadd_epi32(tmp1[i], tmp2[i]); \ if (x < 48) R(x); \ } \ } #define INIT_A 0x6a09e667 #define INIT_B 0xbb67ae85 #define INIT_C 0x3c6ef372 #define INIT_D 0xa54ff53a #define INIT_E 0x510e527f #define INIT_F 0x9b05688c #define INIT_G 0x1f83d9ab #define INIT_H 0x5be0cd19 #define ror(x, n) (((x) >> (n)) | ((x) << (32 - (n)))) void sha256_reverse(uint32_t * hash) { uint32_t a, b, c, d, e, f, g, h, s0, maj, tmp; a = hash[0] - INIT_A; b = hash[1] - INIT_B; c = hash[2] - INIT_C; d = hash[3] - INIT_D; e = hash[4] - INIT_E; f = hash[5] - INIT_F; g = hash[6] - INIT_G; h = hash[7] - INIT_H; s0 = ror(b, 2) ^ ror(b, 13) ^ ror(b, 22); maj = (b & c) ^ (b & d) ^ (c & d); tmp = d; d = e - (a - (s0 + maj)); e = f; f = g; g = h; a = b; b = c; c = tmp; s0 = ror(b, 2) ^ ror(b, 13) ^ ror(b, 22); maj = (b & c) ^ (b & d) ^ (c & d); tmp = d; d = e - (a - (s0 + maj)); e = f; f = g; a = b; b = c; c = tmp; s0 = ror(b, 2) ^ ror(b, 13) ^ ror(b, 22); maj = (b & c) ^ (b & d) ^ (c & d); tmp = d; d = e - (a - (s0 + maj)); e = f; a = b; b = c; c = tmp; s0 = ror(b, 2) ^ ror(b, 13) ^ ror(b, 22); maj = (b & c) ^ (b & d) ^ (c & d); hash[0] = e - (a - (s0 + maj)); } void sha256_unreverse(void) { fprintf(stderr, "sha256_unreverse() not implemented\n"); perror("sha256_unreverse"); } #undef ror #undef INIT_H #undef INIT_G #undef INIT_F #undef INIT_E #undef INIT_D #undef INIT_C #undef INIT_B #undef INIT_A #define INIT_D 0xf70e5939 void sha224_reverse(uint32_t * hash) { hash[3] -= INIT_D; } void sha224_unreverse(uint32_t * hash) { hash[3] += INIT_D; } #undef INIT_D void SIMDSHA256body(vtype * data, ARCH_WORD_32 * out, ARCH_WORD_32 * reload_state, unsigned SSEi_flags) { vtype a[SIMD_PARA_SHA256], b[SIMD_PARA_SHA256], c[SIMD_PARA_SHA256], d[SIMD_PARA_SHA256], e[SIMD_PARA_SHA256], f[SIMD_PARA_SHA256], g[SIMD_PARA_SHA256], h[SIMD_PARA_SHA256]; union { vtype w[16]; ARCH_WORD_32 p[16 * sizeof(vtype) / sizeof(ARCH_WORD_32)]; } _w[SIMD_PARA_SHA256]; vtype tmp1[SIMD_PARA_SHA256], tmp2[SIMD_PARA_SHA256], *w = NULL; ARCH_WORD_32 * saved_key = 0; unsigned int i, k; if (SSEi_flags & SSEi_FLAT_IN) { #if __SSE4_1__ || __MIC__ saved_key = (ARCH_WORD_32 *) data; SHA256_PARA_DO(k) { w = _w[k].w; if (SSEi_flags & SSEi_4BUF_INPUT) { for (i = 0; i < 14; ++i) { GATHER_4x(w[i], saved_key, i); vswap32(w[i]); } GATHER_4x(w[14], saved_key, 14); GATHER_4x(w[15], saved_key, 15); saved_key += (VS32 << 6); } else if (SSEi_flags & SSEi_2BUF_INPUT) { for (i = 0; i < 14; ++i) { GATHER_2x(w[i], saved_key, i); vswap32(w[i]); } GATHER_2x(w[14], saved_key, 14); GATHER_2x(w[15], saved_key, 15); saved_key += (VS32 << 5); } else { for (i = 0; i < 14; ++i) { GATHER(w[i], saved_key, i); vswap32(w[i]); } GATHER(w[14], saved_key, 14); GATHER(w[15], saved_key, 15); saved_key += (VS32 << 4); } if (((SSEi_flags & SSEi_2BUF_INPUT_FIRST_BLK) == SSEi_2BUF_INPUT_FIRST_BLK) || ((SSEi_flags & SSEi_4BUF_INPUT_FIRST_BLK) == SSEi_4BUF_INPUT_FIRST_BLK) || ((SSEi_flags & SSEi_FLAT_RELOAD_SWAPLAST) == SSEi_FLAT_RELOAD_SWAPLAST)) { vswap32(w[14]); vswap32(w[15]); } } #else unsigned int j; saved_key = (ARCH_WORD_32 *) data; SHA256_PARA_DO(k) { ARCH_WORD_32 * p = _w[k].p; w = _w[k].w; if (SSEi_flags & SSEi_4BUF_INPUT) { for (j = 0; j < 16; j++) for (i = 0; i < VS32; i++) *p++ = saved_key[(i << 6) + j]; saved_key += (VS32 << 6); } else if (SSEi_flags & SSEi_2BUF_INPUT) { for (j = 0; j < 16; j++) for (i = 0; i < VS32; i++) *p++ = saved_key[(i << 5) + j]; saved_key += (VS32 << 5); } else { for (j = 0; j < 16; j++) for (i = 0; i < VS32; i++) *p++ = saved_key[(i << 4) + j]; saved_key += (VS32 << 4); } for (i = 0; i < 14; i++) vswap32(w[i]); if (((SSEi_flags & SSEi_2BUF_INPUT_FIRST_BLK) == SSEi_2BUF_INPUT_FIRST_BLK) || ((SSEi_flags & SSEi_4BUF_INPUT_FIRST_BLK) == SSEi_4BUF_INPUT_FIRST_BLK) || ((SSEi_flags & SSEi_FLAT_RELOAD_SWAPLAST) == SSEi_FLAT_RELOAD_SWAPLAST)) { vswap32(w[14]); vswap32(w[15]); } } #endif } else memcpy(_w, data, 16 * sizeof(vtype) * SIMD_PARA_SHA256); // dump_stuff_shammx(w, 64, 0); if (SSEi_flags & SSEi_RELOAD) { if ((SSEi_flags & SSEi_RELOAD_INP_FMT) == SSEi_RELOAD_INP_FMT) { SHA256_PARA_DO(i) { a[i] = vload((vtype *) &reload_state[i * 16 * VS32 + 0 * VS32]); b[i] = vload((vtype *) &reload_state[i * 16 * VS32 + 1 * VS32]); c[i] = vload((vtype *) &reload_state[i * 16 * VS32 + 2 * VS32]); d[i] = vload((vtype *) &reload_state[i * 16 * VS32 + 3 * VS32]); e[i] = vload((vtype *) &reload_state[i * 16 * VS32 + 4 * VS32]); f[i] = vload((vtype *) &reload_state[i * 16 * VS32 + 5 * VS32]); g[i] = vload((vtype *) &reload_state[i * 16 * VS32 + 6 * VS32]); h[i] = vload((vtype *) &reload_state[i * 16 * VS32 + 7 * VS32]); } } else { SHA256_PARA_DO(i) { a[i] = vload((vtype *) &reload_state[i * 8 * VS32 + 0 * VS32]); b[i] = vload((vtype *) &reload_state[i * 8 * VS32 + 1 * VS32]); c[i] = vload((vtype *) &reload_state[i * 8 * VS32 + 2 * VS32]); d[i] = vload((vtype *) &reload_state[i * 8 * VS32 + 3 * VS32]); e[i] = vload((vtype *) &reload_state[i * 8 * VS32 + 4 * VS32]); f[i] = vload((vtype *) &reload_state[i * 8 * VS32 + 5 * VS32]); g[i] = vload((vtype *) &reload_state[i * 8 * VS32 + 6 * VS32]); h[i] = vload((vtype *) &reload_state[i * 8 * VS32 + 7 * VS32]); } } } else { if (SSEi_flags & SSEi_CRYPT_SHA224) { SHA256_PARA_DO(i) { /* SHA-224 IV */ a[i] = vset1_epi32(0xc1059ed8); b[i] = vset1_epi32(0x367cd507); c[i] = vset1_epi32(0x3070dd17); d[i] = vset1_epi32(0xf70e5939); e[i] = vset1_epi32(0xffc00b31); f[i] = vset1_epi32(0x68581511); g[i] = vset1_epi32(0x64f98fa7); h[i] = vset1_epi32(0xbefa4fa4); } } else { SHA256_PARA_DO(i) { // SHA-256 IV */ a[i] = vset1_epi32(0x6a09e667); b[i] = vset1_epi32(0xbb67ae85); c[i] = vset1_epi32(0x3c6ef372); d[i] = vset1_epi32(0xa54ff53a); e[i] = vset1_epi32(0x510e527f); f[i] = vset1_epi32(0x9b05688c); g[i] = vset1_epi32(0x1f83d9ab); h[i] = vset1_epi32(0x5be0cd19); } } } SHA256_STEP(a, b, c, d, e, f, g, h, 0, 0x428a2f98); SHA256_STEP(h, a, b, c, d, e, f, g, 1, 0x71374491); SHA256_STEP(g, h, a, b, c, d, e, f, 2, 0xb5c0fbcf); SHA256_STEP(f, g, h, a, b, c, d, e, 3, 0xe9b5dba5); SHA256_STEP(e, f, g, h, a, b, c, d, 4, 0x3956c25b); SHA256_STEP(d, e, f, g, h, a, b, c, 5, 0x59f111f1); SHA256_STEP(c, d, e, f, g, h, a, b, 6, 0x923f82a4); SHA256_STEP(b, c, d, e, f, g, h, a, 7, 0xab1c5ed5); SHA256_STEP(a, b, c, d, e, f, g, h, 8, 0xd807aa98); SHA256_STEP(h, a, b, c, d, e, f, g, 9, 0x12835b01); SHA256_STEP(g, h, a, b, c, d, e, f, 10, 0x243185be); SHA256_STEP(f, g, h, a, b, c, d, e, 11, 0x550c7dc3); SHA256_STEP(e, f, g, h, a, b, c, d, 12, 0x72be5d74); SHA256_STEP(d, e, f, g, h, a, b, c, 13, 0x80deb1fe); SHA256_STEP(c, d, e, f, g, h, a, b, 14, 0x9bdc06a7); SHA256_STEP(b, c, d, e, f, g, h, a, 15, 0xc19bf174); SHA256_STEP(a, b, c, d, e, f, g, h, 16, 0xe49b69c1); SHA256_STEP(h, a, b, c, d, e, f, g, 17, 0xefbe4786); SHA256_STEP(g, h, a, b, c, d, e, f, 18, 0x0fc19dc6); SHA256_STEP(f, g, h, a, b, c, d, e, 19, 0x240ca1cc); SHA256_STEP(e, f, g, h, a, b, c, d, 20, 0x2de92c6f); SHA256_STEP(d, e, f, g, h, a, b, c, 21, 0x4a7484aa); SHA256_STEP(c, d, e, f, g, h, a, b, 22, 0x5cb0a9dc); SHA256_STEP(b, c, d, e, f, g, h, a, 23, 0x76f988da); SHA256_STEP(a, b, c, d, e, f, g, h, 24, 0x983e5152); SHA256_STEP(h, a, b, c, d, e, f, g, 25, 0xa831c66d); SHA256_STEP(g, h, a, b, c, d, e, f, 26, 0xb00327c8); SHA256_STEP(f, g, h, a, b, c, d, e, 27, 0xbf597fc7); SHA256_STEP(e, f, g, h, a, b, c, d, 28, 0xc6e00bf3); SHA256_STEP(d, e, f, g, h, a, b, c, 29, 0xd5a79147); SHA256_STEP(c, d, e, f, g, h, a, b, 30, 0x06ca6351); SHA256_STEP(b, c, d, e, f, g, h, a, 31, 0x14292967); SHA256_STEP(a, b, c, d, e, f, g, h, 32, 0x27b70a85); SHA256_STEP(h, a, b, c, d, e, f, g, 33, 0x2e1b2138); SHA256_STEP(g, h, a, b, c, d, e, f, 34, 0x4d2c6dfc); SHA256_STEP(f, g, h, a, b, c, d, e, 35, 0x53380d13); SHA256_STEP(e, f, g, h, a, b, c, d, 36, 0x650a7354); SHA256_STEP(d, e, f, g, h, a, b, c, 37, 0x766a0abb); SHA256_STEP(c, d, e, f, g, h, a, b, 38, 0x81c2c92e); SHA256_STEP(b, c, d, e, f, g, h, a, 39, 0x92722c85); SHA256_STEP(a, b, c, d, e, f, g, h, 40, 0xa2bfe8a1); SHA256_STEP(h, a, b, c, d, e, f, g, 41, 0xa81a664b); SHA256_STEP(g, h, a, b, c, d, e, f, 42, 0xc24b8b70); SHA256_STEP(f, g, h, a, b, c, d, e, 43, 0xc76c51a3); SHA256_STEP(e, f, g, h, a, b, c, d, 44, 0xd192e819); SHA256_STEP(d, e, f, g, h, a, b, c, 45, 0xd6990624); SHA256_STEP(c, d, e, f, g, h, a, b, 46, 0xf40e3585); SHA256_STEP(b, c, d, e, f, g, h, a, 47, 0x106aa070); SHA256_STEP(a, b, c, d, e, f, g, h, 48, 0x19a4c116); SHA256_STEP(h, a, b, c, d, e, f, g, 49, 0x1e376c08); SHA256_STEP(g, h, a, b, c, d, e, f, 50, 0x2748774c); SHA256_STEP(f, g, h, a, b, c, d, e, 51, 0x34b0bcb5); SHA256_STEP(e, f, g, h, a, b, c, d, 52, 0x391c0cb3); SHA256_STEP(d, e, f, g, h, a, b, c, 53, 0x4ed8aa4a); SHA256_STEP(c, d, e, f, g, h, a, b, 54, 0x5b9cca4f); SHA256_STEP(b, c, d, e, f, g, h, a, 55, 0x682e6ff3); SHA256_STEP(a, b, c, d, e, f, g, h, 56, 0x748f82ee); if (SSEi_flags & SSEi_REVERSE_STEPS && !(SSEi_flags & SSEi_CRYPT_SHA224)) { SHA256_PARA_DO(i) { vstore((vtype *) &(out[i * 8 * VS32 + 0 * VS32]), h[i]); } return; } SHA256_STEP(h, a, b, c, d, e, f, g, 57, 0x78a5636f); SHA256_STEP(g, h, a, b, c, d, e, f, 58, 0x84c87814); SHA256_STEP(f, g, h, a, b, c, d, e, 59, 0x8cc70208); SHA256_STEP(e, f, g, h, a, b, c, d, 60, 0x90befffa); if (SSEi_flags & SSEi_REVERSE_STEPS) { SHA256_PARA_DO(i) { vstore((vtype *) &(out[i * 8 * VS32 + 3 * VS32]), d[i]); } return; } SHA256_STEP(d, e, f, g, h, a, b, c, 61, 0xa4506ceb); SHA256_STEP(c, d, e, f, g, h, a, b, 62, 0xbef9a3f7); SHA256_STEP(b, c, d, e, f, g, h, a, 63, 0xc67178f2); if (SSEi_flags & SSEi_RELOAD) { if ((SSEi_flags & SSEi_RELOAD_INP_FMT) == SSEi_RELOAD_INP_FMT) { SHA256_PARA_DO(i) { a[i] = vadd_epi32( a[i], vload((vtype *) &reload_state[i * 16 * VS32 + 0 * VS32])); b[i] = vadd_epi32( b[i], vload((vtype *) &reload_state[i * 16 * VS32 + 1 * VS32])); c[i] = vadd_epi32( c[i], vload((vtype *) &reload_state[i * 16 * VS32 + 2 * VS32])); d[i] = vadd_epi32( d[i], vload((vtype *) &reload_state[i * 16 * VS32 + 3 * VS32])); e[i] = vadd_epi32( e[i], vload((vtype *) &reload_state[i * 16 * VS32 + 4 * VS32])); f[i] = vadd_epi32( f[i], vload((vtype *) &reload_state[i * 16 * VS32 + 5 * VS32])); g[i] = vadd_epi32( g[i], vload((vtype *) &reload_state[i * 16 * VS32 + 6 * VS32])); h[i] = vadd_epi32( h[i], vload((vtype *) &reload_state[i * 16 * VS32 + 7 * VS32])); } } else { SHA256_PARA_DO(i) { a[i] = vadd_epi32( a[i], vload((vtype *) &reload_state[i * 8 * VS32 + 0 * VS32])); b[i] = vadd_epi32( b[i], vload((vtype *) &reload_state[i * 8 * VS32 + 1 * VS32])); c[i] = vadd_epi32( c[i], vload((vtype *) &reload_state[i * 8 * VS32 + 2 * VS32])); d[i] = vadd_epi32( d[i], vload((vtype *) &reload_state[i * 8 * VS32 + 3 * VS32])); e[i] = vadd_epi32( e[i], vload((vtype *) &reload_state[i * 8 * VS32 + 4 * VS32])); f[i] = vadd_epi32( f[i], vload((vtype *) &reload_state[i * 8 * VS32 + 5 * VS32])); g[i] = vadd_epi32( g[i], vload((vtype *) &reload_state[i * 8 * VS32 + 6 * VS32])); h[i] = vadd_epi32( h[i], vload((vtype *) &reload_state[i * 8 * VS32 + 7 * VS32])); } } } else { if (SSEi_flags & SSEi_CRYPT_SHA224) { SHA256_PARA_DO(i) { /* SHA-224 IV */ a[i] = vadd_epi32(a[i], vset1_epi32(0xc1059ed8)); b[i] = vadd_epi32(b[i], vset1_epi32(0x367cd507)); c[i] = vadd_epi32(c[i], vset1_epi32(0x3070dd17)); d[i] = vadd_epi32(d[i], vset1_epi32(0xf70e5939)); e[i] = vadd_epi32(e[i], vset1_epi32(0xffc00b31)); f[i] = vadd_epi32(f[i], vset1_epi32(0x68581511)); g[i] = vadd_epi32(g[i], vset1_epi32(0x64f98fa7)); h[i] = vadd_epi32(h[i], vset1_epi32(0xbefa4fa4)); } } else { SHA256_PARA_DO(i) { /* SHA-256 IV */ a[i] = vadd_epi32(a[i], vset1_epi32(0x6a09e667)); b[i] = vadd_epi32(b[i], vset1_epi32(0xbb67ae85)); c[i] = vadd_epi32(c[i], vset1_epi32(0x3c6ef372)); d[i] = vadd_epi32(d[i], vset1_epi32(0xa54ff53a)); e[i] = vadd_epi32(e[i], vset1_epi32(0x510e527f)); f[i] = vadd_epi32(f[i], vset1_epi32(0x9b05688c)); g[i] = vadd_epi32(g[i], vset1_epi32(0x1f83d9ab)); h[i] = vadd_epi32(h[i], vset1_epi32(0x5be0cd19)); } } } if (SSEi_flags & SSEi_FLAT_OUT) { SHA256_PARA_DO(i) { uint32_t * o = (uint32_t *) &out[i * 8 * VS32]; #if __AVX512F__ || __MIC__ vtype idxs = vset_epi32(15 << 3, 14 << 3, 13 << 3, 12 << 3, 11 << 3, 10 << 3, 9 << 3, 8 << 3, 7 << 3, 6 << 3, 5 << 3, 4 << 3, 3 << 3, 2 << 3, 1 << 3, 0 << 3); vscatter_epi32((((uint32_t *) o) + 0), idxs, vswap32(a[i]), 4); vscatter_epi32((((uint32_t *) o) + 1), idxs, vswap32(b[i]), 4); vscatter_epi32((((uint32_t *) o) + 2), idxs, vswap32(c[i]), 4); vscatter_epi32((((uint32_t *) o) + 3), idxs, vswap32(d[i]), 4); vscatter_epi32((((uint32_t *) o) + 4), idxs, vswap32(e[i]), 4); vscatter_epi32((((uint32_t *) o) + 5), idxs, vswap32(f[i]), 4); vscatter_epi32((((uint32_t *) o) + 6), idxs, vswap32(g[i]), 4); vscatter_epi32((((uint32_t *) o) + 7), idxs, vswap32(h[i]), 4); #else uint32_t j, k; union { vtype v[8]; uint32_t s[8 * VS32]; } tmp; tmp.v[0] = vswap32(a[i]); tmp.v[1] = vswap32(b[i]); tmp.v[2] = vswap32(c[i]); tmp.v[3] = vswap32(d[i]); tmp.v[4] = vswap32(e[i]); tmp.v[5] = vswap32(f[i]); tmp.v[6] = vswap32(g[i]); tmp.v[7] = vswap32(h[i]); for (j = 0; j < VS32; j++) for (k = 0; k < 8; k++) o[j * 8 + k] = tmp.s[k * VS32 + j]; #endif } } else if (SSEi_flags & SSEi_OUTPUT_AS_INP_FMT) { if ((SSEi_flags & SSEi_OUTPUT_AS_2BUF_INP_FMT) == SSEi_OUTPUT_AS_2BUF_INP_FMT) { SHA256_PARA_DO(i) { vstore((vtype *) &out[i * 32 * VS32 + 0 * VS32], a[i]); vstore((vtype *) &out[i * 32 * VS32 + 1 * VS32], b[i]); vstore((vtype *) &out[i * 32 * VS32 + 2 * VS32], c[i]); vstore((vtype *) &out[i * 32 * VS32 + 3 * VS32], d[i]); vstore((vtype *) &out[i * 32 * VS32 + 4 * VS32], e[i]); vstore((vtype *) &out[i * 32 * VS32 + 5 * VS32], f[i]); vstore((vtype *) &out[i * 32 * VS32 + 6 * VS32], g[i]); vstore((vtype *) &out[i * 32 * VS32 + 7 * VS32], h[i]); } } else { SHA256_PARA_DO(i) { vstore((vtype *) &out[i * 16 * VS32 + 0 * VS32], a[i]); vstore((vtype *) &out[i * 16 * VS32 + 1 * VS32], b[i]); vstore((vtype *) &out[i * 16 * VS32 + 2 * VS32], c[i]); vstore((vtype *) &out[i * 16 * VS32 + 3 * VS32], d[i]); vstore((vtype *) &out[i * 16 * VS32 + 4 * VS32], e[i]); vstore((vtype *) &out[i * 16 * VS32 + 5 * VS32], f[i]); vstore((vtype *) &out[i * 16 * VS32 + 6 * VS32], g[i]); vstore((vtype *) &out[i * 16 * VS32 + 7 * VS32], h[i]); } } } else { SHA256_PARA_DO(i) { vstore((vtype *) &(out[i * 8 * VS32 + 0 * VS32]), a[i]); vstore((vtype *) &(out[i * 8 * VS32 + 1 * VS32]), b[i]); vstore((vtype *) &(out[i * 8 * VS32 + 2 * VS32]), c[i]); vstore((vtype *) &(out[i * 8 * VS32 + 3 * VS32]), d[i]); vstore((vtype *) &(out[i * 8 * VS32 + 4 * VS32]), e[i]); vstore((vtype *) &(out[i * 8 * VS32 + 5 * VS32]), f[i]); vstore((vtype *) &(out[i * 8 * VS32 + 6 * VS32]), g[i]); vstore((vtype *) &(out[i * 8 * VS32 + 7 * VS32]), h[i]); } } } #endif /* SIMD_PARA_SHA256 */ #if SIMD_PARA_SHA512 #undef S0 #define S0(x) \ (vxor(vroti_epi64(x, -39), vxor(vroti_epi64(x, -28), vroti_epi64(x, -34)))) #undef S1 #define S1(x) \ (vxor(vroti_epi64(x, -41), vxor(vroti_epi64(x, -14), vroti_epi64(x, -18)))) /* * These optimized sigma alternatives are from "Fast SHA-512 Implementations * on Intel Architecture Processors" whitepaper by Intel. They result in less * register copy operations so is faster despite using more ops. Slight boost * indeed seen on intel core i7. */ #if 1 #undef s0 #define s0(x) \ (vxor(vsrli_epi64(vxor(vsrli_epi64(vxor(vsrli_epi64(x, 1), x), 6), x), 1), \ vslli_epi64(vxor(vslli_epi64(x, 7), x), 56))) #undef s1 #define s1(x) \ (vxor( \ vsrli_epi64(vxor(vsrli_epi64(vxor(vsrli_epi64(x, 42), x), 13), x), 6), \ vslli_epi64(vxor(vslli_epi64(x, 42), x), 3))) #else #undef s0 #define s0(x) \ (vxor(vsrli_epi64(x, 7), vxor(vroti_epi64(x, -1), vroti_epi64(x, -8)))) #undef s1 #define s1(x) \ (vxor(vsrli_epi64(x, 6), vxor(vroti_epi64(x, -19), vroti_epi64(x, -61)))) #endif #if __AVX512F__ #define Maj(x, y, z) vternarylogic(x, y, z, 0xE8) #elif !VCMOV_EMULATED #define Maj(x, y, z) vcmov(x, y, vxor(z, y)) #else #define Maj(x, y, z) vor(vand(x, y), vand(vor(x, y), z)) #endif #define Ch(x, y, z) vcmov(y, z, x) #define SHA512_PARA_DO(x) for (x = 0; x < SIMD_PARA_SHA512; ++x) #undef R #define R(t) \ { \ tmp1[i] = vadd_epi64(s1(w[i][(t - 2) & 0xf]), w[i][(t - 7) & 0xf]); \ tmp2[i] = vadd_epi64(s0(w[i][(t - 15) & 0xf]), w[i][(t - 16) & 0xf]); \ w[i][(t) &0xf] = vadd_epi64(tmp1[i], tmp2[i]); \ } #define SHA512_STEP(a, b, c, d, e, f, g, h, x, K) \ { \ SHA512_PARA_DO(i) \ { \ tmp1[i] = vadd_epi64(h[i], w[i][(x) &0xf]); \ tmp2[i] = vadd_epi64(S1(e[i]), vset1_epi64(K)); \ tmp1[i] = vadd_epi64(tmp1[i], Ch(e[i], f[i], g[i])); \ tmp1[i] = vadd_epi64(tmp1[i], tmp2[i]); \ tmp2[i] = vadd_epi64(S0(a[i]), Maj(a[i], b[i], c[i])); \ d[i] = vadd_epi64(tmp1[i], d[i]); \ h[i] = vadd_epi64(tmp1[i], tmp2[i]); \ if (x < 64) R(x); \ } \ } #define INIT_A 0x6a09e667f3bcc908ULL #define INIT_B 0xbb67ae8584caa73bULL #define INIT_C 0x3c6ef372fe94f82bULL #define INIT_D 0xa54ff53a5f1d36f1ULL #define INIT_E 0x510e527fade682d1ULL #define INIT_F 0x9b05688c2b3e6c1fULL #define INIT_G 0x1f83d9abfb41bd6bULL #define INIT_H 0x5be0cd19137e2179ULL #define ror(x, n) (((x) >> (n)) | ((x) << (64 - (n)))) void sha512_reverse(uint64_t * hash) { uint64_t a, b, c, d, e, f, g, h, s0, maj, tmp; a = hash[0] - INIT_A; b = hash[1] - INIT_B; c = hash[2] - INIT_C; d = hash[3] - INIT_D; e = hash[4] - INIT_E; f = hash[5] - INIT_F; g = hash[6] - INIT_G; h = hash[7] - INIT_H; s0 = ror(b, 28) ^ ror(b, 34) ^ ror(b, 39); maj = (b & c) ^ (b & d) ^ (c & d); tmp = d; d = e - (a - (s0 + maj)); e = f; f = g; g = h; a = b; b = c; c = tmp; s0 = ror(b, 28) ^ ror(b, 34) ^ ror(b, 39); maj = (b & c) ^ (b & d) ^ (c & d); tmp = d; d = e - (a - (s0 + maj)); e = f; f = g; a = b; b = c; c = tmp; s0 = ror(b, 28) ^ ror(b, 34) ^ ror(b, 39); maj = (b & c) ^ (b & d) ^ (c & d); tmp = d; d = e - (a - (s0 + maj)); e = f; a = b; b = c; c = tmp; s0 = ror(b, 28) ^ ror(b, 34) ^ ror(b, 39); maj = (b & c) ^ (b & d) ^ (c & d); hash[0] = e - (a - (s0 + maj)); } void sha512_unreverse(void) { fprintf(stderr, "sha512_unreverse() not implemented\n"); perror("sha512"); } #undef ror #undef INIT_H #undef INIT_G #undef INIT_F #undef INIT_E #undef INIT_D #undef INIT_C #undef INIT_B #undef INIT_A #define INIT_D 0x152fecd8f70e5939ULL void sha384_reverse(ARCH_WORD_64 * hash) { hash[3] -= INIT_D; } void sha384_unreverse(ARCH_WORD_64 * hash) { hash[3] += INIT_D; } #undef INIT_D void SIMDSHA512body(vtype * data, ARCH_WORD_64 * out, ARCH_WORD_64 * reload_state, unsigned SSEi_flags) { unsigned int i, k; vtype a[SIMD_PARA_SHA512], b[SIMD_PARA_SHA512], c[SIMD_PARA_SHA512], d[SIMD_PARA_SHA512], e[SIMD_PARA_SHA512], f[SIMD_PARA_SHA512], g[SIMD_PARA_SHA512], h[SIMD_PARA_SHA512]; vtype w[SIMD_PARA_SHA512][16]; vtype tmp1[SIMD_PARA_SHA512], tmp2[SIMD_PARA_SHA512]; if (SSEi_flags & SSEi_FLAT_IN) { ARCH_WORD_64 * _data = (ARCH_WORD_64 *) data; SHA512_PARA_DO(k) { if (SSEi_flags & SSEi_2BUF_INPUT) { ARCH_WORD_64(*saved_key)[32] = (ARCH_WORD_64(*)[32]) _data; for (i = 0; i < 14; i += 2) { GATHER64(tmp1[k], saved_key, i); GATHER64(tmp2[k], saved_key, i + 1); vswap64(tmp1[k]); vswap64(tmp2[k]); w[k][i] = tmp1[k]; w[k][i + 1] = tmp2[k]; } GATHER64(tmp1[k], saved_key, 14); GATHER64(tmp2[k], saved_key, 15); _data += (VS64 << 5); } else { ARCH_WORD_64(*saved_key)[16] = (ARCH_WORD_64(*)[16]) _data; for (i = 0; i < 14; i += 2) { GATHER64(tmp1[k], saved_key, i); GATHER64(tmp2[k], saved_key, i + 1); vswap64(tmp1[k]); vswap64(tmp2[k]); w[k][i] = tmp1[k]; w[k][i + 1] = tmp2[k]; } GATHER64(tmp1[k], saved_key, 14); GATHER64(tmp2[k], saved_key, 15); _data += (VS64 << 4); } if (((SSEi_flags & SSEi_2BUF_INPUT_FIRST_BLK) == SSEi_2BUF_INPUT_FIRST_BLK) || ((SSEi_flags & SSEi_FLAT_RELOAD_SWAPLAST) == SSEi_FLAT_RELOAD_SWAPLAST)) { vswap64(tmp1[k]); vswap64(tmp2[k]); } w[k][14] = tmp1[k]; w[k][15] = tmp2[k]; } } else memcpy(w, data, 16 * sizeof(vtype) * SIMD_PARA_SHA512); // dump_stuff_shammx64_msg("\nindex 2", w, 128, 2); if (SSEi_flags & SSEi_RELOAD) { if ((SSEi_flags & SSEi_RELOAD_INP_FMT) == SSEi_RELOAD_INP_FMT) { SHA512_PARA_DO(i) { a[i] = vload((vtype *) &reload_state[i * 16 * VS64 + 0 * VS64]); b[i] = vload((vtype *) &reload_state[i * 16 * VS64 + 1 * VS64]); c[i] = vload((vtype *) &reload_state[i * 16 * VS64 + 2 * VS64]); d[i] = vload((vtype *) &reload_state[i * 16 * VS64 + 3 * VS64]); e[i] = vload((vtype *) &reload_state[i * 16 * VS64 + 4 * VS64]); f[i] = vload((vtype *) &reload_state[i * 16 * VS64 + 5 * VS64]); g[i] = vload((vtype *) &reload_state[i * 16 * VS64 + 6 * VS64]); h[i] = vload((vtype *) &reload_state[i * 16 * VS64 + 7 * VS64]); } } else { SHA512_PARA_DO(i) { a[i] = vload((vtype *) &reload_state[i * 8 * VS64 + 0 * VS64]); b[i] = vload((vtype *) &reload_state[i * 8 * VS64 + 1 * VS64]); c[i] = vload((vtype *) &reload_state[i * 8 * VS64 + 2 * VS64]); d[i] = vload((vtype *) &reload_state[i * 8 * VS64 + 3 * VS64]); e[i] = vload((vtype *) &reload_state[i * 8 * VS64 + 4 * VS64]); f[i] = vload((vtype *) &reload_state[i * 8 * VS64 + 5 * VS64]); g[i] = vload((vtype *) &reload_state[i * 8 * VS64 + 6 * VS64]); h[i] = vload((vtype *) &reload_state[i * 8 * VS64 + 7 * VS64]); } } } else { if (SSEi_flags & SSEi_CRYPT_SHA384) { SHA512_PARA_DO(i) { /* SHA-384 IV */ a[i] = vset1_epi64(0xcbbb9d5dc1059ed8ULL); b[i] = vset1_epi64(0x629a292a367cd507ULL); c[i] = vset1_epi64(0x9159015a3070dd17ULL); d[i] = vset1_epi64(0x152fecd8f70e5939ULL); e[i] = vset1_epi64(0x67332667ffc00b31ULL); f[i] = vset1_epi64(0x8eb44a8768581511ULL); g[i] = vset1_epi64(0xdb0c2e0d64f98fa7ULL); h[i] = vset1_epi64(0x47b5481dbefa4fa4ULL); } } else { SHA512_PARA_DO(i) { /* SHA-512 IV */ a[i] = vset1_epi64(0x6a09e667f3bcc908ULL); b[i] = vset1_epi64(0xbb67ae8584caa73bULL); c[i] = vset1_epi64(0x3c6ef372fe94f82bULL); d[i] = vset1_epi64(0xa54ff53a5f1d36f1ULL); e[i] = vset1_epi64(0x510e527fade682d1ULL); f[i] = vset1_epi64(0x9b05688c2b3e6c1fULL); g[i] = vset1_epi64(0x1f83d9abfb41bd6bULL); h[i] = vset1_epi64(0x5be0cd19137e2179ULL); } } } SHA512_STEP(a, b, c, d, e, f, g, h, 0, 0x428a2f98d728ae22ULL); SHA512_STEP(h, a, b, c, d, e, f, g, 1, 0x7137449123ef65cdULL); SHA512_STEP(g, h, a, b, c, d, e, f, 2, 0xb5c0fbcfec4d3b2fULL); SHA512_STEP(f, g, h, a, b, c, d, e, 3, 0xe9b5dba58189dbbcULL); SHA512_STEP(e, f, g, h, a, b, c, d, 4, 0x3956c25bf348b538ULL); SHA512_STEP(d, e, f, g, h, a, b, c, 5, 0x59f111f1b605d019ULL); SHA512_STEP(c, d, e, f, g, h, a, b, 6, 0x923f82a4af194f9bULL); SHA512_STEP(b, c, d, e, f, g, h, a, 7, 0xab1c5ed5da6d8118ULL); SHA512_STEP(a, b, c, d, e, f, g, h, 8, 0xd807aa98a3030242ULL); SHA512_STEP(h, a, b, c, d, e, f, g, 9, 0x12835b0145706fbeULL); SHA512_STEP(g, h, a, b, c, d, e, f, 10, 0x243185be4ee4b28cULL); SHA512_STEP(f, g, h, a, b, c, d, e, 11, 0x550c7dc3d5ffb4e2ULL); SHA512_STEP(e, f, g, h, a, b, c, d, 12, 0x72be5d74f27b896fULL); SHA512_STEP(d, e, f, g, h, a, b, c, 13, 0x80deb1fe3b1696b1ULL); SHA512_STEP(c, d, e, f, g, h, a, b, 14, 0x9bdc06a725c71235ULL); SHA512_STEP(b, c, d, e, f, g, h, a, 15, 0xc19bf174cf692694ULL); SHA512_STEP(a, b, c, d, e, f, g, h, 16, 0xe49b69c19ef14ad2ULL); SHA512_STEP(h, a, b, c, d, e, f, g, 17, 0xefbe4786384f25e3ULL); SHA512_STEP(g, h, a, b, c, d, e, f, 18, 0x0fc19dc68b8cd5b5ULL); SHA512_STEP(f, g, h, a, b, c, d, e, 19, 0x240ca1cc77ac9c65ULL); SHA512_STEP(e, f, g, h, a, b, c, d, 20, 0x2de92c6f592b0275ULL); SHA512_STEP(d, e, f, g, h, a, b, c, 21, 0x4a7484aa6ea6e483ULL); SHA512_STEP(c, d, e, f, g, h, a, b, 22, 0x5cb0a9dcbd41fbd4ULL); SHA512_STEP(b, c, d, e, f, g, h, a, 23, 0x76f988da831153b5ULL); SHA512_STEP(a, b, c, d, e, f, g, h, 24, 0x983e5152ee66dfabULL); SHA512_STEP(h, a, b, c, d, e, f, g, 25, 0xa831c66d2db43210ULL); SHA512_STEP(g, h, a, b, c, d, e, f, 26, 0xb00327c898fb213fULL); SHA512_STEP(f, g, h, a, b, c, d, e, 27, 0xbf597fc7beef0ee4ULL); SHA512_STEP(e, f, g, h, a, b, c, d, 28, 0xc6e00bf33da88fc2ULL); SHA512_STEP(d, e, f, g, h, a, b, c, 29, 0xd5a79147930aa725ULL); SHA512_STEP(c, d, e, f, g, h, a, b, 30, 0x06ca6351e003826fULL); SHA512_STEP(b, c, d, e, f, g, h, a, 31, 0x142929670a0e6e70ULL); SHA512_STEP(a, b, c, d, e, f, g, h, 32, 0x27b70a8546d22ffcULL); SHA512_STEP(h, a, b, c, d, e, f, g, 33, 0x2e1b21385c26c926ULL); SHA512_STEP(g, h, a, b, c, d, e, f, 34, 0x4d2c6dfc5ac42aedULL); SHA512_STEP(f, g, h, a, b, c, d, e, 35, 0x53380d139d95b3dfULL); SHA512_STEP(e, f, g, h, a, b, c, d, 36, 0x650a73548baf63deULL); SHA512_STEP(d, e, f, g, h, a, b, c, 37, 0x766a0abb3c77b2a8ULL); SHA512_STEP(c, d, e, f, g, h, a, b, 38, 0x81c2c92e47edaee6ULL); SHA512_STEP(b, c, d, e, f, g, h, a, 39, 0x92722c851482353bULL); SHA512_STEP(a, b, c, d, e, f, g, h, 40, 0xa2bfe8a14cf10364ULL); SHA512_STEP(h, a, b, c, d, e, f, g, 41, 0xa81a664bbc423001ULL); SHA512_STEP(g, h, a, b, c, d, e, f, 42, 0xc24b8b70d0f89791ULL); SHA512_STEP(f, g, h, a, b, c, d, e, 43, 0xc76c51a30654be30ULL); SHA512_STEP(e, f, g, h, a, b, c, d, 44, 0xd192e819d6ef5218ULL); SHA512_STEP(d, e, f, g, h, a, b, c, 45, 0xd69906245565a910ULL); SHA512_STEP(c, d, e, f, g, h, a, b, 46, 0xf40e35855771202aULL); SHA512_STEP(b, c, d, e, f, g, h, a, 47, 0x106aa07032bbd1b8ULL); SHA512_STEP(a, b, c, d, e, f, g, h, 48, 0x19a4c116b8d2d0c8ULL); SHA512_STEP(h, a, b, c, d, e, f, g, 49, 0x1e376c085141ab53ULL); SHA512_STEP(g, h, a, b, c, d, e, f, 50, 0x2748774cdf8eeb99ULL); SHA512_STEP(f, g, h, a, b, c, d, e, 51, 0x34b0bcb5e19b48a8ULL); SHA512_STEP(e, f, g, h, a, b, c, d, 52, 0x391c0cb3c5c95a63ULL); SHA512_STEP(d, e, f, g, h, a, b, c, 53, 0x4ed8aa4ae3418acbULL); SHA512_STEP(c, d, e, f, g, h, a, b, 54, 0x5b9cca4f7763e373ULL); SHA512_STEP(b, c, d, e, f, g, h, a, 55, 0x682e6ff3d6b2b8a3ULL); SHA512_STEP(a, b, c, d, e, f, g, h, 56, 0x748f82ee5defb2fcULL); SHA512_STEP(h, a, b, c, d, e, f, g, 57, 0x78a5636f43172f60ULL); SHA512_STEP(g, h, a, b, c, d, e, f, 58, 0x84c87814a1f0ab72ULL); SHA512_STEP(f, g, h, a, b, c, d, e, 59, 0x8cc702081a6439ecULL); SHA512_STEP(e, f, g, h, a, b, c, d, 60, 0x90befffa23631e28ULL); SHA512_STEP(d, e, f, g, h, a, b, c, 61, 0xa4506cebde82bde9ULL); SHA512_STEP(c, d, e, f, g, h, a, b, 62, 0xbef9a3f7b2c67915ULL); SHA512_STEP(b, c, d, e, f, g, h, a, 63, 0xc67178f2e372532bULL); SHA512_STEP(a, b, c, d, e, f, g, h, 64, 0xca273eceea26619cULL); SHA512_STEP(h, a, b, c, d, e, f, g, 65, 0xd186b8c721c0c207ULL); SHA512_STEP(g, h, a, b, c, d, e, f, 66, 0xeada7dd6cde0eb1eULL); SHA512_STEP(f, g, h, a, b, c, d, e, 67, 0xf57d4f7fee6ed178ULL); SHA512_STEP(e, f, g, h, a, b, c, d, 68, 0x06f067aa72176fbaULL); SHA512_STEP(d, e, f, g, h, a, b, c, 69, 0x0a637dc5a2c898a6ULL); SHA512_STEP(c, d, e, f, g, h, a, b, 70, 0x113f9804bef90daeULL); SHA512_STEP(b, c, d, e, f, g, h, a, 71, 0x1b710b35131c471bULL); SHA512_STEP(a, b, c, d, e, f, g, h, 72, 0x28db77f523047d84ULL); if (SSEi_flags & SSEi_REVERSE_STEPS && !(SSEi_flags & SSEi_CRYPT_SHA384)) { SHA512_PARA_DO(i) { vstore((vtype *) &(out[i * 8 * VS64 + 0 * VS64]), h[i]); } return; } SHA512_STEP(h, a, b, c, d, e, f, g, 73, 0x32caab7b40c72493ULL); SHA512_STEP(g, h, a, b, c, d, e, f, 74, 0x3c9ebe0a15c9bebcULL); SHA512_STEP(f, g, h, a, b, c, d, e, 75, 0x431d67c49c100d4cULL); SHA512_STEP(e, f, g, h, a, b, c, d, 76, 0x4cc5d4becb3e42b6ULL); if (SSEi_flags & SSEi_REVERSE_STEPS) { SHA512_PARA_DO(i) { vstore((vtype *) &(out[i * 8 * VS64 + 3 * VS64]), d[i]); } return; } SHA512_STEP(d, e, f, g, h, a, b, c, 77, 0x597f299cfc657e2aULL); SHA512_STEP(c, d, e, f, g, h, a, b, 78, 0x5fcb6fab3ad6faecULL); SHA512_STEP(b, c, d, e, f, g, h, a, 79, 0x6c44198c4a475817ULL); if (SSEi_flags & SSEi_RELOAD) { if ((SSEi_flags & SSEi_RELOAD_INP_FMT) == SSEi_RELOAD_INP_FMT) { SHA512_PARA_DO(i) { a[i] = vadd_epi64( a[i], vload((vtype *) &reload_state[i * 16 * VS64 + 0 * VS64])); b[i] = vadd_epi64( b[i], vload((vtype *) &reload_state[i * 16 * VS64 + 1 * VS64])); c[i] = vadd_epi64( c[i], vload((vtype *) &reload_state[i * 16 * VS64 + 2 * VS64])); d[i] = vadd_epi64( d[i], vload((vtype *) &reload_state[i * 16 * VS64 + 3 * VS64])); e[i] = vadd_epi64( e[i], vload((vtype *) &reload_state[i * 16 * VS64 + 4 * VS64])); f[i] = vadd_epi64( f[i], vload((vtype *) &reload_state[i * 16 * VS64 + 5 * VS64])); g[i] = vadd_epi64( g[i], vload((vtype *) &reload_state[i * 16 * VS64 + 6 * VS64])); h[i] = vadd_epi64( h[i], vload((vtype *) &reload_state[i * 16 * VS64 + 7 * VS64])); } } else { SHA512_PARA_DO(i) { a[i] = vadd_epi64( a[i], vload((vtype *) &reload_state[i * 8 * VS64 + 0 * VS64])); b[i] = vadd_epi64( b[i], vload((vtype *) &reload_state[i * 8 * VS64 + 1 * VS64])); c[i] = vadd_epi64( c[i], vload((vtype *) &reload_state[i * 8 * VS64 + 2 * VS64])); d[i] = vadd_epi64( d[i], vload((vtype *) &reload_state[i * 8 * VS64 + 3 * VS64])); e[i] = vadd_epi64( e[i], vload((vtype *) &reload_state[i * 8 * VS64 + 4 * VS64])); f[i] = vadd_epi64( f[i], vload((vtype *) &reload_state[i * 8 * VS64 + 5 * VS64])); g[i] = vadd_epi64( g[i], vload((vtype *) &reload_state[i * 8 * VS64 + 6 * VS64])); h[i] = vadd_epi64( h[i], vload((vtype *) &reload_state[i * 8 * VS64 + 7 * VS64])); } } } else { if (SSEi_flags & SSEi_CRYPT_SHA384) { SHA512_PARA_DO(i) { /* SHA-384 IV */ a[i] = vadd_epi64(a[i], vset1_epi64(0xcbbb9d5dc1059ed8ULL)); b[i] = vadd_epi64(b[i], vset1_epi64(0x629a292a367cd507ULL)); c[i] = vadd_epi64(c[i], vset1_epi64(0x9159015a3070dd17ULL)); d[i] = vadd_epi64(d[i], vset1_epi64(0x152fecd8f70e5939ULL)); e[i] = vadd_epi64(e[i], vset1_epi64(0x67332667ffc00b31ULL)); f[i] = vadd_epi64(f[i], vset1_epi64(0x8eb44a8768581511ULL)); g[i] = vadd_epi64(g[i], vset1_epi64(0xdb0c2e0d64f98fa7ULL)); h[i] = vadd_epi64(h[i], vset1_epi64(0x47b5481dbefa4fa4ULL)); } } else { SHA512_PARA_DO(i) { /* SHA-512 IV */ a[i] = vadd_epi64(a[i], vset1_epi64(0x6a09e667f3bcc908ULL)); b[i] = vadd_epi64(b[i], vset1_epi64(0xbb67ae8584caa73bULL)); c[i] = vadd_epi64(c[i], vset1_epi64(0x3c6ef372fe94f82bULL)); d[i] = vadd_epi64(d[i], vset1_epi64(0xa54ff53a5f1d36f1ULL)); e[i] = vadd_epi64(e[i], vset1_epi64(0x510e527fade682d1ULL)); f[i] = vadd_epi64(f[i], vset1_epi64(0x9b05688c2b3e6c1fULL)); g[i] = vadd_epi64(g[i], vset1_epi64(0x1f83d9abfb41bd6bULL)); h[i] = vadd_epi64(h[i], vset1_epi64(0x5be0cd19137e2179ULL)); } } } if (SSEi_flags & SSEi_FLAT_OUT) { SHA512_PARA_DO(i) { uint64_t * o = (uint64_t *) &out[i * 8 * VS64]; #if __AVX512F__ || __MIC__ vtype idxs = vset_epi64( 7 << 3, 6 << 3, 5 << 3, 4 << 3, 3 << 3, 2 << 3, 1 << 3, 0 << 3); vscatter_epi64((((uint64_t *) o) + 0), idxs, vswap64(a[i]), 8); vscatter_epi64((((uint64_t *) o) + 1), idxs, vswap64(b[i]), 8); vscatter_epi64((((uint64_t *) o) + 2), idxs, vswap64(c[i]), 8); vscatter_epi64((((uint64_t *) o) + 3), idxs, vswap64(d[i]), 8); vscatter_epi64((((uint64_t *) o) + 4), idxs, vswap64(e[i]), 8); vscatter_epi64((((uint64_t *) o) + 5), idxs, vswap64(f[i]), 8); vscatter_epi64((((uint64_t *) o) + 6), idxs, vswap64(g[i]), 8); vscatter_epi64((((uint64_t *) o) + 7), idxs, vswap64(h[i]), 8); #else uint64_t j, k; union { vtype v[8]; uint64_t s[8 * VS64]; } tmp; tmp.v[0] = vswap64(a[i]); tmp.v[1] = vswap64(b[i]); tmp.v[2] = vswap64(c[i]); tmp.v[3] = vswap64(d[i]); tmp.v[4] = vswap64(e[i]); tmp.v[5] = vswap64(f[i]); tmp.v[6] = vswap64(g[i]); tmp.v[7] = vswap64(h[i]); for (j = 0; j < VS64; j++) for (k = 0; k < 8; k++) o[j * 8 + k] = tmp.s[k * VS64 + j]; #endif } } else if (SSEi_flags & SSEi_OUTPUT_AS_INP_FMT) { if ((SSEi_flags & SSEi_OUTPUT_AS_2BUF_INP_FMT) == SSEi_OUTPUT_AS_2BUF_INP_FMT) { SHA512_PARA_DO(i) { vstore((vtype *) &out[i * 32 * VS64 + 0 * VS64], a[i]); vstore((vtype *) &out[i * 32 * VS64 + 1 * VS64], b[i]); vstore((vtype *) &out[i * 32 * VS64 + 2 * VS64], c[i]); vstore((vtype *) &out[i * 32 * VS64 + 3 * VS64], d[i]); vstore((vtype *) &out[i * 32 * VS64 + 4 * VS64], e[i]); vstore((vtype *) &out[i * 32 * VS64 + 5 * VS64], f[i]); vstore((vtype *) &out[i * 32 * VS64 + 6 * VS64], g[i]); vstore((vtype *) &out[i * 32 * VS64 + 7 * VS64], h[i]); } } else { SHA512_PARA_DO(i) { vstore((vtype *) &out[i * 16 * VS64 + 0 * VS64], a[i]); vstore((vtype *) &out[i * 16 * VS64 + 1 * VS64], b[i]); vstore((vtype *) &out[i * 16 * VS64 + 2 * VS64], c[i]); vstore((vtype *) &out[i * 16 * VS64 + 3 * VS64], d[i]); vstore((vtype *) &out[i * 16 * VS64 + 4 * VS64], e[i]); vstore((vtype *) &out[i * 16 * VS64 + 5 * VS64], f[i]); vstore((vtype *) &out[i * 16 * VS64 + 6 * VS64], g[i]); vstore((vtype *) &out[i * 16 * VS64 + 7 * VS64], h[i]); } } } else { SHA512_PARA_DO(i) { vstore((vtype *) &(out[i * 8 * VS64 + 0 * VS64]), a[i]); vstore((vtype *) &(out[i * 8 * VS64 + 1 * VS64]), b[i]); vstore((vtype *) &(out[i * 8 * VS64 + 2 * VS64]), c[i]); vstore((vtype *) &(out[i * 8 * VS64 + 3 * VS64]), d[i]); vstore((vtype *) &(out[i * 8 * VS64 + 4 * VS64]), e[i]); vstore((vtype *) &(out[i * 8 * VS64 + 5 * VS64]), f[i]); vstore((vtype *) &(out[i * 8 * VS64 + 6 * VS64]), g[i]); vstore((vtype *) &(out[i * 8 * VS64 + 7 * VS64]), h[i]); } } } #endif /* SIMD_PARA_SHA512 */ aircrack-ng-1.6/lib/ce-wpa/wpapsk.c000066400000000000000000000412141361312141100171270ustar00rootroot00000000000000/* * Based on John the Ripper and modified to integrate with aircrack * * John the Ripper copyright and license. * * John the Ripper password cracker, * Copyright (c) 1996-2013 by Solar Designer. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * As a special exception to the GNU General Public License terms, * permission is hereby granted to link the code of this program, with or * without modification, with any version of the OpenSSL library and/or any * version of unRAR, and to distribute such linked combinations. You must * obey the GNU GPL in all respects for all of the code used other than * OpenSSL and unRAR. If you modify this program, you may extend this * exception to your version of the program, but you are not obligated to * do so. (In other words, you may release your derived work under pure * GNU GPL version 2 or later as published by the FSF.) * * (This exception from the GNU GPL is not required for the core tree of * John the Ripper, but arguably it is required for -jumbo.) * * Relaxed terms for certain components. * * In addition or alternatively to the license above, many components are * available to you under more relaxed terms (most commonly under cut-down * BSD license) as specified in the corresponding source files. * * For more information on John the Ripper licensing please visit: * * http://www.openwall.com/john/doc/LICENSE.shtml * * This software is Copyright (c) 2012 Lukas Odzioba * and it is hereby released to the general public under the following terms: * Redistribution and use in source and binary forms, with or without * modification, are permitted. * * Code is based on Aircrack-ng source * * SSE2 code enhancement, Jim Fougeron, Jan, 2013. * Also removed oSSL code: HMAC(EVP_sha1(), ....), and coded what it does * (which is simple), inline. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include "aircrack-ng/ce-wpa/simd-intrinsics.h" #include "aircrack-ng/aircrack-ng.h" #include "aircrack-ng/ce-wpa/arch.h" #include "aircrack-ng/ce-wpa/wpapsk.h" #include "aircrack-ng/ce-wpa/johnswap.h" #include "aircrack-ng/ce-wpa/memory.h" #include "aircrack-ng/cpu/simd_cpuid.h" // #define XDEBUG #if defined(__INTEL_COMPILER) #define SIMD_PARA_SHA1 1 #elif defined(__clang__) #define SIMD_PARA_SHA1 1 #elif defined(__llvm__) #define SIMD_PARA_SHA1 1 #elif defined(__GNUC__) && GCC_VERSION < 40504 // 4.5.4 #define SIMD_PARA_SHA1 1 #elif !defined(__AVX__) && defined(__GNUC__) && GCC_VERSION > 40700 // 4.7.0 #define SIMD_PARA_SHA1 1 #else #define SIMD_PARA_SHA1 1 #endif #ifdef SIMD_CORE #ifdef SIMD_COEF_32 #define NBKEYS (SIMD_COEF_32 * SIMD_PARA_SHA1) #ifdef _OPENMP #include #endif #else #define NBKEYS 1 #ifdef _OPENMP #include #endif #endif #else #ifdef MMX_COEF #define NBKEYS (MMX_COEF * SHA1_SSE_PARA) #ifdef _OPENMP #include #endif #else #define NBKEYS 1 #ifdef _OPENMP #include #endif #endif #endif #include "aircrack-ng/ce-wpa/memdbg.h" #ifndef SIMD_CORE #undef SIMDSHA1body #define SIMDSHA1body SSESHA1body #endif static char itoa64[64] = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; char atoi64[0x100]; /* for endianity conversion */ #ifdef SIMD_CORE #define GETPOS(i, index) \ ((index & (SIMD_COEF_32 - 1)) * 4 \ + ((i) & (0xffffffff - 3)) * SIMD_COEF_32 \ + (3 - ((i) &3)) \ + (unsigned int) index / SIMD_COEF_32 * SHA_BUF_SIZ * SIMD_COEF_32 * 4) #else #define GETPOS(i, index) \ (((index) & (MMX_COEF - 1)) * 4 + ((i) & (0xffffffff - 3)) * MMX_COEF \ + (3 - ((i) &3)) \ + ((index) >> (MMX_COEF >> 1)) * SHA_BUF_SIZ * MMX_COEF * 4) #endif #ifdef SIMD_CORE static MAYBE_INLINE void wpapsk_sse(ac_crypto_engine_t * engine, int threadid, int count, const wpapsk_password * in) { int t; // thread count int salt_length = engine->essid_length; int slen = salt_length + 4; int loops = (count + NBKEYS - 1) / NBKEYS; unsigned char * sse_hash1 = NULL; unsigned char * sse_crypt1 = NULL; unsigned char * sse_crypt2 = NULL; unsigned char essid[ESSID_LENGTH + 4]; sse_hash1 = engine->thread_data[threadid]->hash1; sse_crypt1 = engine->thread_data[threadid]->crypt1; sse_crypt2 = engine->thread_data[threadid]->crypt2; memset(essid, 0, sizeof(essid)); strncpy((char *) essid, (const char *) engine->essid, (size_t) engine->essid_length); for (t = 0; t < loops; t++) { unsigned int i, k, j; union { unsigned char c[64]; uint32_t i[16]; } buffer[NBKEYS]; char __dummy[CACHELINE_SIZE]; union { unsigned char c[40]; // only 40 are used uint32_t i[10]; // only 8 are used } outbuf[NBKEYS]; char __dummy2[CACHELINE_SIZE]; SHA_CTX ctx_ipad[NBKEYS]; SHA_CTX ctx_opad[NBKEYS]; SHA_CTX sha1_ctx; unsigned int *i1, *i2, *o1; unsigned char *t_sse_crypt1, *t_sse_crypt2, *t_sse_hash1; // All pointers get their offset for this thread here. No further // offsetting below. t_sse_crypt1 = &sse_crypt1[t * NBKEYS * 20]; t_sse_crypt2 = &sse_crypt2[t * NBKEYS * 20]; t_sse_hash1 = &sse_hash1[t * NBKEYS * SHA_BUF_SIZ * 4]; i1 = (unsigned int *) t_sse_crypt1; i2 = (unsigned int *) t_sse_crypt2; o1 = (unsigned int *) t_sse_hash1; (void) __dummy; (void) __dummy2; for (j = 0; j < NBKEYS; ++j) { memcpy( buffer[j].c, in[t * NBKEYS + j].v, in[t * NBKEYS + j].length); memset(&buffer[j].c[in[t * NBKEYS + j].length], 0, 64 - in[t * NBKEYS + j].length); SHA1_Init(&ctx_ipad[j]); SHA1_Init(&ctx_opad[j]); UNROLL_LOOP_N_TIME(8) for (i = 0; i < 16; i++) buffer[j].i[i] ^= 0x36363636; SHA1_Update(&ctx_ipad[j], buffer[j].c, 64); UNROLL_LOOP_N_TIME(8) for (i = 0; i < 16; i++) buffer[j].i[i] ^= 0x6a6a6a6a; SHA1_Update(&ctx_opad[j], buffer[j].c, 64); // we memcopy from flat into MMX_COEF output buffer's (our 'temp' ctx buffer). // This data will NOT need to be BE swapped (it already IS BE swapped). #ifdef SIMD_CORE i1[(j / SIMD_COEF_32) * SIMD_COEF_32 * 5 + (j & (SIMD_COEF_32 - 1)) + 0 * SIMD_COEF_32] = ctx_ipad[j].h0; i1[(j / SIMD_COEF_32) * SIMD_COEF_32 * 5 + (j & (SIMD_COEF_32 - 1)) + 1 * SIMD_COEF_32] = ctx_ipad[j].h1; i1[(j / SIMD_COEF_32) * SIMD_COEF_32 * 5 + (j & (SIMD_COEF_32 - 1)) + 2 * SIMD_COEF_32] = ctx_ipad[j].h2; i1[(j / SIMD_COEF_32) * SIMD_COEF_32 * 5 + (j & (SIMD_COEF_32 - 1)) + 3 * SIMD_COEF_32] = ctx_ipad[j].h3; i1[(j / SIMD_COEF_32) * SIMD_COEF_32 * 5 + (j & (SIMD_COEF_32 - 1)) + 4 * SIMD_COEF_32] = ctx_ipad[j].h4; i2[(j / SIMD_COEF_32) * SIMD_COEF_32 * 5 + (j & (SIMD_COEF_32 - 1)) + 0 * SIMD_COEF_32] = ctx_opad[j].h0; i2[(j / SIMD_COEF_32) * SIMD_COEF_32 * 5 + (j & (SIMD_COEF_32 - 1)) + 1 * SIMD_COEF_32] = ctx_opad[j].h1; i2[(j / SIMD_COEF_32) * SIMD_COEF_32 * 5 + (j & (SIMD_COEF_32 - 1)) + 2 * SIMD_COEF_32] = ctx_opad[j].h2; i2[(j / SIMD_COEF_32) * SIMD_COEF_32 * 5 + (j & (SIMD_COEF_32 - 1)) + 3 * SIMD_COEF_32] = ctx_opad[j].h3; i2[(j / SIMD_COEF_32) * SIMD_COEF_32 * 5 + (j & (SIMD_COEF_32 - 1)) + 4 * SIMD_COEF_32] = ctx_opad[j].h4; #else i1[(j / MMX_COEF) * MMX_COEF * 5 + (j & (MMX_COEF - 1))] = ctx_ipad[j].h0; i1[(j / MMX_COEF) * MMX_COEF * 5 + (j & (MMX_COEF - 1)) + MMX_COEF] = ctx_ipad[j].h1; i1[(j / MMX_COEF) * MMX_COEF * 5 + (j & (MMX_COEF - 1)) + (MMX_COEF << 1)] = ctx_ipad[j].h2; i1[(j / MMX_COEF) * MMX_COEF * 5 + (j & (MMX_COEF - 1)) + MMX_COEF * 3] = ctx_ipad[j].h3; i1[(j / MMX_COEF) * MMX_COEF * 5 + (j & (MMX_COEF - 1)) + (MMX_COEF << 2)] = ctx_ipad[j].h4; i2[(j / MMX_COEF) * MMX_COEF * 5 + (j & (MMX_COEF - 1))] = ctx_opad[j].h0; i2[(j / MMX_COEF) * MMX_COEF * 5 + (j & (MMX_COEF - 1)) + MMX_COEF] = ctx_opad[j].h1; i2[(j / MMX_COEF) * MMX_COEF * 5 + (j & (MMX_COEF - 1)) + (MMX_COEF << 1)] = ctx_opad[j].h2; i2[(j / MMX_COEF) * MMX_COEF * 5 + (j & (MMX_COEF - 1)) + MMX_COEF * 3] = ctx_opad[j].h3; i2[(j / MMX_COEF) * MMX_COEF * 5 + (j & (MMX_COEF - 1)) + (MMX_COEF << 2)] = ctx_opad[j].h4; #endif essid[slen - 1] = 1; // This code does the HMAC(EVP_....) call. We already have essid // appended with BE((int)1) so we simply call a single SHA1_Update memcpy(&sha1_ctx, &ctx_ipad[j], sizeof(sha1_ctx)); SHA1_Update(&sha1_ctx, essid, slen); SHA1_Final(outbuf[j].c, &sha1_ctx); memcpy(&sha1_ctx, &ctx_opad[j], sizeof(sha1_ctx)); SHA1_Update(&sha1_ctx, outbuf[j].c, SHA_DIGEST_LENGTH); SHA1_Final(outbuf[j].c, &sha1_ctx); // now convert this from flat into MMX_COEF buffers. (same as the memcpy() // commented out in the last line) // Also, perform the 'first' ^= into the crypt buffer. We are doing that in BE // format // so we will need to 'undo' that in the end. #ifdef SIMD_CORE o1[(j / SIMD_COEF_32) * SIMD_COEF_32 * SHA_BUF_SIZ + (j & (SIMD_COEF_32 - 1)) + 0 * SIMD_COEF_32] = outbuf[j].i[0] = sha1_ctx.h0; o1[(j / SIMD_COEF_32) * SIMD_COEF_32 * SHA_BUF_SIZ + (j & (SIMD_COEF_32 - 1)) + 1 * SIMD_COEF_32] = outbuf[j].i[1] = sha1_ctx.h1; o1[(j / SIMD_COEF_32) * SIMD_COEF_32 * SHA_BUF_SIZ + (j & (SIMD_COEF_32 - 1)) + 2 * SIMD_COEF_32] = outbuf[j].i[2] = sha1_ctx.h2; o1[(j / SIMD_COEF_32) * SIMD_COEF_32 * SHA_BUF_SIZ + (j & (SIMD_COEF_32 - 1)) + 3 * SIMD_COEF_32] = outbuf[j].i[3] = sha1_ctx.h3; o1[(j / SIMD_COEF_32) * SIMD_COEF_32 * SHA_BUF_SIZ + (j & (SIMD_COEF_32 - 1)) + 4 * SIMD_COEF_32] = outbuf[j].i[4] = sha1_ctx.h4; #else o1[(j / MMX_COEF) * MMX_COEF * SHA_BUF_SIZ + (j & (MMX_COEF - 1))] = outbuf[j].i[0] = sha1_ctx.h0; o1[(j / MMX_COEF) * MMX_COEF * SHA_BUF_SIZ + (j & (MMX_COEF - 1)) + MMX_COEF] = outbuf[j].i[1] = sha1_ctx.h1; o1[(j / MMX_COEF) * MMX_COEF * SHA_BUF_SIZ + (j & (MMX_COEF - 1)) + (MMX_COEF << 1)] = outbuf[j].i[2] = sha1_ctx.h2; o1[(j / MMX_COEF) * MMX_COEF * SHA_BUF_SIZ + (j & (MMX_COEF - 1)) + MMX_COEF * 3] = outbuf[j].i[3] = sha1_ctx.h3; o1[(j / MMX_COEF) * MMX_COEF * SHA_BUF_SIZ + (j & (MMX_COEF - 1)) + (MMX_COEF << 2)] = outbuf[j].i[4] = sha1_ctx.h4; #endif } for (i = 1; i < 4096; i++) { SIMDSHA1body((unsigned int *) t_sse_hash1, (unsigned int *) t_sse_hash1, (unsigned int *) t_sse_crypt1, SSEi_MIXED_IN | SSEi_RELOAD | SSEi_OUTPUT_AS_INP_FMT); SIMDSHA1body((unsigned int *) t_sse_hash1, (unsigned int *) t_sse_hash1, (unsigned int *) t_sse_crypt2, SSEi_MIXED_IN | SSEi_RELOAD | SSEi_OUTPUT_AS_INP_FMT); for (j = 0; j < NBKEYS; j++) { #ifdef SIMD_CORE uint32_t * p = &((uint32_t *) t_sse_hash1)[(((j / SIMD_COEF_32) * SHA_BUF_SIZ) * SIMD_COEF_32) + (j & (SIMD_COEF_32 - 1))]; UNROLL_LOOP_N_TIME(5) for (k = 0; k < 5; k++) outbuf[j].i[k] ^= p[(k * SIMD_COEF_32)]; #else uint32_t * p = &(( uint32_t *) t_sse_hash1)[(((j >> 2) * SHA_BUF_SIZ) << 2) + (j & (MMX_COEF - 1))]; UNROLL_LOOP_N_TIME(5) for (k = 0; k < 5; k++) outbuf[j].i[k] ^= p[(k << (MMX_COEF >> 1))]; #endif } } essid[slen - 1] = 2; for (j = 0; j < NBKEYS; ++j) { // This code does the HMAC(EVP_....) call. We already have essid // appended with BE((int)1) so we simply call a single SHA1_Update memcpy(&sha1_ctx, &ctx_ipad[j], sizeof(sha1_ctx)); SHA1_Update(&sha1_ctx, essid, slen); SHA1_Final(&outbuf[j].c[20], &sha1_ctx); memcpy(&sha1_ctx, &ctx_opad[j], sizeof(sha1_ctx)); SHA1_Update(&sha1_ctx, &outbuf[j].c[20], 20); SHA1_Final(&outbuf[j].c[20], &sha1_ctx); // now convert this from flat into MMX_COEF buffers. (same as the memcpy() // commented out in the last line) // Also, perform the 'first' ^= into the crypt buffer. We are doing that in BE // format // so we will need to 'undo' that in the end. (only 3 dwords of the 2nd block // outbuf are worked with). #ifdef SIMD_CORE o1[(j / SIMD_COEF_32) * SIMD_COEF_32 * SHA_BUF_SIZ + (j & (SIMD_COEF_32 - 1)) + 0 * SIMD_COEF_32] = outbuf[j].i[5] = sha1_ctx.h0; o1[(j / SIMD_COEF_32) * SIMD_COEF_32 * SHA_BUF_SIZ + (j & (SIMD_COEF_32 - 1)) + 1 * SIMD_COEF_32] = outbuf[j].i[6] = sha1_ctx.h1; o1[(j / SIMD_COEF_32) * SIMD_COEF_32 * SHA_BUF_SIZ + (j & (SIMD_COEF_32 - 1)) + 2 * SIMD_COEF_32] = outbuf[j].i[7] = sha1_ctx.h2; o1[(j / SIMD_COEF_32) * SIMD_COEF_32 * SHA_BUF_SIZ + (j & (SIMD_COEF_32 - 1)) + 3 * SIMD_COEF_32] = sha1_ctx.h3; o1[(j / SIMD_COEF_32) * SIMD_COEF_32 * SHA_BUF_SIZ + (j & (SIMD_COEF_32 - 1)) + 4 * SIMD_COEF_32] = sha1_ctx.h4; #else o1[(j / MMX_COEF) * MMX_COEF * SHA_BUF_SIZ + (j & (MMX_COEF - 1))] = outbuf[j].i[5] = sha1_ctx.h0; o1[(j / MMX_COEF) * MMX_COEF * SHA_BUF_SIZ + (j & (MMX_COEF - 1)) + MMX_COEF] = outbuf[j].i[6] = sha1_ctx.h1; o1[(j / MMX_COEF) * MMX_COEF * SHA_BUF_SIZ + (j & (MMX_COEF - 1)) + (MMX_COEF << 1)] = outbuf[j].i[7] = sha1_ctx.h2; o1[(j / MMX_COEF) * MMX_COEF * SHA_BUF_SIZ + (j & (MMX_COEF - 1)) + MMX_COEF * 3] = sha1_ctx.h3; o1[(j / MMX_COEF) * MMX_COEF * SHA_BUF_SIZ + (j & (MMX_COEF - 1)) + (MMX_COEF << 2)] = sha1_ctx.h4; #endif } for (i = 1; i < 4096; i++) { SIMDSHA1body((unsigned int *) t_sse_hash1, (unsigned int *) t_sse_hash1, (unsigned int *) t_sse_crypt1, SSEi_MIXED_IN | SSEi_RELOAD | SSEi_OUTPUT_AS_INP_FMT); SIMDSHA1body((unsigned int *) t_sse_hash1, (unsigned int *) t_sse_hash1, (unsigned int *) t_sse_crypt2, SSEi_MIXED_IN | SSEi_RELOAD | SSEi_OUTPUT_AS_INP_FMT); for (j = 0; j < NBKEYS; j++) { #ifdef SIMD_CORE uint32_t * p = &((uint32_t *) t_sse_hash1)[(((j / SIMD_COEF_32) * SHA_BUF_SIZ) * SIMD_COEF_32) + (j & (SIMD_COEF_32 - 1))]; UNROLL_LOOP_N_TIME(4) for (k = 5; k < 8; k++) outbuf[j].i[k] ^= p[((k - 5) * SIMD_COEF_32)]; #else uint32_t * p = &(( uint32_t *) t_sse_hash1)[(((j >> 2) * SHA_BUF_SIZ) << 2) + (j & (MMX_COEF - 1))]; UNROLL_LOOP_N_TIME(4) for (k = 5; k < 8; k++) outbuf[j].i[k] ^= p[((k - 5) << (MMX_COEF >> 1))]; #endif } } for (j = 0; j < NBKEYS; ++j) { memcpy(&engine->thread_data[threadid]->pmk[j], //-V512 outbuf[j].c, 32); alter_endianity_to_BE((&engine->thread_data[threadid]->pmk[j]), 8); } } return; } #endif void init_atoi() { char * pos; memset(atoi64, 0x7F, sizeof(atoi64)); for (pos = itoa64; pos != &itoa64[63]; pos++) atoi64[ARCH_INDEX(*pos)] = pos - itoa64; } #ifdef SIMD_CORE //#define XDEBUG 1 //#define ODEBUG 1 int init_wpapsk(ac_crypto_engine_t * engine, const wpapsk_password key[MAX_KEYS_PER_CRYPT_SUPPORTED], int nparallel, int threadid) { int i = 0; int count = 0; // clear entire output table memset(engine->thread_data[threadid]->pmk, 0, (sizeof(wpapsk_hash) * (nparallel))); { unsigned char * sse_hash1 = engine->thread_data[threadid]->hash1; int index; for (index = 0; index < nparallel; ++index) { // set the length of all hash1 SSE buffer to 64+20 * 8 bits. The 64 is for the // ipad/opad, // the 20 is for the length of the SHA1 buffer that also gets into each crypt. // Works for SSE2i and SSE2 #ifdef SIMD_CORE ((unsigned int *) sse_hash1)[15 * SIMD_COEF_32 + (index & (SIMD_COEF_32 - 1)) + (unsigned int) index / SIMD_COEF_32 * SHA_BUF_SIZ * SIMD_COEF_32] = (84 << 3); // all encrypts are 64+20 bytes. #else ((unsigned int *) sse_hash1)[15 * MMX_COEF + (index & (MMX_COEF - 1)) + (index >> (MMX_COEF >> 1)) * SHA_BUF_SIZ * MMX_COEF] = (84 << 3); // all encrypts are 64+20 bytes. #endif sse_hash1[GETPOS(20, index)] = 0x80; } } for (i = 0; i < nparallel; ++i) { char * tkey = (char *) key[i].v; if (*tkey != 0) { // set_key(tkey, i, inbuffer); #ifdef XDEBUG printf( "key%d (inbuffer) = (%p) %s VALID\n", i + 1, tkey, key[i].v); #endif count = i + 1; } } wpapsk_sse(engine, threadid, count, key); return 0; } #endifaircrack-ng-1.6/lib/cowpatty/000077500000000000000000000000001361312141100161525ustar00rootroot00000000000000aircrack-ng-1.6/lib/cowpatty/cowpatty.c000066400000000000000000000124401361312141100201710ustar00rootroot00000000000000/* * coWPAtty hash DB file helper functions * * Copyright (C) 2018 Thomas d'Otreppe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. * If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. * If you * do not wish to do so, delete this exception statement from your * version. * If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include "aircrack-ng/defs.h" #include "aircrack-ng/cowpatty/cowpatty.h" void close_free_cowpatty_hashdb(struct cowpatty_file * cf) { if (cf != NULL) { if (cf->fp) { fclose(cf->fp); } free(cf); } } struct cowpatty_file * open_cowpatty_hashdb(const char * filename, const char * mode) { struct hashdb_head filehead; // Initialize structure struct cowpatty_file * ret = (struct cowpatty_file *) malloc(sizeof(struct cowpatty_file)); ALLEGE(ret != NULL); memset(ret->ssid, 0, sizeof(ret->ssid)); memset(ret->error, 0, sizeof(ret->error)); ret->fp = NULL; if (filename == NULL || filename[0] == 0) { strcpy(ret->error, "No filename specified"); return (ret); } if (mode == NULL || strncmp(mode, "r", 1) == 0) { if (strcmp(filename, "-") == 0) { ret->fp = stdin; } else { ret->fp = fopen(filename, "r"); if (ret->fp == NULL) { snprintf(ret->error, sizeof(ret->error), "File <%s> cannot be opened", filename); return (ret); } } // Check headers if (fread(&filehead, sizeof(struct hashdb_head), 1, ret->fp) != 1) { strcpy(ret->error, "Failed reading hash DB header"); fclose(ret->fp); ret->fp = NULL; return (ret); } if (filehead.magic != GENPMKMAGIC) { // Verify header magic strcpy(ret->error, "Header magic doesn't match"); fclose(ret->fp); ret->fp = NULL; return (ret); } if (filehead.ssid[0] == 0) { strcpy(ret->error, "SSID is NULL"); fclose(ret->fp); ret->fp = NULL; return (ret); } // Copy SSID memcpy(ret->ssid, filehead.ssid, sizeof(filehead.ssid)); if (filehead.ssidlen > 32 || filehead.ssidlen == 0) { snprintf(ret->error, sizeof(ret->error), "Advertised SSID length is %u (Max length: 32)", filehead.ssidlen); fclose(ret->fp); ret->fp = NULL; } } else { // Write not supported yet strcpy(ret->error, "Write and other modes not supported yet"); } return (ret); } struct hashdb_rec * read_next_cowpatty_record(struct cowpatty_file * cf) { int rc, wordlength; struct hashdb_rec * ret = NULL; if (cf == NULL || cf->error[0]) { return (NULL); } if (cf->fp == NULL) { strcpy(cf->error, "File pointer is NULL"); return (NULL); } // Allocate memory ret = (struct hashdb_rec *) malloc(sizeof(struct hashdb_rec)); if (ret == NULL) { strcpy(cf->error, "Failed allocating memory for coWPAtty record"); return (NULL); } // Read record size rc = fread(&(ret->rec_size), sizeof(ret->rec_size), 1, cf->fp); // Close and exit if failed if (rc != 1 && feof(cf->fp)) { free(ret); fclose(cf->fp); cf->fp = NULL; return (NULL); } // Get passphrase length ret->word = NULL; wordlength = ret->rec_size - (sizeof(ret->pmk) + sizeof(ret->rec_size)); if (wordlength > 0 && wordlength <= MAX_PASSPHRASE_LENGTH) { ret->word = (char *) calloc(wordlength + 1, sizeof(char)); ALLEGE(ret->word != NULL); // Read passphrase rc += fread(ret->word, wordlength, 1, cf->fp); if (rc == 2) { // And the PMK rc += fread(&ret->pmk, sizeof(ret->pmk), 1, cf->fp); } } // Check if everything went well if (rc != 3 || ret->word == NULL || ret->word[0] == 0) { if (rc == 1) { snprintf(cf->error, sizeof(cf->error), "Error while reading record, failed to read passphrase " "invalid word length: %i", wordlength); } else if (rc == 2) { strcpy(cf->error, "Error while reading record, failed reading PMK"); } else { strcpy(cf->error, "NULL or empty passphrase"); } // Cleanup and close file fclose(cf->fp); free(ret->word); free(ret); ret = NULL; cf->fp = NULL; } return (ret); }aircrack-ng-1.6/lib/crypto/000077500000000000000000000000001361312141100156205ustar00rootroot00000000000000aircrack-ng-1.6/lib/crypto/crypto.c000066400000000000000000001160501361312141100173070ustar00rootroot00000000000000/* * MD5, SHA-1, RC4 and AES implementations * * Copyright (C) 2001-2004 Christophe Devine * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include "aircrack-ng/defs.h" #include "aircrack-ng/crypto/crypto.h" #include "aircrack-ng/crypto/crctable.h" #include "aircrack-ng/aircrack-ng.h" #include "aircrack-ng/support/common.h" #define UBTOUL(b) ((unsigned long) (b)) // libgcrypt thread callback definition for libgcrypt < 1.6.0 #ifdef USE_GCRYPT #if GCRYPT_VERSION_NUMBER < 0x010600 GCRY_THREAD_OPTION_PTHREAD_IMPL; #endif #endif API_EXPORT void ac_crypto_init(void) { #ifdef USE_GCRYPT // Register callback functions to ensure proper locking in the sensitive parts // of libgcrypt < 1.6.0 #if GCRYPT_VERSION_NUMBER < 0x010600 gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); #endif // Disable secure memory. gcry_control(GCRYCTL_DISABLE_SECMEM, 0); // Tell Libgcrypt that initialization has completed. gcry_control(GCRYCTL_INITIALIZATION_FINISHED, 0); #endif } /* RC4 encryption/ WEP decryption check */ /* SSL decryption */ inline int encrypt_wep(unsigned char * data, int len, unsigned char * key, int keylen) { RC4_KEY S; RC4_set_key(&S, keylen, key); RC4(&S, (size_t) len, data, data); return (0); } inline int decrypt_wep(unsigned char * data, int len, unsigned char * key, int keylen) { encrypt_wep(data, len, key, keylen); return (check_crc_buf(data, len - 4)); } /* derive the PMK from the passphrase and the essid */ void calc_pmk(char * key, char * essid_pre, unsigned char pmk[40]) { REQUIRE(key != NULL); REQUIRE(essid_pre != NULL); int i, j, slen; unsigned char buffer[65]; char essid[33 + 4]; SHA_CTX ctx_ipad; SHA_CTX ctx_opad; SHA_CTX sha1_ctx; size_t essid_pre_len; if (essid_pre[0] == 0 || (essid_pre_len = strlen(essid_pre)) > 32) { return; } memset(essid, 0, sizeof(essid)); memcpy(essid, essid_pre, essid_pre_len); slen = (int) essid_pre_len + 4; /* setup the inner and outer contexts */ memset(buffer, 0, sizeof(buffer)); strncpy((char *) buffer, key, sizeof(buffer) - 1); for (i = 0; i < 64; i++) buffer[i] ^= 0x36; SHA1_Init(&ctx_ipad); SHA1_Update(&ctx_ipad, buffer, 64); for (i = 0; i < 64; i++) buffer[i] ^= 0x6A; SHA1_Init(&ctx_opad); SHA1_Update(&ctx_opad, buffer, 64); /* iterate HMAC-SHA1 over itself 8192 times */ essid[slen - 1] = '\1'; HMAC(EVP_sha1(), (unsigned char *) key, (int) strlen(key), (unsigned char *) essid, (size_t) slen, pmk, NULL); memcpy(buffer, pmk, 20); //-V512 for (i = 1; i < 4096; i++) { memcpy(&sha1_ctx, &ctx_ipad, sizeof(sha1_ctx)); SHA1_Update(&sha1_ctx, buffer, 20); SHA1_Final(buffer, &sha1_ctx); memcpy(&sha1_ctx, &ctx_opad, sizeof(sha1_ctx)); SHA1_Update(&sha1_ctx, buffer, 20); SHA1_Final(buffer, &sha1_ctx); for (j = 0; j < 20; j++) pmk[j] ^= buffer[j]; } essid[slen - 1] = '\2'; HMAC(EVP_sha1(), (unsigned char *) key, (int) strlen(key), (unsigned char *) essid, (size_t) slen, pmk + 20, NULL); memcpy(buffer, pmk + 20, 20); for (i = 1; i < 4096; i++) { memcpy(&sha1_ctx, &ctx_ipad, sizeof(sha1_ctx)); SHA1_Update(&sha1_ctx, buffer, 20); SHA1_Final(buffer, &sha1_ctx); memcpy(&sha1_ctx, &ctx_opad, sizeof(sha1_ctx)); SHA1_Update(&sha1_ctx, buffer, 20); SHA1_Final(buffer, &sha1_ctx); for (j = 0; j < 20; j++) pmk[j + 20] ^= buffer[j]; } } void calc_mic(struct AP_info * ap, unsigned char pmk[32], unsigned char ptk[80], unsigned char mic[20]) { REQUIRE(ap != NULL); int i; unsigned char pke[100]; #if defined(USE_GCRYPT) || OPENSSL_VERSION_NUMBER < 0x10100000L \ || defined(LIBRESSL_VERSION_NUMBER) #define HMAC_USE_NO_PTR #endif #ifdef HMAC_USE_NO_PTR HMAC_CTX ctx = {0}; #else HMAC_CTX * ctx; #endif memcpy(pke, "Pairwise key expansion", 23); if (memcmp(ap->wpa.stmac, ap->bssid, 6) < 0) { memcpy(pke + 23, ap->wpa.stmac, 6); memcpy(pke + 29, ap->bssid, 6); } else { memcpy(pke + 23, ap->bssid, 6); memcpy(pke + 29, ap->wpa.stmac, 6); } if (memcmp(ap->wpa.snonce, ap->wpa.anonce, 32) < 0) { memcpy(pke + 35, ap->wpa.snonce, 32); memcpy(pke + 67, ap->wpa.anonce, 32); } else { memcpy(pke + 35, ap->wpa.anonce, 32); memcpy(pke + 67, ap->wpa.snonce, 32); } #ifdef HMAC_USE_NO_PTR HMAC_CTX_init(&ctx); HMAC_Init_ex(&ctx, pmk, 32, EVP_sha1(), NULL); for (i = 0; i < 4; i++) { pke[99] = (uint8_t) i; HMAC_Init_ex(&ctx, 0, 0, 0, 0); HMAC_Update(&ctx, pke, 100); HMAC_Final(&ctx, ptk + i * 20, NULL); } HMAC_CTX_cleanup(&ctx); #else ctx = HMAC_CTX_new(); HMAC_Init_ex(ctx, pmk, 32, EVP_sha1(), NULL); for (i = 0; i < 4; i++) { pke[99] = i; HMAC_Init_ex(ctx, 0, 0, 0, 0); HMAC_Update(ctx, pke, 100); HMAC_Final(ctx, ptk + i * 20, NULL); } HMAC_CTX_free(ctx); #endif #undef HMAC_USE_NO_PTR if (ap->wpa.keyver == 1) { HMAC(EVP_md5(), ptk, 16, ap->wpa.eapol, ap->wpa.eapol_size, mic, NULL); } else { HMAC(EVP_sha1(), ptk, 16, ap->wpa.eapol, ap->wpa.eapol_size, mic, NULL); } } static inline unsigned long calc_crc(const unsigned char * buf, int len) { REQUIRE(buf != NULL); unsigned long crc = 0xFFFFFFFF; for (; len > 0; len--, buf++) crc = crc_tbl[(crc ^ *buf) & 0xFF] ^ (crc >> 8); return (~crc); } // without inversion, must be used for bit flipping attacks static inline unsigned long calc_crc_plain(unsigned char * buf, int len) { REQUIRE(buf != NULL); unsigned long crc = 0x00000000; for (; len > 0; len--, buf++) crc = crc_tbl[(crc ^ *buf) & 0xFF] ^ (crc >> 8); return (crc); } /* CRC checksum verification routine */ int check_crc_buf(const unsigned char * buf, int len) { REQUIRE(buf != NULL); unsigned long crc; crc = calc_crc(buf, len); buf += len; return (((crc) &0xFF) == buf[0] && ((crc >> 8) & 0xFF) == buf[1] && ((crc >> 16) & 0xFF) == buf[2] && ((crc >> 24) & 0xFF) == buf[3]); } /* Add CRC32 */ int add_crc32(unsigned char * data, int length) { REQUIRE(data != NULL); unsigned long crc; crc = calc_crc(data, length); data[length] = (uint8_t)((crc) &0xFF); data[length + 1] = (uint8_t)((crc >> 8) & 0xFF); data[length + 2] = (uint8_t)((crc >> 16) & 0xFF); data[length + 3] = (uint8_t)((crc >> 24) & 0xFF); return (0); } int add_crc32_plain(unsigned char * data, int length) { REQUIRE(data != NULL); unsigned long crc; crc = calc_crc_plain(data, length); data[length] = (uint8_t)((crc) &0xFF); data[length + 1] = (uint8_t)((crc >> 8) & 0xFF); data[length + 2] = (uint8_t)((crc >> 16) & 0xFF); data[length + 3] = (uint8_t)((crc >> 24) & 0xFF); return (0); } int calc_crc_buf(const unsigned char * buf, int len) { REQUIRE(buf != NULL); return (int) (calc_crc(buf, len)); } static void * get_da(unsigned char * wh) { REQUIRE(wh != NULL); if (wh[1] & IEEE80211_FC1_DIR_FROMDS) return (wh + 4); else return (wh + 4 + 6 * 2); } static void * get_sa(unsigned char * wh) { REQUIRE(wh != NULL); if (wh[1] & IEEE80211_FC1_DIR_FROMDS) return (wh + 4 + 6 * 2); else return (wh + 4 + 6); } int is_ipv6(void * wh) { REQUIRE(wh != NULL); if (memcmp((char *) wh + 4, "\x33\x33", 2) == 0 || memcmp((char *) wh + 16, "\x33\x33", 2) == 0) return (1); return (0); } int is_dhcp_discover(void * wh, size_t len) { REQUIRE(wh != NULL); if ((memcmp((char *) wh + 4, BROADCAST, 6) == 0 || memcmp((char *) wh + 16, BROADCAST, 6) == 0) && (len >= 360 - 24 - 4 - 4 && len <= 380 - 24 - 4 - 4)) return (1); return (0); } static inline int is_arp(void * wh, size_t len) { UNUSED_PARAM(wh); const size_t arpsize = 8 + 8 + 10 * 2; /* remove non BROADCAST frames? could be anything, but * chances are good that we got an arp response tho. */ if (len == arpsize || len == 54) return (1); return (0); } static inline int is_wlccp(void * wh, size_t len) { UNUSED_PARAM(wh); const size_t wlccpsize = 58; if (len == wlccpsize) return (1); return (0); } int is_qos_arp_tkip(void * wh, int len) { REQUIRE(wh != NULL); unsigned char * packet = (unsigned char *) wh; const int qosarpsize = (24 + 2) + 8 + (8 + (8 + 10 * 2)) + 8 + 4; // 82 in total if ((packet[1] & 3) == 1) // to ds { if (len == qosarpsize) // always wireless return (1); } if ((packet[1] & 3) == 2) // from ds { if (len == qosarpsize || len == qosarpsize + 18) // wireless or padded wired return (1); } return (0); } static int is_spantree(void * wh) { REQUIRE(wh != NULL); if (memcmp((char *) wh + 4, SPANTREE, 6) == 0 || memcmp((char *) wh + 16, SPANTREE, 6) == 0) return (1); return (0); } static int is_cdp_vtp(void * wh) { REQUIRE(wh != NULL); if (memcmp((char *) wh + 4, CDP_VTP, 6) == 0 || memcmp((char *) wh + 16, CDP_VTP, 6) == 0) return (1); return (0); } /* weight is used for guesswork in PTW. Can be null if known_clear is not for * PTW, but just for getting known clear-text. */ int known_clear( void * clear, int * clen, int * weight, unsigned char * wh, size_t len) { REQUIRE(clear != NULL); REQUIRE(clen != NULL); REQUIRE(wh != NULL); unsigned char * ptr = clear; int num; if (is_arp(wh, len)) /*arp*/ { len = sizeof(S_LLC_SNAP_ARP) - 1; memcpy(ptr, S_LLC_SNAP_ARP, len); ptr += len; /* arp hdr */ len = 6; memcpy(ptr, "\x00\x01\x08\x00\x06\x04", len); ptr += len; /* type of arp */ len = 2; if (memcmp(get_da(wh), "\xff\xff\xff\xff\xff\xff", 6) == 0) memcpy(ptr, "\x00\x01", len); else memcpy(ptr, "\x00\x02", len); ptr += len; /* src mac */ len = 6; memcpy(ptr, get_sa(wh), len); ptr += len; len = ptr - ((unsigned char *) clear); *clen = (int) len; if (weight) weight[0] = 256; return (1); } else if (is_wlccp(wh, len)) /*wlccp*/ { len = sizeof(S_LLC_SNAP_WLCCP) - 1; memcpy(ptr, S_LLC_SNAP_WLCCP, len); ptr += len; /* wlccp hdr */ len = 4; memcpy(ptr, "\x00\x32\x40\x01", len); ptr += len; /* dst mac */ len = 6; memcpy(ptr, get_da(wh), len); ptr += len; len = ptr - ((unsigned char *) clear); *clen = (int) len; if (weight) weight[0] = 256; return (1); } else if (is_spantree(wh)) /*spantree*/ { len = sizeof(S_LLC_SNAP_SPANTREE) - 1; memcpy(ptr, S_LLC_SNAP_SPANTREE, len); ptr += len; len = ptr - ((unsigned char *) clear); *clen = (int) len; if (weight) weight[0] = 256; return (1); } else if (is_cdp_vtp(wh)) /*spantree*/ { len = sizeof(S_LLC_SNAP_CDP) - 1; memcpy(ptr, S_LLC_SNAP_CDP, len); ptr += len; len = ptr - ((unsigned char *) clear); *clen = (int) len; if (weight) weight[0] = 256; return (1); } else /* IP */ { unsigned short iplen = htons((uint16_t)(len - 8)); len = sizeof(S_LLC_SNAP_IP) - 1; memcpy(ptr, S_LLC_SNAP_IP, len); ptr += len; // version=4; header_length=20; services=0 len = 2; memcpy(ptr, "\x45\x00", len); ptr += len; // ip total length memcpy(ptr, &iplen, len); ptr += len; /* no guesswork */ if (!weight) { *clen = (int) (ptr - ((unsigned char *) clear)); return (1); } /* setting IP ID 0 is ok, as we * bruteforce it later */ // ID=0 len = 2; memcpy(ptr, "\x00\x00", len); ptr += len; // ip flags=don't fragment len = 2; memcpy(ptr, "\x40\x00", len); ptr += len; len = ptr - ((unsigned char *) clear); *clen = (int) len; memmove((char *) clear + 32, clear, len); memcpy((char *) clear + 32 + 14, "\x00\x00", 2); // ip flags=none num = 2; ALLEGE(weight); weight[0] = 220; weight[1] = 36; return (num); } } /* derive the pairwise transcient keys from a bunch of stuff */ int calc_ptk(struct WPA_ST_info * wpa, unsigned char pmk[32]) { REQUIRE(wpa != NULL); int i; unsigned char pke[100]; unsigned char mic[20]; memcpy(pke, "Pairwise key expansion", 23); if (memcmp(wpa->stmac, wpa->bssid, 6) < 0) { memcpy(pke + 23, wpa->stmac, 6); memcpy(pke + 29, wpa->bssid, 6); } else { memcpy(pke + 23, wpa->bssid, 6); memcpy(pke + 29, wpa->stmac, 6); } if (memcmp(wpa->snonce, wpa->anonce, 32) < 0) { memcpy(pke + 35, wpa->snonce, 32); memcpy(pke + 67, wpa->anonce, 32); } else { memcpy(pke + 35, wpa->anonce, 32); memcpy(pke + 67, wpa->snonce, 32); } for (i = 0; i < 4; i++) { pke[99] = (uint8_t) i; HMAC(EVP_sha1(), pmk, 32, pke, 100, wpa->ptk + i * 20, NULL); } /* check the EAPOL frame MIC */ if ((wpa->keyver & 0x07) == 1) HMAC(EVP_md5(), wpa->ptk, 16, wpa->eapol, wpa->eapol_size, mic, NULL); else HMAC(EVP_sha1(), wpa->ptk, 16, wpa->eapol, wpa->eapol_size, mic, NULL); return (memcmp(mic, wpa->keymic, 16) == 0); //-V512 } static int init_michael(struct Michael * mic, const unsigned char key[8]) { REQUIRE(mic != NULL); mic->key0 = UBTOUL(key[0]) << 0UL | UBTOUL(key[1]) << 8UL | UBTOUL(key[2]) << 16UL | UBTOUL(key[3] << 24UL); mic->key1 = UBTOUL(key[4]) << 0UL | UBTOUL(key[5]) << 8UL | UBTOUL(key[6]) << 16UL | UBTOUL(key[7] << 24UL); // and reset the message mic->left = mic->key0; mic->right = mic->key1; mic->nBytesInM = 0UL; mic->message = 0UL; return (0); } static int michael_append_byte(struct Michael * mic, unsigned char byte) { REQUIRE(mic != NULL); mic->message |= (UBTOUL(byte) << (8UL * mic->nBytesInM)); mic->nBytesInM++; // Process the word if it is full. if (mic->nBytesInM >= 4UL) { mic->left ^= mic->message; mic->right ^= ROL32(mic->left, 17); mic->left += mic->right; mic->right ^= ((mic->left & 0xff00ff00) >> 8UL) | ((mic->left & 0x00ff00ff) << 8UL); mic->left += mic->right; mic->right ^= ROL32(mic->left, 3); mic->left += mic->right; mic->right ^= ROR32(mic->left, 2); mic->left += mic->right; // Clear the buffer mic->message = 0UL; mic->nBytesInM = 0UL; } return (0); } static int michael_remove_byte(struct Michael * mic, const unsigned char bytes[4]) { REQUIRE(mic != NULL); if (mic->nBytesInM == 0) { // Clear the buffer mic->message = UBTOUL(bytes[0]) << 0UL | UBTOUL(bytes[1]) << 8UL | UBTOUL(bytes[2]) << 16UL | UBTOUL(bytes[3]) << 24UL; mic->nBytesInM = 4; mic->left -= mic->right; mic->right ^= ROR32(mic->left, 2); mic->left -= mic->right; mic->right ^= ROL32(mic->left, 3); mic->left -= mic->right; mic->right ^= ((mic->left & 0xff00ff00) >> 8UL) | ((mic->left & 0x00ff00ff) << 8UL); mic->left -= mic->right; mic->right ^= ROL32(mic->left, 17); mic->left ^= mic->message; } mic->nBytesInM--; mic->message &= ~(0xFFUL << (8UL * mic->nBytesInM)); return (0); } static int michael_append(struct Michael * mic, unsigned char * bytes, int length) { while (length > 0) { michael_append_byte(mic, *bytes++); length--; } return (0); } static int michael_remove(struct Michael * mic, unsigned char * bytes, int length) { while (length >= 4) { michael_remove_byte(mic, (bytes + length - 4)); length--; } return (0); } static int michael_finalize(struct Michael * mic) { REQUIRE(mic != NULL); // Append the minimum padding michael_append_byte(mic, 0x5a); michael_append_byte(mic, 0); michael_append_byte(mic, 0); michael_append_byte(mic, 0); michael_append_byte(mic, 0); // and then zeroes until the length is a multiple of 4 while (mic->nBytesInM != 0) { michael_append_byte(mic, 0); } // The appendByte function has already computed the result. mic->mic[0] = (uint8_t)((mic->left >> 0) & 0xff); mic->mic[1] = (uint8_t)((mic->left >> 8) & 0xff); mic->mic[2] = (uint8_t)((mic->left >> 16) & 0xff); mic->mic[3] = (uint8_t)((mic->left >> 24) & 0xff); mic->mic[4] = (uint8_t)((mic->right >> 0) & 0xff); mic->mic[5] = (uint8_t)((mic->right >> 8) & 0xff); mic->mic[6] = (uint8_t)((mic->right >> 16) & 0xff); mic->mic[7] = (uint8_t)((mic->right >> 24) & 0xff); return (0); } static int michael_finalize_zero(struct Michael * mic) { REQUIRE(mic != NULL); // Append the minimum padding michael_append_byte(mic, 0); michael_append_byte(mic, 0); michael_append_byte(mic, 0); michael_append_byte(mic, 0); michael_append_byte(mic, 0); // and then zeroes until the length is a multiple of 4 while (mic->nBytesInM != 0) { michael_append_byte(mic, 0); } // The appendByte function has already computed the result. mic->mic[0] = (uint8_t)((mic->left >> 0) & 0xff); mic->mic[1] = (uint8_t)((mic->left >> 8) & 0xff); mic->mic[2] = (uint8_t)((mic->left >> 16) & 0xff); mic->mic[3] = (uint8_t)((mic->left >> 24) & 0xff); mic->mic[4] = (uint8_t)((mic->right >> 0) & 0xff); mic->mic[5] = (uint8_t)((mic->right >> 8) & 0xff); mic->mic[6] = (uint8_t)((mic->right >> 16) & 0xff); mic->mic[7] = (uint8_t)((mic->right >> 24) & 0xff); return (0); } int michael_test(unsigned char key[8], unsigned char * message, int length, unsigned char out[8]) { int i = 0; struct Michael mic0; struct Michael mic1; struct Michael mic2; struct Michael mic; init_michael(&mic0, (unsigned char *) "\x00\x00\x00\x00\x00\x00\x00\x00"); init_michael(&mic1, (unsigned char *) "\x00\x00\x00\x00\x00\x00\x00\x00"); init_michael(&mic2, (unsigned char *) "\x00\x00\x00\x00\x00\x00\x00\x00"); michael_append_byte(&mic0, 0x02); michael_append_byte(&mic1, 0x01); michael_append_byte(&mic2, 0x03); michael_finalize(&mic0); michael_finalize_zero(&mic1); michael_finalize(&mic2); printf("Blub 2:"); for (i = 0; i < 8; i++) { printf("%02X ", mic0.mic[i]); } printf("\n"); printf("Blub 1:"); for (i = 0; i < 8; i++) { printf("%02X ", mic1.mic[i]); } printf("\n"); printf("Blub 3:"); for (i = 0; i < 8; i++) { printf("%02X ", mic2.mic[i]); } printf("\n"); init_michael(&mic, key); michael_append(&mic, message, length); michael_finalize(&mic); return (memcmp(mic.mic, out, 8) == 0); } int calc_tkip_mic_key(unsigned char * packet, int length, unsigned char key[8]) { REQUIRE(packet != NULL); int z, is_qos = 0; unsigned char smac[6], dmac[6], bssid[6]; unsigned char prio[4]; unsigned char message[4096]; unsigned char * ptr; struct Michael mic; memset(message, 0, 4096); z = ((packet[1] & 3) != 3) ? 24 : 30; if (length < z) return (0); /* Check if 802.11e (QoS) */ if ((packet[0] & 0x80) == 0x80) { z += 2; is_qos = 1; } memset(prio, 0, 4); if (is_qos) { prio[0] = (uint8_t)(packet[z - 2] & 0x0f); } switch (packet[1] & 3) { case 0: memcpy(bssid, packet + 16, 6); memcpy(dmac, packet + 4, 6); memcpy(smac, packet + 10, 6); break; case 1: memcpy(bssid, packet + 4, 6); memcpy(dmac, packet + 16, 6); memcpy(smac, packet + 10, 6); break; case 2: memcpy(bssid, packet + 10, 6); memcpy(dmac, packet + 4, 6); memcpy(smac, packet + 16, 6); break; default: memcpy(bssid, packet + 10, 6); memcpy(dmac, packet + 16, 6); memcpy(smac, packet + 24, 6); break; } ptr = message; memcpy(ptr, dmac, 6); ptr += 6; memcpy(ptr, smac, 6); ptr += 6; memcpy(ptr, prio, 4); ptr += 4; memcpy(ptr, packet + z, length - z - 8UL); ptr += length - z - 8; memcpy(ptr, "\x5a", 1); ptr += 1; memcpy(ptr, ZERO, 4); ptr += 4; if ((ptr - message) % 4 > 0) { memcpy(ptr, ZERO, 4 - ((ptr - message) % 4)); ptr += 4 - ((ptr - message) % 4); } init_michael(&mic, packet + length - 8); michael_remove(&mic, message, (int) (ptr - message)); mic.mic[0] = (uint8_t)((mic.left >> 0) & 0xFF); mic.mic[1] = (uint8_t)((mic.left >> 8) & 0xFF); mic.mic[2] = (uint8_t)((mic.left >> 16) & 0xFF); mic.mic[3] = (uint8_t)((mic.left >> 24) & 0xFF); mic.mic[4] = (uint8_t)((mic.right >> 0) & 0xFF); mic.mic[5] = (uint8_t)((mic.right >> 8) & 0xFF); mic.mic[6] = (uint8_t)((mic.right >> 16) & 0xFF); mic.mic[7] = (uint8_t)((mic.right >> 24) & 0xFF); memcpy(key, mic.mic, 8); return (0); } int calc_tkip_mic(unsigned char * packet, int length, unsigned char ptk[80], unsigned char value[8]) { REQUIRE(packet != NULL); int z, koffset = 0, is_qos = 0; unsigned char smac[6], dmac[6], bssid[6]; unsigned char prio[4]; struct Michael mic; z = ((packet[1] & 3) != 3) ? 24 : 30; if (length < z) return (0); /* Check if 802.11e (QoS) */ if ((packet[0] & 0x80) == 0x80) { z += 2; is_qos = 1; } switch (packet[1] & 3) { case 0: memcpy(bssid, packet + 16, 6); memcpy(dmac, packet + 4, 6); memcpy(smac, packet + 10, 6); break; case 1: memcpy(bssid, packet + 4, 6); memcpy(dmac, packet + 16, 6); memcpy(smac, packet + 10, 6); koffset = 48 + 8; break; case 2: memcpy(bssid, packet + 10, 6); memcpy(dmac, packet + 4, 6); memcpy(smac, packet + 16, 6); koffset = 48; break; default: memcpy(bssid, packet + 10, 6); memcpy(dmac, packet + 16, 6); memcpy(smac, packet + 24, 6); break; } if (koffset != 48 && koffset != 48 + 8) return (1); init_michael(&mic, ptk + koffset); michael_append(&mic, dmac, 6); michael_append(&mic, smac, 6); memset(prio, 0, 4); if (is_qos) { prio[0] = (uint8_t)(packet[z - 2] & 0x0f); } michael_append(&mic, prio, 4); michael_append(&mic, packet + z, length - z); michael_finalize(&mic); memcpy(value, mic.mic, 8); return (0); } static const unsigned short TkipSbox[2][256] = {{0xC6A5, 0xF884, 0xEE99, 0xF68D, 0xFF0D, 0xD6BD, 0xDEB1, 0x9154, 0x6050, 0x0203, 0xCEA9, 0x567D, 0xE719, 0xB562, 0x4DE6, 0xEC9A, 0x8F45, 0x1F9D, 0x8940, 0xFA87, 0xEF15, 0xB2EB, 0x8EC9, 0xFB0B, 0x41EC, 0xB367, 0x5FFD, 0x45EA, 0x23BF, 0x53F7, 0xE496, 0x9B5B, 0x75C2, 0xE11C, 0x3DAE, 0x4C6A, 0x6C5A, 0x7E41, 0xF502, 0x834F, 0x685C, 0x51F4, 0xD134, 0xF908, 0xE293, 0xAB73, 0x6253, 0x2A3F, 0x080C, 0x9552, 0x4665, 0x9D5E, 0x3028, 0x37A1, 0x0A0F, 0x2FB5, 0x0E09, 0x2436, 0x1B9B, 0xDF3D, 0xCD26, 0x4E69, 0x7FCD, 0xEA9F, 0x121B, 0x1D9E, 0x5874, 0x342E, 0x362D, 0xDCB2, 0xB4EE, 0x5BFB, 0xA4F6, 0x764D, 0xB761, 0x7DCE, 0x527B, 0xDD3E, 0x5E71, 0x1397, 0xA6F5, 0xB968, 0x0000, 0xC12C, 0x4060, 0xE31F, 0x79C8, 0xB6ED, 0xD4BE, 0x8D46, 0x67D9, 0x724B, 0x94DE, 0x98D4, 0xB0E8, 0x854A, 0xBB6B, 0xC52A, 0x4FE5, 0xED16, 0x86C5, 0x9AD7, 0x6655, 0x1194, 0x8ACF, 0xE910, 0x0406, 0xFE81, 0xA0F0, 0x7844, 0x25BA, 0x4BE3, 0xA2F3, 0x5DFE, 0x80C0, 0x058A, 0x3FAD, 0x21BC, 0x7048, 0xF104, 0x63DF, 0x77C1, 0xAF75, 0x4263, 0x2030, 0xE51A, 0xFD0E, 0xBF6D, 0x814C, 0x1814, 0x2635, 0xC32F, 0xBEE1, 0x35A2, 0x88CC, 0x2E39, 0x9357, 0x55F2, 0xFC82, 0x7A47, 0xC8AC, 0xBAE7, 0x322B, 0xE695, 0xC0A0, 0x1998, 0x9ED1, 0xA37F, 0x4466, 0x547E, 0x3BAB, 0x0B83, 0x8CCA, 0xC729, 0x6BD3, 0x283C, 0xA779, 0xBCE2, 0x161D, 0xAD76, 0xDB3B, 0x6456, 0x744E, 0x141E, 0x92DB, 0x0C0A, 0x486C, 0xB8E4, 0x9F5D, 0xBD6E, 0x43EF, 0xC4A6, 0x39A8, 0x31A4, 0xD337, 0xF28B, 0xD532, 0x8B43, 0x6E59, 0xDAB7, 0x018C, 0xB164, 0x9CD2, 0x49E0, 0xD8B4, 0xACFA, 0xF307, 0xCF25, 0xCAAF, 0xF48E, 0x47E9, 0x1018, 0x6FD5, 0xF088, 0x4A6F, 0x5C72, 0x3824, 0x57F1, 0x73C7, 0x9751, 0xCB23, 0xA17C, 0xE89C, 0x3E21, 0x96DD, 0x61DC, 0x0D86, 0x0F85, 0xE090, 0x7C42, 0x71C4, 0xCCAA, 0x90D8, 0x0605, 0xF701, 0x1C12, 0xC2A3, 0x6A5F, 0xAEF9, 0x69D0, 0x1791, 0x9958, 0x3A27, 0x27B9, 0xD938, 0xEB13, 0x2BB3, 0x2233, 0xD2BB, 0xA970, 0x0789, 0x33A7, 0x2DB6, 0x3C22, 0x1592, 0xC920, 0x8749, 0xAAFF, 0x5078, 0xA57A, 0x038F, 0x59F8, 0x0980, 0x1A17, 0x65DA, 0xD731, 0x84C6, 0xD0B8, 0x82C3, 0x29B0, 0x5A77, 0x1E11, 0x7BCB, 0xA8FC, 0x6DD6, 0x2C3A}, {0xA5C6, 0x84F8, 0x99EE, 0x8DF6, 0x0DFF, 0xBDD6, 0xB1DE, 0x5491, 0x5060, 0x0302, 0xA9CE, 0x7D56, 0x19E7, 0x62B5, 0xE64D, 0x9AEC, 0x458F, 0x9D1F, 0x4089, 0x87FA, 0x15EF, 0xEBB2, 0xC98E, 0x0BFB, 0xEC41, 0x67B3, 0xFD5F, 0xEA45, 0xBF23, 0xF753, 0x96E4, 0x5B9B, 0xC275, 0x1CE1, 0xAE3D, 0x6A4C, 0x5A6C, 0x417E, 0x02F5, 0x4F83, 0x5C68, 0xF451, 0x34D1, 0x08F9, 0x93E2, 0x73AB, 0x5362, 0x3F2A, 0x0C08, 0x5295, 0x6546, 0x5E9D, 0x2830, 0xA137, 0x0F0A, 0xB52F, 0x090E, 0x3624, 0x9B1B, 0x3DDF, 0x26CD, 0x694E, 0xCD7F, 0x9FEA, 0x1B12, 0x9E1D, 0x7458, 0x2E34, 0x2D36, 0xB2DC, 0xEEB4, 0xFB5B, 0xF6A4, 0x4D76, 0x61B7, 0xCE7D, 0x7B52, 0x3EDD, 0x715E, 0x9713, 0xF5A6, 0x68B9, 0x0000, 0x2CC1, 0x6040, 0x1FE3, 0xC879, 0xEDB6, 0xBED4, 0x468D, 0xD967, 0x4B72, 0xDE94, 0xD498, 0xE8B0, 0x4A85, 0x6BBB, 0x2AC5, 0xE54F, 0x16ED, 0xC586, 0xD79A, 0x5566, 0x9411, 0xCF8A, 0x10E9, 0x0604, 0x81FE, 0xF0A0, 0x4478, 0xBA25, 0xE34B, 0xF3A2, 0xFE5D, 0xC080, 0x8A05, 0xAD3F, 0xBC21, 0x4870, 0x04F1, 0xDF63, 0xC177, 0x75AF, 0x6342, 0x3020, 0x1AE5, 0x0EFD, 0x6DBF, 0x4C81, 0x1418, 0x3526, 0x2FC3, 0xE1BE, 0xA235, 0xCC88, 0x392E, 0x5793, 0xF255, 0x82FC, 0x477A, 0xACC8, 0xE7BA, 0x2B32, 0x95E6, 0xA0C0, 0x9819, 0xD19E, 0x7FA3, 0x6644, 0x7E54, 0xAB3B, 0x830B, 0xCA8C, 0x29C7, 0xD36B, 0x3C28, 0x79A7, 0xE2BC, 0x1D16, 0x76AD, 0x3BDB, 0x5664, 0x4E74, 0x1E14, 0xDB92, 0x0A0C, 0x6C48, 0xE4B8, 0x5D9F, 0x6EBD, 0xEF43, 0xA6C4, 0xA839, 0xA431, 0x37D3, 0x8BF2, 0x32D5, 0x438B, 0x596E, 0xB7DA, 0x8C01, 0x64B1, 0xD29C, 0xE049, 0xB4D8, 0xFAAC, 0x07F3, 0x25CF, 0xAFCA, 0x8EF4, 0xE947, 0x1810, 0xD56F, 0x88F0, 0x6F4A, 0x725C, 0x2438, 0xF157, 0xC773, 0x5197, 0x23CB, 0x7CA1, 0x9CE8, 0x213E, 0xDD96, 0xDC61, 0x860D, 0x850F, 0x90E0, 0x427C, 0xC471, 0xAACC, 0xD890, 0x0506, 0x01F7, 0x121C, 0xA3C2, 0x5F6A, 0xF9AE, 0xD069, 0x9117, 0x5899, 0x273A, 0xB927, 0x38D9, 0x13EB, 0xB32B, 0x3322, 0xBBD2, 0x70A9, 0x8907, 0xA733, 0xB62D, 0x223C, 0x9215, 0x20C9, 0x4987, 0xFFAA, 0x7850, 0x7AA5, 0x8F03, 0xF859, 0x8009, 0x171A, 0xDA65, 0x31D7, 0xC684, 0xB8D0, 0xC382, 0xB029, 0x775A, 0x111E, 0xCB7B, 0xFCA8, 0xD66D, 0x3A2C}}; /* TKIP (RC4 + key mixing) decryption routine */ #define ROTR1(x) ((((x) >> 1) & 0x7FFF) ^ (((x) &1) << 15)) #define LO8(x) ((x) &0x00FF) #define LO16(x) ((x) &0xFFFF) #define HI8(x) (((x) >> 8) & 0x00FF) #define HI16(x) (((x) >> 16) & 0xFFFF) #define MK16(hi, lo) ((lo) ^ (LO8(hi) << 8)) #define TK16(N) MK16(TK1[2 * (N) + 1], TK1[2 * (N)]) #define _S_(x) (TkipSbox[0][LO8(x)] ^ TkipSbox[1][HI8(x)]) int calc_tkip_ppk(unsigned char * h80211, int caplen, unsigned char TK1[16], unsigned char key[16]) { UNUSED_PARAM(caplen); REQUIRE(h80211 != NULL); int i, z; uint32_t IV32; uint16_t IV16; uint16_t PPK[6]; z = ((h80211[1] & 3) != 3) ? 24 : 30; if (GET_SUBTYPE(h80211[0]) == IEEE80211_FC0_SUBTYPE_QOS) { z += 2; } IV16 = (uint16_t) MK16(h80211[z], h80211[z + 2]); IV32 = (h80211[z + 4]) | (h80211[z + 5] << 8) | (h80211[z + 6] << 16) | (h80211[z + 7] << 24); PPK[0] = (uint16_t) LO16(IV32); PPK[1] = (uint16_t) HI16(IV32); PPK[2] = (uint16_t) MK16(h80211[11], h80211[10]); PPK[3] = (uint16_t) MK16(h80211[13], h80211[12]); PPK[4] = (uint16_t) MK16(h80211[15], h80211[14]); for (i = 0; i < 8; i++) { PPK[0] += _S_(PPK[4] ^ TK16((i & 1) + 0)); PPK[1] += _S_(PPK[0] ^ TK16((i & 1) + 2)); PPK[2] += _S_(PPK[1] ^ TK16((i & 1) + 4)); PPK[3] += _S_(PPK[2] ^ TK16((i & 1) + 6)); PPK[4] += _S_(PPK[3] ^ TK16((i & 1) + 0)) + i; } PPK[5] = PPK[4] + IV16; PPK[0] += _S_(PPK[5] ^ TK16(0)); PPK[1] += _S_(PPK[0] ^ TK16(1)); PPK[2] += _S_(PPK[1] ^ TK16(2)); PPK[3] += _S_(PPK[2] ^ TK16(3)); PPK[4] += _S_(PPK[3] ^ TK16(4)); PPK[5] += _S_(PPK[4] ^ TK16(5)); PPK[0] += ROTR1(PPK[5] ^ TK16(6)); PPK[1] += ROTR1(PPK[0] ^ TK16(7)); PPK[2] += ROTR1(PPK[1]); PPK[3] += ROTR1(PPK[2]); PPK[4] += ROTR1(PPK[3]); PPK[5] += ROTR1(PPK[4]); key[0] = (uint8_t) HI8(IV16); key[1] = (uint8_t)((HI8(IV16) | 0x20) & 0x7F); key[2] = (uint8_t) LO8(IV16); key[3] = (uint8_t) LO8((PPK[5] ^ TK16(0)) >> 1); for (i = 0; i < 6; i++) { key[4 + (2 * i)] = (uint8_t) LO8(PPK[i]); key[5 + (2 * i)] = (uint8_t) HI8(PPK[i]); } return (0); } static int calc_tkip_mic_skip_eiv(unsigned char * packet, int length, unsigned char ptk[80], unsigned char value[8]) { REQUIRE(packet != NULL); int z, koffset = 0, is_qos = 0; unsigned char smac[6], dmac[6], bssid[6]; unsigned char prio[4] = {0}; struct Michael mic; z = ((packet[1] & 3) != 3) ? 24 : 30; if (length < z) return (0); /* Check if 802.11e (QoS) */ if ((packet[0] & 0x80) == 0x80) { z += 2; is_qos = 1; } switch (packet[1] & 3) { case 0: memcpy(bssid, packet + 16, 6); memcpy(dmac, packet + 4, 6); memcpy(smac, packet + 10, 6); break; case 1: memcpy(bssid, packet + 4, 6); memcpy(dmac, packet + 16, 6); memcpy(smac, packet + 10, 6); koffset = 48 + 8; break; case 2: memcpy(bssid, packet + 10, 6); memcpy(dmac, packet + 4, 6); memcpy(smac, packet + 16, 6); koffset = 48; break; default: memcpy(bssid, packet + 10, 6); memcpy(dmac, packet + 16, 6); memcpy(smac, packet + 24, 6); break; } if (koffset != 48 && koffset != 48 + 8) return (1); init_michael(&mic, ptk + koffset); michael_append(&mic, dmac, 6); michael_append(&mic, smac, 6); // memset(prio, 0, 4); if (is_qos) { prio[0] = (uint8_t)(packet[z - 2] & 0x0f); } michael_append(&mic, prio, 4); michael_append(&mic, packet + z + 8, length - z - 8); michael_finalize(&mic); memcpy(value, mic.mic, 8); return (0); } void encrypt_tkip(unsigned char * h80211, int caplen, unsigned char ptk[80]) { REQUIRE(h80211 != NULL); unsigned char * TK1 = ptk + 32; unsigned char K[16]; int z; z = ((h80211[1] & 3) != 3) ? 24 : 30; if (GET_SUBTYPE(h80211[0]) == IEEE80211_FC0_SUBTYPE_QOS) { z += 2; } // Update the MIC in the frame... // Had to mod calc_tkip_mic to skip extended IV to avoid memmoves unsigned char micval[8] = {0}; calc_tkip_mic_skip_eiv(h80211, caplen - 12, ptk, micval); unsigned char * mic_in_packet = h80211 + caplen - 12; memcpy(mic_in_packet, micval, 8); // Update the CRC in the frame before encrypting uint32_t crc = (uint32_t) calc_crc(h80211 + z + 8, caplen - z - 8 - 4); unsigned char * buf = h80211 + z + 8; buf += caplen - z - 8 - 4; buf[0] = (uint8_t)((crc) &0xFF); buf[2] = (uint8_t)((crc >> 16) & 0xFF); buf[1] = (uint8_t)((crc >> 8) & 0xFF); buf[3] = (uint8_t)((crc >> 24) & 0xFF); calc_tkip_ppk(h80211, caplen, TK1, K); decrypt_wep(h80211 + z + 8, caplen - z - 8, K, 16); } int decrypt_tkip(unsigned char * h80211, int caplen, unsigned char TK1[16]) { REQUIRE(h80211 != NULL); unsigned char K[16]; int z; z = ((h80211[1] & 3) != 3) ? 24 : 30; if (GET_SUBTYPE(h80211[0]) == IEEE80211_FC0_SUBTYPE_QOS) { z += 2; } calc_tkip_ppk(h80211, caplen, TK1, K); return (decrypt_wep(h80211 + z + 8, caplen - z - 8, K, 16)); } /* CCMP (AES-CTR-MAC) decryption routine */ static inline void XOR(unsigned char * dst, unsigned char * src, int len) { REQUIRE(dst != NULL); REQUIRE(src != NULL); for (int i = 0; i < len; i++) dst[i] ^= src[i]; } // Important documents for the implementation of encrypt_ccmp() and // decrypt_ccmp(): // // * RFC 3610 Counter with CBC-MAC (CCM) // https://www.ietf.org/rfc/rfc3610.txt // // * IEEE 802.11(TM)-2012 // http://standards.ieee.org/about/get/802/802.11.html // // Note: RFC uses the abbreviation MAC (Message Authentication Code, or // value U in the RFC). It is the same as IEEE's MIC (Message // Integrity Code) // encrypt_ccmp() takes an h80211 frame and encrypts it in-place using CCMP. // This results in a frame that is 16 bytes longer than the original, take this // into account when allocating h80211! encrypt() returns the new length (and // thus the offset where the caller needs to write the FCS). // caplen is the combined length of the 802.11 header and data, not the FCS! int encrypt_ccmp(unsigned char * h80211, int caplen, unsigned char TK1[16], unsigned char PN[6]) { REQUIRE(h80211 != NULL); int is_a4, i, z, blocks, is_qos; int data_len, last, offset; unsigned char B0[16], B[16], MIC[16]; unsigned char AAD[32]; AES_KEY aes_ctx; is_a4 = (h80211[1] & 3) == 3; is_qos = (h80211[0] & 0x8C) == 0x88; z = 24 + 6 * is_a4; z += 2 * is_qos; // Insert CCMP header memmove(h80211 + z + 8, h80211 + z, (size_t) caplen - z); h80211[z + 0] = PN[5]; h80211[z + 1] = PN[4]; h80211[z + 2] = 0x00; // Reserved -> 0 h80211[z + 3] = 0x20; // ExtIV=1, KeyID=0 h80211[z + 4] = PN[3]; h80211[z + 5] = PN[2]; h80211[z + 6] = PN[1]; h80211[z + 7] = PN[0]; data_len = caplen - z; // B_0 := B0 B0[0] = 0x59; // Flags B0[1] = 0; // Nonce := CCM Nonce: - Nonce flags memcpy(B0 + 2, h80211 + 10, 6); // - A2 memcpy(B0 + 8, PN, 6); // - PN B0[14] = (uint8_t)((data_len >> 8) & 0xFF); // l(m) B0[15] = (uint8_t)(data_len & 0xFF); // l(m) // B_1 := AAD[ 0..15] // B_2 := AAD[16..31] // AAD[ 0.. 1] = l(a) // AAD[ 2..31] = a memset(AAD, 0, sizeof(AAD)); AAD[2] = (uint8_t)(h80211[0] & 0x8F); // AAD[2..3] = FC AAD[3] = (uint8_t)(h80211[1] & 0xC7); // memcpy(AAD + 4, h80211 + 4, 3 * 6); // AAD[4..21] = [A1,A2,A3] AAD[22] = (uint8_t)(h80211[22] & 0x0F); // AAD[22] = SC if (is_a4) { memcpy(AAD + 24, h80211 + 24, 6); // AAD[24..29] = A4 if (is_qos) { AAD[30] = (uint8_t)(h80211[z - 2] & 0x0F); // AAD[30..31] = QC AAD[31] = 0; // B0[1] = AAD[30]; // B0[ 1] = CCM Nonce flags AAD[1] = 22 + 2 + 6; // AAD[ 0.. 1] = l(a) } else { memset(&AAD[30], 0, 2); // AAD[30..31] = QC B0[1] = 0; // B0[ 1] = CCM Nonce flags AAD[1] = 22 + 6; // AAD[ 0.. 1] = l(a) } } else { if (is_qos) { AAD[24] = (uint8_t)(h80211[z - 2] & 0x0F); // AAD[24..25] = QC AAD[25] = 0; // B0[1] = AAD[24]; // B0[ 1] = CCM Nonce flags AAD[1] = 22 + 2; // AAD[ 0.. 1] = l(a) } else { memset(&AAD[24], 0, 2); // AAD[24..25] = QC B0[1] = 0; // B0[ 1] = CCM Nonce flags AAD[1] = 22; // AAD[ 0.. 1] = l(a) } } AES_set_encrypt_key(TK1, 128, &aes_ctx); AES_encrypt(B0, MIC, &aes_ctx); // X_1 := E( K, B_0 ) XOR(MIC, AAD, 16); // X_2 := E( K, X_1 XOR B_1 ) AES_encrypt(MIC, MIC, &aes_ctx); // XOR(MIC, AAD + 16, 16); // X_3 := E( K, X_2 XOR B_2 ) AES_encrypt(MIC, MIC, &aes_ctx); // // A_i := B0 // B0[ 0] = Flags // B0[ 1..13] = Nonce := CCM Nonce // B0[14..15] = i B0[0] &= 0x07; B0[14] = B0[15] = 0; AES_encrypt(B0, B, &aes_ctx); // S_0 := E( K, A_i ) memcpy(h80211 + z + 8 + data_len, B, 8); //-V512 // ^^^^^^^^^^^^^^^^^^^ ^ // S_0[0..7]/future U S_0 blocks = (data_len + 16 - 1) / 16; last = data_len % 16; offset = z + 8; for (i = 1; i <= blocks; i++) { int n = (last > 0 && i == blocks) ? last : 16; XOR(MIC, h80211 + offset, n); // X_i+3 := E( K, X_i+2 XOR B_i+2 ) AES_encrypt(MIC, MIC, &aes_ctx); // // (X_i+2 ^^^)(^^^ X_i+3) // The message is encrypted by XORing the octets of message m with the // first l(m) octets of the concatenation of S_1, S_2, S_3, ... . B0[14] = (uint8_t)((i >> 8) & 0xFF); // A_i[14..15] = i B0[15] = (uint8_t)(i & 0xFF); // AES_encrypt(B0, B, &aes_ctx); // S_i := E( K, A_i ) XOR(h80211 + offset, B, n); // [B_3, ..., B_n] := m offset += n; } // We need to free the ctx when using gcrypt to avoid memory leaks #ifdef USE_GCRYPT gcry_cipher_close(aes_ctx); #endif // T := X_i+3[ 0.. 7] // U := T XOR S_0[ 0.. 7] XOR(h80211 + offset, MIC, 8); return (z + 8 + data_len + 8); } int decrypt_ccmp(unsigned char * h80211, int caplen, unsigned char TK1[16]) { REQUIRE(h80211 != NULL); int is_a4, i, z, blocks, is_qos; int data_len, last, offset; unsigned char B0[16], B[16], MIC[16]; unsigned char PN[6], AAD[32]; AES_KEY aes_ctx; is_a4 = (h80211[1] & 3) == 3; is_qos = (h80211[0] & 0x8C) == 0x88; z = 24 + 6 * is_a4; z += 2 * is_qos; PN[0] = h80211[z + 7]; PN[1] = h80211[z + 6]; PN[2] = h80211[z + 5]; PN[3] = h80211[z + 4]; PN[4] = h80211[z + 1]; PN[5] = h80211[z + 0]; data_len = caplen - z - 8 - 8; // B_0 := B0 B0[0] = 0x59; // Flags B0[1] = 0; // Nonce := CCM Nonce: - Nonce flags memcpy(B0 + 2, h80211 + 10, 6); // - A2 memcpy(B0 + 8, PN, 6); // - PN B0[14] = (uint8_t)((data_len >> 8) & 0xFF); // l(m) B0[15] = (uint8_t)(data_len & 0xFF); // l(m) // B_1 := AAD[ 0..15] // B_2 := AAD[16..31] // AAD[ 0.. 1] = l(a) // AAD[ 2..31] = a memset(AAD, 0, sizeof(AAD)); AAD[2] = (uint8_t)(h80211[0] & 0x8F); // AAD[2..3] = FC AAD[3] = (uint8_t)(h80211[1] & 0xC7); // memcpy(AAD + 4, h80211 + 4, 3 * 6); // AAD[4..21] = [A1,A2,A3] AAD[22] = (uint8_t)(h80211[22] & 0x0F); // AAD[22] = SC if (is_a4) { memcpy(AAD + 24, h80211 + 24, 6); // AAD[24..29] = A4 if (is_qos) { AAD[30] = (uint8_t)(h80211[z - 2] & 0x0F); // AAD[30..31] = QC AAD[31] = 0; // B0[1] = AAD[30]; // B0[ 1] = CCM Nonce flags AAD[1] = 22 + 2 + 6; // AAD[ 0.. 1] = l(a) } else { memset(&AAD[30], 0, 2); // AAD[30..31] = QC B0[1] = 0; // B0[ 1] = CCM Nonce flags AAD[1] = 22 + 6; // AAD[ 0.. 1] = l(a) } } else { if (is_qos) { AAD[24] = (uint8_t)(h80211[z - 2] & 0x0F); // AAD[24..25] = QC AAD[25] = 0; // B0[1] = AAD[24]; // B0[ 1] = CCM Nonce flags AAD[1] = 22 + 2; // AAD[ 0.. 1] = l(a) } else { memset(&AAD[24], 0, 2); // AAD[24..25] = QC B0[1] = 0; // B0[ 1] = CCM Nonce flags AAD[1] = 22; // AAD[ 0.. 1] = l(a) } } AES_set_encrypt_key(TK1, 128, &aes_ctx); AES_encrypt(B0, MIC, &aes_ctx); // X_1 := E( K, B_0 ) XOR(MIC, AAD, 16); // X_2 := E( K, X_1 XOR B_1 ) AES_encrypt(MIC, MIC, &aes_ctx); // XOR(MIC, AAD + 16, 16); // X_3 := E( K, X_2 XOR B_2 ) AES_encrypt(MIC, MIC, &aes_ctx); // // A_i := B0 // B0[ 0] = Flags // B0[ 1..13] = Nonce := CCM Nonce // B0[14..15] = i B0[0] &= 0x07; B0[14] = B0[15] = 0; AES_encrypt(B0, B, &aes_ctx); // S_0 := E( K, A_i ) XOR(h80211 + caplen - 8, B, 8); // T := U XOR S_0[0..7] // ^^^^^^^^^^^^^^^ ^ // U:=MIC -> T S_0 blocks = (data_len + 16 - 1) / 16; last = data_len % 16; offset = z + 8; for (i = 1; i <= blocks; i++) { int n = (last > 0 && i == blocks) ? last : 16; B0[14] = (uint8_t)((i >> 8) & 0xFF); // A_i[14..15] = i B0[15] = (uint8_t)(i & 0xFF); // AES_encrypt(B0, B, &aes_ctx); // S_i := E( K, A_i ) // The message is encrypted by XORing the octets of message m with the // first l(m) octets of the concatenation of S_1, S_2, S_3, ... . XOR(h80211 + offset, B, n); // [B_3, ..., B_n] := m XOR(MIC, h80211 + offset, n); // X_i+3 := E( K, X_i+2 XOR B_i+2 ) AES_encrypt(MIC, MIC, &aes_ctx); // // (X_i+2 ^^^)(^^^ X_i+3) offset += n; } // We need to free the ctx when using gcrypt to avoid memory leaks #ifdef USE_GCRYPT gcry_cipher_close(aes_ctx); #endif // T := X_n[ 0.. 7] // Note: Decryption is successful if calculated T is the same as the one // that was sent with the message. return (memcmp(h80211 + offset, MIC, 8) == 0); //-V512 } aircrack-ng-1.6/lib/crypto/sha1-git.c000066400000000000000000000310361361312141100174040ustar00rootroot00000000000000#ifndef _SHA1_GIT /* * sha1-git.c * * This code is based on the GIT SHA1 Implementation. * * Copyright (C) 2009 Linus Torvalds * Copyright (C) 2009 Nicolas Pitre * Copyright (C) 2009 Junio C Hamano * Copyright (C) 2009 Brandon Casey * Copyright (C) 2010 Ramsay Jones * Copyright (C) 2012 Carlos Alberto Lopez Perez * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. * */ /* * SHA1 routine optimized to do word accesses rather than byte accesses, * and to avoid unnecessary copies into the context array. * * This was initially based on the Mozilla SHA1 implementation, although * none of the original Mozilla code remains. */ /* this is only to get definitions for memcpy(), ntohl() and htonl() */ //#include "../git-compat-util.h" #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include "aircrack-ng/crypto/sha1-git.h" #if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) /* * Force usage of rol or ror by selecting the one with the smaller constant. * It _can_ generate slightly smaller code (a constant of 1 is special), but * perhaps more importantly it's possibly faster on any uarch that does a * rotate with a loop. */ #define SHA_ASM(op, x, n) \ ({ \ unsigned int __res; \ __asm__(op " %1,%0" : "=r"(__res) : "i"(n), "0"(x)); \ __res; \ }) #define SHA_ROL(x, n) SHA_ASM("rol", x, n) #define SHA_ROR(x, n) SHA_ASM("ror", x, n) #else #define SHA_ROT(X, l, r) (((X) << (l)) | ((X) >> (r))) #define SHA_ROL(X, n) SHA_ROT(X, n, 32 - (n)) #define SHA_ROR(X, n) SHA_ROT(X, 32 - (n), n) #endif /* * If you have 32 registers or more, the compiler can (and should) * try to change the array[] accesses into registers. However, on * machines with less than ~25 registers, that won't really work, * and at least gcc will make an unholy mess of it. * * So to avoid that mess which just slows things down, we force * the stores to memory to actually happen (we might be better off * with a 'W(t)=(val);asm("":"+m" (W(t))' there instead, as * suggested by Artur Skawina - that will also make gcc unable to * try to do the silly "optimize away loads" part because it won't * see what the value will be). * * Ben Herrenschmidt reports that on PPC, the C version comes close * to the optimized asm with this (ie on PPC you don't want that * 'volatile', since there are lots of registers). * * On ARM we get the best code generation by forcing a full memory barrier * between each SHA_ROUND, otherwise gcc happily get wild with spilling and * the stack frame size simply explode and performance goes down the drain. */ #if defined(__i386__) || defined(__x86_64__) #define setW(x, val) (*(volatile unsigned int *) &W(x) = (val)) #elif defined(__GNUC__) && defined(__arm__) #define setW(x, val) \ do \ { \ W(x) = (val); \ __asm__("" ::: "memory"); \ } while (0) #else #define setW(x, val) (W(x) = (val)) #endif /* * Performance might be improved if the CPU architecture is OK with * unaligned 32-bit loads and a fast ntohl() is available. * Otherwise fall back to byte loads and shifts which is portable, * and is faster on architectures with memory alignment issues. */ #if defined(__i386__) || defined(__x86_64__) || defined(_M_IX86) \ || defined(_M_X64) || defined(__ppc__) || defined(__ppc64__) \ || defined(__powerpc__) || defined(__powerpc64__) || defined(__s390__) \ || defined(__s390x__) #define get_be32(p) ntohl(*(unsigned int *) (p)) #define put_be32(p, v) \ do \ { \ *(unsigned int *) (p) = htonl(v); \ } while (0) #else #define get_be32(p) \ ((*((unsigned char *) (p) + 0) << 24) \ | (*((unsigned char *) (p) + 1) << 16) \ | (*((unsigned char *) (p) + 2) << 8) \ | (*((unsigned char *) (p) + 3) << 0)) #define put_be32(p, v) \ do \ { \ unsigned int __v = (v); \ *((unsigned char *) (p) + 0) = __v >> 24; \ *((unsigned char *) (p) + 1) = __v >> 16; \ *((unsigned char *) (p) + 2) = __v >> 8; \ *((unsigned char *) (p) + 3) = __v >> 0; \ } while (0) #endif /* This "rolls" over the 512-bit array */ #define W(x) (array[(x) &15]) /* * Where do we get the source from? The first 16 iterations get it from * the input data, the next mix it from the 512-bit array. */ #define SHA_SRC(t) get_be32(data + t) #define SHA_MIX(t) SHA_ROL(W(t + 13) ^ W(t + 8) ^ W(t + 2) ^ W(t), 1) #define SHA_ROUND(t, input, fn, constant, A, B, C, D, E) \ do \ { \ unsigned int TEMP = input(t); \ setW(t, TEMP); \ E += TEMP + SHA_ROL(A, 5) + (fn) + (constant); \ B = SHA_ROR(B, 2); \ } while (0) #define T_0_15(t, A, B, C, D, E) \ SHA_ROUND( \ t, SHA_SRC, ((((C) ^ (D)) & (B)) ^ (D)), 0x5a827999, A, B, C, D, E) #define T_16_19(t, A, B, C, D, E) \ SHA_ROUND( \ t, SHA_MIX, ((((C) ^ (D)) & (B)) ^ (D)), 0x5a827999, A, B, C, D, E) #define T_20_39(t, A, B, C, D, E) \ SHA_ROUND(t, SHA_MIX, ((B) ^ (C) ^ (D)), 0x6ed9eba1, A, B, C, D, E) #define T_40_59(t, A, B, C, D, E) \ SHA_ROUND(t, \ SHA_MIX, \ (((B) & (C)) + ((D) & ((B) ^ (C)))), \ 0x8f1bbcdc, \ A, \ B, \ C, \ D, \ E) #define T_60_79(t, A, B, C, D, E) \ SHA_ROUND(t, SHA_MIX, ((B) ^ (C) ^ (D)), 0xca62c1d6, A, B, C, D, E) static void blk_SHA1_Block(blk_SHA_CTX * ctx, const unsigned int * data) { unsigned int A, B, C, D, E; unsigned int array[16]; A = ctx->h0; B = ctx->h1; C = ctx->h2; D = ctx->h3; E = ctx->h4; /* Round 1 - iterations 0-16 take their input from 'data' */ T_0_15(0, A, B, C, D, E); T_0_15(1, E, A, B, C, D); T_0_15(2, D, E, A, B, C); T_0_15(3, C, D, E, A, B); T_0_15(4, B, C, D, E, A); T_0_15(5, A, B, C, D, E); T_0_15(6, E, A, B, C, D); T_0_15(7, D, E, A, B, C); T_0_15(8, C, D, E, A, B); T_0_15(9, B, C, D, E, A); T_0_15(10, A, B, C, D, E); T_0_15(11, E, A, B, C, D); T_0_15(12, D, E, A, B, C); T_0_15(13, C, D, E, A, B); T_0_15(14, B, C, D, E, A); T_0_15(15, A, B, C, D, E); /* Round 1 - tail. Input from 512-bit mixing array */ T_16_19(16, E, A, B, C, D); T_16_19(17, D, E, A, B, C); T_16_19(18, C, D, E, A, B); T_16_19(19, B, C, D, E, A); /* Round 2 */ T_20_39(20, A, B, C, D, E); T_20_39(21, E, A, B, C, D); T_20_39(22, D, E, A, B, C); T_20_39(23, C, D, E, A, B); T_20_39(24, B, C, D, E, A); T_20_39(25, A, B, C, D, E); T_20_39(26, E, A, B, C, D); T_20_39(27, D, E, A, B, C); T_20_39(28, C, D, E, A, B); T_20_39(29, B, C, D, E, A); T_20_39(30, A, B, C, D, E); T_20_39(31, E, A, B, C, D); T_20_39(32, D, E, A, B, C); T_20_39(33, C, D, E, A, B); T_20_39(34, B, C, D, E, A); T_20_39(35, A, B, C, D, E); T_20_39(36, E, A, B, C, D); T_20_39(37, D, E, A, B, C); T_20_39(38, C, D, E, A, B); T_20_39(39, B, C, D, E, A); /* Round 3 */ T_40_59(40, A, B, C, D, E); T_40_59(41, E, A, B, C, D); T_40_59(42, D, E, A, B, C); T_40_59(43, C, D, E, A, B); T_40_59(44, B, C, D, E, A); T_40_59(45, A, B, C, D, E); T_40_59(46, E, A, B, C, D); T_40_59(47, D, E, A, B, C); T_40_59(48, C, D, E, A, B); T_40_59(49, B, C, D, E, A); T_40_59(50, A, B, C, D, E); T_40_59(51, E, A, B, C, D); T_40_59(52, D, E, A, B, C); T_40_59(53, C, D, E, A, B); T_40_59(54, B, C, D, E, A); T_40_59(55, A, B, C, D, E); T_40_59(56, E, A, B, C, D); T_40_59(57, D, E, A, B, C); T_40_59(58, C, D, E, A, B); T_40_59(59, B, C, D, E, A); /* Round 4 */ T_60_79(60, A, B, C, D, E); T_60_79(61, E, A, B, C, D); T_60_79(62, D, E, A, B, C); T_60_79(63, C, D, E, A, B); T_60_79(64, B, C, D, E, A); T_60_79(65, A, B, C, D, E); T_60_79(66, E, A, B, C, D); T_60_79(67, D, E, A, B, C); T_60_79(68, C, D, E, A, B); T_60_79(69, B, C, D, E, A); T_60_79(70, A, B, C, D, E); T_60_79(71, E, A, B, C, D); T_60_79(72, D, E, A, B, C); T_60_79(73, C, D, E, A, B); T_60_79(74, B, C, D, E, A); T_60_79(75, A, B, C, D, E); T_60_79(76, E, A, B, C, D); T_60_79(77, D, E, A, B, C); T_60_79(78, C, D, E, A, B); T_60_79(79, B, C, D, E, A); ctx->h0 += A; ctx->h1 += B; ctx->h2 += C; ctx->h3 += D; ctx->h4 += E; } void blk_SHA1_Init(blk_SHA_CTX * ctx) { ctx->size = 0; /* Initialize H with the magic constants (see FIPS180 for constants) */ ctx->h0 = 0x67452301; ctx->h1 = 0xefcdab89; ctx->h2 = 0x98badcfe; ctx->h3 = 0x10325476; ctx->h4 = 0xc3d2e1f0; } void blk_SHA1_Update(blk_SHA_CTX * ctx, const void * data, unsigned long len) { unsigned int lenW = ctx->size & 63; ctx->size += len; /* Read the data into W and process blocks as they get full */ if (lenW) { unsigned int left = 64 - lenW; if (len < left) left = len; memcpy(lenW + (char *) ctx->W, data, left); lenW = (lenW + left) & 63; len -= left; data = ((const char *) data + left); if (lenW) return; blk_SHA1_Block(ctx, ctx->W); } while (len >= 64) { blk_SHA1_Block(ctx, data); data = ((const char *) data + 64); len -= 64; } if (len) memcpy(ctx->W, data, len); } void blk_SHA1_Final(unsigned char hashout[20], blk_SHA_CTX * ctx) { static const unsigned char pad[64] = {0x80}; //-V1009 unsigned int padlen[2]; int i; /* Pad with a binary 1 (ie 0x80), then zeroes, then length */ padlen[0] = htonl((uint32_t)(ctx->size >> 29)); padlen[1] = htonl((uint32_t)(ctx->size << 3)); i = ctx->size & 63; blk_SHA1_Update(ctx, pad, 1 + (63 & (55 - i))); blk_SHA1_Update(ctx, padlen, 8); /* Output hash */ assert(((uintptr_t) hashout % 4UL) == 0); // V1032 catch put_be32(&hashout[0], ctx->h0); put_be32(&hashout[4], ctx->h1); put_be32(&hashout[8], ctx->h2); put_be32(&hashout[12], ctx->h3); put_be32(&hashout[16], ctx->h4); } #define _SHA1_GIT #endif aircrack-ng-1.6/lib/crypto/sha1-sse2.S000066400000000000000000000510031361312141100174510ustar00rootroot00000000000000// Cygwin, Apple, Clang, (C) 2018 Joseph Benden (joe@benden.us) // SHA-1 SSE2 implementation, (C) 2008 Alvaro Salmador (naplam33@msn.com), ported from Simon Marechal's SHA-1 MMX - License: GPLv2 // SHA-1 MMX implementation, (C) 2005 Simon Marechal (simon@banquise.net) - License: Public Domain // This code computes two (with sse now four) SHA-1 digests at the same time. It // doesn't take care of padding (0x80 and size << 3), so make // sure the last input block is properly padded. Both 64-byte // input blocks must be (four bytes) interleaved. // In addition, as a special exception, the copyright holders give // permission to link the code of portions of this program with the // OpenSSL library under certain conditions as described in each // individual source file, and distribute linked combinations // including the two. // You must obey the GNU General Public License in all respects // for all of the code used other than OpenSSL. * If you modify // file(s) with this exception, you may extend this exception to your // version of the file(s), but you are not obligated to do so. * If you // do not wish to do so, delete this exception statement from your // version. * If you delete this exception statement from all source // files in the program, then also delete it here. #if defined(__x86_64__) #if defined(__APPLE__) || defined(__CYGWIN__) #define USE_PIC 1 #else #undef USE_PIC #endif #else #undef USE_PIC #endif #if defined(USE_PIC) #define PRELOAD(x,f) #define MANGLE(x,f) x(%rip) #define INIT_PIC(f) #define END_PIC(f) #else #ifdef __PIC__ #ifdef __x86_64__ #define PRELOAD(x,f) movq x@GOTPCREL(%rip), %rbx; #define MANGLE(x,f) (%rbx) #define INIT_PIC(f) pushq %rbx #define END_PIC(f) popq %rbx #else #if __APPLE__ #define PRELOAD(x,f) leal x-L0## f ##$pb(%ebx), %esi; #define MANGLE(x,f) (%esi) #define INIT_PIC(x) \ push %ebx; \ call L0## x ##$pb; \ L0## x ##$pb:; \ pop %ebx; #define END_PIC(x) pop %ebx #else #undef __i686 /* gcc builtin define gets in our way */ #define PRELOAD(x,f) #define MANGLE(x,f) x ## @GOTOFF(%ebx) #define INIT_PIC(f) \ call __i686.get_pc_thunk.bx ; \ addl $_GLOBAL_OFFSET_TABLE_, %ebx #define END_PIC(f) #endif #endif #else #define PRELOAD(x,f) #define MANGLE(x,f) x #define INIT_PIC(f) #define END_PIC(f) #endif #endif #if defined(__i386__) || defined(__x86_64__) .globl shasse2_init; .globl shasse2_ends; .globl shasse2_data; .globl shasse2_cpuid; .globl _shasse2_init; .globl _shasse2_ends; .globl _shasse2_data; .globl _shasse2_cpuid; .data #ifdef __APPLE__ .align(12) #else .align(16) #endif const_init_a: .long 0x67452301 .long 0x67452301 .long 0x67452301 .long 0x67452301 const_init_b: .long 0xEFCDAB89 .long 0xEFCDAB89 .long 0xEFCDAB89 .long 0xEFCDAB89 const_init_c: .long 0x98BADCFE .long 0x98BADCFE .long 0x98BADCFE .long 0x98BADCFE const_init_d: .long 0x10325476 .long 0x10325476 .long 0x10325476 .long 0x10325476 const_init_e: .long 0xC3D2E1F0 .long 0xC3D2E1F0 .long 0xC3D2E1F0 .long 0xC3D2E1F0 const_stage0: .long 0x5A827999 .long 0x5A827999 .long 0x5A827999 .long 0x5A827999 const_stage1: .long 0x6ED9EBA1 .long 0x6ED9EBA1 .long 0x6ED9EBA1 .long 0x6ED9EBA1 const_stage2: .long 0x8F1BBCDC .long 0x8F1BBCDC .long 0x8F1BBCDC .long 0x8F1BBCDC const_stage3: .long 0xCA62C1D6 .long 0xCA62C1D6 .long 0xCA62C1D6 .long 0xCA62C1D6 const_ff00: .long 0xFF00FF00 .long 0xFF00FF00 .long 0xFF00FF00 .long 0xFF00FF00 const_00ff: .long 0x00FF00FF .long 0x00FF00FF .long 0x00FF00FF .long 0x00FF00FF #define ctxa %xmm0 #define ctxb %xmm1 #define ctxc %xmm2 #define ctxd %xmm3 #define ctxe %xmm4 #define tmp1 %xmm5 #define tmp2 %xmm6 #define tmp3 %xmm7 #define tmp4 ctxa #define tmp5 ctxb #if defined(__x86_64__) && defined(__CYGWIN__) #define edx_rsi %rdx // arg2 #define ecx_rdx %r8 // arg3 #define eax_rdi %rcx // arg1 #elif defined(__x86_64__) #define edx_rsi %rsi // arg2 #define ecx_rdx %rdx // arg3 #define eax_rdi %rdi // arg1 #else #define edx_rsi %edx #define ecx_rdx %ecx #define eax_rdi %eax #endif // movdqa movapd #define F0(x,y,z) \ movdqa x, tmp2; \ movdqa x, tmp1; \ pand y, tmp2; \ pandn z, tmp1; \ por tmp2, tmp1; #define F1(x,y,z) \ movdqa z, tmp1; \ pxor y, tmp1; \ pxor x, tmp1 #define F2(x,y,z) \ movdqa x, tmp1; \ movdqa x, tmp2; \ pand y, tmp1; \ por y, tmp2; \ pand z, tmp2; \ por tmp2, tmp1; #if defined(__x86_64__) && (defined(__CYGWIN__) && !defined(__clang__)) #define subRoundX(a, b, c, d, e, f, k, data) \ f(b,c,d); \ movdqa a, tmp2; \ movdqa a, tmp3; \ paddd tmp1, e; \ pslld $5, tmp2; \ psrld $27, tmp3; \ por tmp3, tmp2; \ paddd tmp2, e; \ movdqa b, tmp2; \ pslld $30, b; \ paddd MANGLE(k,shasse2_data), e; \ psrld $2, tmp2; \ por tmp2, b; \ movdqa (data*16)(edx_rsi), tmp1; \ movdqa tmp1, tmp2; \ pand MANGLE(const_ff00,shasse2_data), tmp1; \ pand MANGLE(const_00ff,shasse2_data), tmp2; \ psrld $8, tmp1; \ pslld $8, tmp2; \ por tmp2, tmp1; \ movdqa tmp1, tmp2; \ psrld $16, tmp1; \ pslld $16, tmp2; \ por tmp2, tmp1; \ movdqa tmp1, (data*16)(ecx_rdx); \ paddd tmp1, e; #else #define subRoundX(a, b, c, d, e, f, k, data) \ f(b,c,d); \ movdqa a, tmp2; \ movdqa a, tmp3; \ paddd tmp1, e; \ pslld $5, tmp2; \ psrld $27, tmp3; \ por tmp3, tmp2; \ paddd tmp2, e; \ movdqa b, tmp2; \ pslld $30, b; \ PRELOAD(k,shasse2_data) \ paddd MANGLE(k,shasse2_data), e; \ psrld $2, tmp2; \ por tmp2, b; \ movdqa (data*16)(edx_rsi), tmp1; \ movdqa tmp1, tmp2; \ PRELOAD(const_ff00,shasse2_data) \ pand MANGLE(const_ff00,shasse2_data), tmp1; \ PRELOAD(const_00ff,shasse2_data) \ pand MANGLE(const_00ff,shasse2_data), tmp2; \ psrld $8, tmp1; \ pslld $8, tmp2; \ por tmp2, tmp1; \ movdqa tmp1, tmp2; \ psrld $16, tmp1; \ pslld $16, tmp2; \ por tmp2, tmp1; \ movdqa tmp1, (data*16)(ecx_rdx); \ paddd tmp1, e; #endif #if defined(__x86_64__) && (defined(__CYGWIN__) && !defined(__clang__)) #define subRoundY(a, b, c, d, e, f, k, data) \ movdqa ((data- 3)*16)(ecx_rdx), tmp1; \ pxor ((data- 8)*16)(ecx_rdx), tmp1; \ pxor ((data-14)*16)(ecx_rdx), tmp1; \ pxor ((data-16)*16)(ecx_rdx), tmp1; \ movdqa tmp1, tmp2; \ pslld $1, tmp1; \ psrld $31, tmp2; \ por tmp2, tmp1; \ movdqa tmp1, (data*16)(ecx_rdx); \ paddd tmp1, e; \ f(b,c,d); \ movdqa a, tmp2; \ movdqa a, tmp3; \ paddd tmp1, e; \ pslld $5, tmp2; \ psrld $27, tmp3; \ por tmp3, tmp2; \ paddd tmp2, e; \ movdqa b, tmp2; \ pslld $30, b; \ paddd MANGLE(k,shasse2_data), e; \ psrld $2, tmp2; \ por tmp2, b; #else #define subRoundY(a, b, c, d, e, f, k, data) \ movdqa ((data- 3)*16)(ecx_rdx), tmp1; \ pxor ((data- 8)*16)(ecx_rdx), tmp1; \ pxor ((data-14)*16)(ecx_rdx), tmp1; \ pxor ((data-16)*16)(ecx_rdx), tmp1; \ movdqa tmp1, tmp2; \ pslld $1, tmp1; \ psrld $31, tmp2; \ por tmp2, tmp1; \ movdqa tmp1, (data*16)(ecx_rdx); \ paddd tmp1, e; \ f(b,c,d); \ movdqa a, tmp2; \ movdqa a, tmp3; \ paddd tmp1, e; \ pslld $5, tmp2; \ psrld $27, tmp3; \ por tmp3, tmp2; \ paddd tmp2, e; \ movdqa b, tmp2; \ pslld $30, b; \ PRELOAD(k,shasse2_data) \ paddd MANGLE(k,shasse2_data), e; \ psrld $2, tmp2; \ por tmp2, b; #endif .text // arg 1 (eax) (64bit: rdi): context (4*20 bytes) shasse2_init: _shasse2_init: INIT_PIC(shasse2_init) PRELOAD(const_init_a,shasse2_init) movdqa MANGLE(const_init_a,shasse2_init), ctxa PRELOAD(const_init_b,shasse2_init) movdqa MANGLE(const_init_b,shasse2_init), ctxb PRELOAD(const_init_c,shasse2_init) movdqa MANGLE(const_init_c,shasse2_init), ctxc PRELOAD(const_init_d,shasse2_init) movdqa MANGLE(const_init_d,shasse2_init), ctxd PRELOAD(const_init_e,shasse2_init) movdqa MANGLE(const_init_e,shasse2_init), ctxe movdqa ctxa, 0(eax_rdi) movdqa ctxb, 16(eax_rdi) movdqa ctxc, 32(eax_rdi) movdqa ctxd, 48(eax_rdi) movdqa ctxe, 64(eax_rdi) END_PIC() ret // arg 1 (eax) (64bit: rdi): context (4*20 bytes) // arg 2 (edx) (64bit: rsi) : digests (4*20 bytes) shasse2_ends: _shasse2_ends: INIT_PIC(shasse2_ends) movdqa 0(eax_rdi), ctxa movdqa 16(eax_rdi), ctxb movdqa 32(eax_rdi), ctxc movdqa 48(eax_rdi), ctxd movdqa 64(eax_rdi), ctxe PRELOAD(const_ff00,shasse2_ends) movdqa MANGLE(const_ff00,shasse2_ends), tmp3 movdqa ctxa, tmp1 movdqa ctxb, tmp2 pand tmp3, ctxa pand tmp3, ctxb PRELOAD(const_00ff,shasse2_ends) movdqa MANGLE(const_00ff,shasse2_ends), tmp3 pand tmp3, tmp1 pand tmp3, tmp2 psrld $8, ctxa psrld $8, ctxb pslld $8, tmp1 pslld $8, tmp2 por tmp1, ctxa por tmp2, ctxb movdqa ctxa, tmp1 movdqa ctxb, tmp2 psrld $16, ctxa psrld $16, ctxb pslld $16, tmp1 pslld $16, tmp2 por tmp1, ctxa por tmp2, ctxb movdqa ctxa, 0(edx_rsi) movdqa ctxb, 16(edx_rsi) PRELOAD(const_ff00,shasse2_ends) movdqa MANGLE(const_ff00,shasse2_ends), tmp5 movdqa ctxc, tmp1 movdqa ctxd, tmp2 movdqa ctxe, tmp3 pand tmp5, ctxc pand tmp5, ctxd pand tmp5, ctxe PRELOAD(const_00ff,shasse2_ends) movdqa MANGLE(const_00ff,shasse2_ends), tmp5 pand tmp5, tmp1 pand tmp5, tmp2 pand tmp5, tmp3 psrld $8, ctxc psrld $8, ctxd psrld $8, ctxe pslld $8, tmp1 pslld $8, tmp2 pslld $8, tmp3 por tmp1, ctxc por tmp2, ctxd por tmp3, ctxe movdqa ctxc, tmp1 movdqa ctxd, tmp2 movdqa ctxe, tmp3 psrld $16, ctxc psrld $16, ctxd psrld $16, ctxe pslld $16, tmp1 pslld $16, tmp2 pslld $16, tmp3 por tmp1, ctxc por tmp2, ctxd por tmp3, ctxe movdqa ctxc, 32(edx_rsi) movdqa ctxd, 48(edx_rsi) movdqa ctxe, 64(edx_rsi) END_PIC() ret // arg 1 (eax) (64bit: rdi): context (4*20 bytes) // arg 2 (edx) (64bit: rsi): input data (4*64 bytes) // arg 3 (ecx) (64bit: rdx): workspace (1280 bytes) shasse2_data: _shasse2_data: INIT_PIC(shasse2_data) movdqa 0(eax_rdi), ctxa movdqa 16(eax_rdi), ctxb movdqa 32(eax_rdi), ctxc movdqa 48(eax_rdi), ctxd movdqa 64(eax_rdi), ctxe round0: prefetchnta (edx_rsi) subRoundX( ctxa, ctxb, ctxc, ctxd, ctxe, F0, const_stage0, 0 ); subRoundX( ctxe, ctxa, ctxb, ctxc, ctxd, F0, const_stage0, 1 ); subRoundX( ctxd, ctxe, ctxa, ctxb, ctxc, F0, const_stage0, 2 ); subRoundX( ctxc, ctxd, ctxe, ctxa, ctxb, F0, const_stage0, 3 ); subRoundX( ctxb, ctxc, ctxd, ctxe, ctxa, F0, const_stage0, 4 ); subRoundX( ctxa, ctxb, ctxc, ctxd, ctxe, F0, const_stage0, 5 ); subRoundX( ctxe, ctxa, ctxb, ctxc, ctxd, F0, const_stage0, 6 ); subRoundX( ctxd, ctxe, ctxa, ctxb, ctxc, F0, const_stage0, 7 ); subRoundX( ctxc, ctxd, ctxe, ctxa, ctxb, F0, const_stage0, 8 ); subRoundX( ctxb, ctxc, ctxd, ctxe, ctxa, F0, const_stage0, 9 ); subRoundX( ctxa, ctxb, ctxc, ctxd, ctxe, F0, const_stage0, 10 ); subRoundX( ctxe, ctxa, ctxb, ctxc, ctxd, F0, const_stage0, 11 ); subRoundX( ctxd, ctxe, ctxa, ctxb, ctxc, F0, const_stage0, 12 ); subRoundX( ctxc, ctxd, ctxe, ctxa, ctxb, F0, const_stage0, 13 ); subRoundX( ctxb, ctxc, ctxd, ctxe, ctxa, F0, const_stage0, 14 ); subRoundX( ctxa, ctxb, ctxc, ctxd, ctxe, F0, const_stage0, 15 ); subRoundY( ctxe, ctxa, ctxb, ctxc, ctxd, F0, const_stage0, 16 ); subRoundY( ctxd, ctxe, ctxa, ctxb, ctxc, F0, const_stage0, 17 ); subRoundY( ctxc, ctxd, ctxe, ctxa, ctxb, F0, const_stage0, 18 ); subRoundY( ctxb, ctxc, ctxd, ctxe, ctxa, F0, const_stage0, 19 ); round1: subRoundY( ctxa, ctxb, ctxc, ctxd, ctxe, F1, const_stage1, 20 ); subRoundY( ctxe, ctxa, ctxb, ctxc, ctxd, F1, const_stage1, 21 ); subRoundY( ctxd, ctxe, ctxa, ctxb, ctxc, F1, const_stage1, 22 ); subRoundY( ctxc, ctxd, ctxe, ctxa, ctxb, F1, const_stage1, 23 ); subRoundY( ctxb, ctxc, ctxd, ctxe, ctxa, F1, const_stage1, 24 ); subRoundY( ctxa, ctxb, ctxc, ctxd, ctxe, F1, const_stage1, 25 ); subRoundY( ctxe, ctxa, ctxb, ctxc, ctxd, F1, const_stage1, 26 ); subRoundY( ctxd, ctxe, ctxa, ctxb, ctxc, F1, const_stage1, 27 ); subRoundY( ctxc, ctxd, ctxe, ctxa, ctxb, F1, const_stage1, 28 ); subRoundY( ctxb, ctxc, ctxd, ctxe, ctxa, F1, const_stage1, 29 ); subRoundY( ctxa, ctxb, ctxc, ctxd, ctxe, F1, const_stage1, 30 ); subRoundY( ctxe, ctxa, ctxb, ctxc, ctxd, F1, const_stage1, 31 ); subRoundY( ctxd, ctxe, ctxa, ctxb, ctxc, F1, const_stage1, 32 ); subRoundY( ctxc, ctxd, ctxe, ctxa, ctxb, F1, const_stage1, 33 ); subRoundY( ctxb, ctxc, ctxd, ctxe, ctxa, F1, const_stage1, 34 ); subRoundY( ctxa, ctxb, ctxc, ctxd, ctxe, F1, const_stage1, 35 ); subRoundY( ctxe, ctxa, ctxb, ctxc, ctxd, F1, const_stage1, 36 ); subRoundY( ctxd, ctxe, ctxa, ctxb, ctxc, F1, const_stage1, 37 ); subRoundY( ctxc, ctxd, ctxe, ctxa, ctxb, F1, const_stage1, 38 ); subRoundY( ctxb, ctxc, ctxd, ctxe, ctxa, F1, const_stage1, 39 ); round2: subRoundY( ctxa, ctxb, ctxc, ctxd, ctxe, F2, const_stage2, 40 ); subRoundY( ctxe, ctxa, ctxb, ctxc, ctxd, F2, const_stage2, 41 ); subRoundY( ctxd, ctxe, ctxa, ctxb, ctxc, F2, const_stage2, 42 ); subRoundY( ctxc, ctxd, ctxe, ctxa, ctxb, F2, const_stage2, 43 ); subRoundY( ctxb, ctxc, ctxd, ctxe, ctxa, F2, const_stage2, 44 ); subRoundY( ctxa, ctxb, ctxc, ctxd, ctxe, F2, const_stage2, 45 ); subRoundY( ctxe, ctxa, ctxb, ctxc, ctxd, F2, const_stage2, 46 ); subRoundY( ctxd, ctxe, ctxa, ctxb, ctxc, F2, const_stage2, 47 ); subRoundY( ctxc, ctxd, ctxe, ctxa, ctxb, F2, const_stage2, 48 ); subRoundY( ctxb, ctxc, ctxd, ctxe, ctxa, F2, const_stage2, 49 ); subRoundY( ctxa, ctxb, ctxc, ctxd, ctxe, F2, const_stage2, 50 ); subRoundY( ctxe, ctxa, ctxb, ctxc, ctxd, F2, const_stage2, 51 ); subRoundY( ctxd, ctxe, ctxa, ctxb, ctxc, F2, const_stage2, 52 ); subRoundY( ctxc, ctxd, ctxe, ctxa, ctxb, F2, const_stage2, 53 ); subRoundY( ctxb, ctxc, ctxd, ctxe, ctxa, F2, const_stage2, 54 ); subRoundY( ctxa, ctxb, ctxc, ctxd, ctxe, F2, const_stage2, 55 ); subRoundY( ctxe, ctxa, ctxb, ctxc, ctxd, F2, const_stage2, 56 ); subRoundY( ctxd, ctxe, ctxa, ctxb, ctxc, F2, const_stage2, 57 ); subRoundY( ctxc, ctxd, ctxe, ctxa, ctxb, F2, const_stage2, 58 ); subRoundY( ctxb, ctxc, ctxd, ctxe, ctxa, F2, const_stage2, 59 ); round3: subRoundY( ctxa, ctxb, ctxc, ctxd, ctxe, F1, const_stage3, 60 ); subRoundY( ctxe, ctxa, ctxb, ctxc, ctxd, F1, const_stage3, 61 ); subRoundY( ctxd, ctxe, ctxa, ctxb, ctxc, F1, const_stage3, 62 ); subRoundY( ctxc, ctxd, ctxe, ctxa, ctxb, F1, const_stage3, 63 ); subRoundY( ctxb, ctxc, ctxd, ctxe, ctxa, F1, const_stage3, 64 ); subRoundY( ctxa, ctxb, ctxc, ctxd, ctxe, F1, const_stage3, 65 ); subRoundY( ctxe, ctxa, ctxb, ctxc, ctxd, F1, const_stage3, 66 ); subRoundY( ctxd, ctxe, ctxa, ctxb, ctxc, F1, const_stage3, 67 ); subRoundY( ctxc, ctxd, ctxe, ctxa, ctxb, F1, const_stage3, 68 ); subRoundY( ctxb, ctxc, ctxd, ctxe, ctxa, F1, const_stage3, 69 ); subRoundY( ctxa, ctxb, ctxc, ctxd, ctxe, F1, const_stage3, 70 ); subRoundY( ctxe, ctxa, ctxb, ctxc, ctxd, F1, const_stage3, 71 ); subRoundY( ctxd, ctxe, ctxa, ctxb, ctxc, F1, const_stage3, 72 ); subRoundY( ctxc, ctxd, ctxe, ctxa, ctxb, F1, const_stage3, 73 ); subRoundY( ctxb, ctxc, ctxd, ctxe, ctxa, F1, const_stage3, 74 ); subRoundY( ctxa, ctxb, ctxc, ctxd, ctxe, F1, const_stage3, 75 ); subRoundY( ctxe, ctxa, ctxb, ctxc, ctxd, F1, const_stage3, 76 ); subRoundY( ctxd, ctxe, ctxa, ctxb, ctxc, F1, const_stage3, 77 ); subRoundY( ctxc, ctxd, ctxe, ctxa, ctxb, F1, const_stage3, 78 ); subRoundY( ctxb, ctxc, ctxd, ctxe, ctxa, F1, const_stage3, 79 ); paddd 0(eax_rdi), ctxa paddd 16(eax_rdi), ctxb paddd 32(eax_rdi), ctxc paddd 48(eax_rdi), ctxd paddd 64(eax_rdi), ctxe movdqa ctxa, 0(eax_rdi) movdqa ctxb, 16(eax_rdi) movdqa ctxc, 32(eax_rdi) movdqa ctxd, 48(eax_rdi) movdqa ctxe, 64(eax_rdi) END_PIC() ret // returns 0 if neither MMX nor SSE2 are supported; 1 if MMX is supported; 2 if SSE2 is also supported shasse2_cpuid: _shasse2_cpuid: #ifndef __x86_64__ pushfl pushfl popl %eax movl %eax, %ecx xorl $0x200000, %eax push %eax popfl pushfl popl %eax popfl xorl %ecx, %eax jnz do_cpuid ret do_cpuid: #endif #ifdef __x86_64__ push %rbx push %rcx push %rdx #else push %ebx push %ecx push %edx #endif movl $1, %eax cpuid testl $0x00800000, %edx // bit 23 (MMX) jz no_mmx testl $0x04000000, %edx // bit 26 (SSE2) jz mmx_only // sse2 supported: movl $2, %eax jmp cpuid_exit mmx_only: movl $1, %eax jmp cpuid_exit no_mmx: movl $0, %eax cpuid_exit: #ifdef __x86_64__ pop %rdx pop %rcx pop %rbx #else pop %edx pop %ecx pop %ebx #endif ret #ifdef __i386__ #ifdef __PIC__ #ifndef __APPLE__ .section .gnu.linkonce.t.__i686.get_pc_thunk.bx,"ax",@progbits #endif .globl __i686.get_pc_thunk.bx #ifdef __APPLE__ .private_extern __i686.get_pc_thunk.bx #else .hidden __i686.get_pc_thunk.bx .type __i686.get_pc_thunk.bx,@function #endif __i686.get_pc_thunk.bx: movl (%esp), %ebx ret #endif #endif #endif #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits #endif aircrack-ng-1.6/lib/csharp/000077500000000000000000000000001361312141100155605ustar00rootroot00000000000000aircrack-ng-1.6/lib/csharp/Example1/000077500000000000000000000000001361312141100172345ustar00rootroot00000000000000aircrack-ng-1.6/lib/csharp/Example1/Example1.sln000066400000000000000000000050031361312141100214240ustar00rootroot00000000000000 Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Example1", "Example1\Example1.csproj", "{C4AE481A-A896-4830-9202-6221890AB43B}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WirelessPanda", "..\WirelessPanda\WirelessPanda.csproj", "{F3A06E01-20E6-4CF8-AD62-1034A0B4EAE3}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Debug|Mixed Platforms = Debug|Mixed Platforms Debug|x86 = Debug|x86 Release|Any CPU = Release|Any CPU Release|Mixed Platforms = Release|Mixed Platforms Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {C4AE481A-A896-4830-9202-6221890AB43B}.Debug|Any CPU.ActiveCfg = Debug|x86 {C4AE481A-A896-4830-9202-6221890AB43B}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 {C4AE481A-A896-4830-9202-6221890AB43B}.Debug|Mixed Platforms.Build.0 = Debug|x86 {C4AE481A-A896-4830-9202-6221890AB43B}.Debug|x86.ActiveCfg = Debug|x86 {C4AE481A-A896-4830-9202-6221890AB43B}.Debug|x86.Build.0 = Debug|x86 {C4AE481A-A896-4830-9202-6221890AB43B}.Release|Any CPU.ActiveCfg = Release|x86 {C4AE481A-A896-4830-9202-6221890AB43B}.Release|Mixed Platforms.ActiveCfg = Release|x86 {C4AE481A-A896-4830-9202-6221890AB43B}.Release|Mixed Platforms.Build.0 = Release|x86 {C4AE481A-A896-4830-9202-6221890AB43B}.Release|x86.ActiveCfg = Release|x86 {C4AE481A-A896-4830-9202-6221890AB43B}.Release|x86.Build.0 = Release|x86 {F3A06E01-20E6-4CF8-AD62-1034A0B4EAE3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {F3A06E01-20E6-4CF8-AD62-1034A0B4EAE3}.Debug|Any CPU.Build.0 = Debug|Any CPU {F3A06E01-20E6-4CF8-AD62-1034A0B4EAE3}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {F3A06E01-20E6-4CF8-AD62-1034A0B4EAE3}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU {F3A06E01-20E6-4CF8-AD62-1034A0B4EAE3}.Debug|x86.ActiveCfg = Debug|Any CPU {F3A06E01-20E6-4CF8-AD62-1034A0B4EAE3}.Release|Any CPU.ActiveCfg = Release|Any CPU {F3A06E01-20E6-4CF8-AD62-1034A0B4EAE3}.Release|Any CPU.Build.0 = Release|Any CPU {F3A06E01-20E6-4CF8-AD62-1034A0B4EAE3}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {F3A06E01-20E6-4CF8-AD62-1034A0B4EAE3}.Release|Mixed Platforms.Build.0 = Release|Any CPU {F3A06E01-20E6-4CF8-AD62-1034A0B4EAE3}.Release|x86.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal aircrack-ng-1.6/lib/csharp/Example1/Example1/000077500000000000000000000000001361312141100207105ustar00rootroot00000000000000aircrack-ng-1.6/lib/csharp/Example1/Example1/Example1.csproj000066400000000000000000000073121361312141100236110ustar00rootroot00000000000000 Debug x86 8.0.30703 2.0 {C4AE481A-A896-4830-9202-6221890AB43B} WinExe Properties Example1 Example1 v4.0 512 x86 true full false bin\Debug\ DEBUG;TRACE prompt 4 x86 pdbonly true bin\Release\ TRACE prompt 4 Form Form1.cs Form1.cs ResXFileCodeGenerator Resources.Designer.cs Designer True Resources.resx True SettingsSingleFileGenerator Settings.Designer.cs True Settings.settings True {F3A06E01-20E6-4CF8-AD62-1034A0B4EAE3} WirelessPanda aircrack-ng-1.6/lib/csharp/Example1/Example1/Form1.Designer.cs000066400000000000000000000242321361312141100237650ustar00rootroot00000000000000namespace Example1 { partial class Form1 { /// /// Required designer variable. /// private System.ComponentModel.IContainer components = null; /// /// Clean up any resources being used. /// /// true if managed resources should be disposed; otherwise, false. protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows Form Designer generated code /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.dataGridView1 = new System.Windows.Forms.DataGridView(); this.dataGridView2 = new System.Windows.Forms.DataGridView(); this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.button1 = new System.Windows.Forms.Button(); this.label3 = new System.Windows.Forms.Label(); this.lblFiletype = new System.Windows.Forms.Label(); this.label4 = new System.Windows.Forms.Label(); this.lblFilename = new System.Windows.Forms.Label(); this.label5 = new System.Windows.Forms.Label(); this.lblParsed = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).BeginInit(); this.SuspendLayout(); // // dataGridView1 // this.dataGridView1.AllowUserToAddRows = false; this.dataGridView1.AllowUserToDeleteRows = false; this.dataGridView1.AllowUserToOrderColumns = true; this.dataGridView1.AllowUserToResizeRows = false; this.dataGridView1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.ColumnHeader; this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dataGridView1.Location = new System.Drawing.Point(12, 106); this.dataGridView1.MultiSelect = false; this.dataGridView1.Name = "dataGridView1"; this.dataGridView1.ReadOnly = true; this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.dataGridView1.Size = new System.Drawing.Size(860, 128); this.dataGridView1.TabIndex = 0; // // dataGridView2 // this.dataGridView2.AllowUserToAddRows = false; this.dataGridView2.AllowUserToDeleteRows = false; this.dataGridView2.AllowUserToOrderColumns = true; this.dataGridView2.AllowUserToResizeRows = false; this.dataGridView2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.dataGridView2.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.dataGridView2.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dataGridView2.Location = new System.Drawing.Point(12, 268); this.dataGridView2.MultiSelect = false; this.dataGridView2.Name = "dataGridView2"; this.dataGridView2.ReadOnly = true; this.dataGridView2.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.dataGridView2.Size = new System.Drawing.Size(860, 128); this.dataGridView2.TabIndex = 1; // // label1 // this.label1.Anchor = System.Windows.Forms.AnchorStyles.Top; this.label1.AutoSize = true; this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label1.Location = new System.Drawing.Point(388, 86); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(109, 17); this.label1.TabIndex = 2; this.label1.Text = "Access Points"; // // label2 // this.label2.Anchor = System.Windows.Forms.AnchorStyles.Top; this.label2.AutoSize = true; this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label2.Location = new System.Drawing.Point(409, 248); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(67, 17); this.label2.TabIndex = 3; this.label2.Text = "Stations"; // // button1 // this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.button1.Location = new System.Drawing.Point(797, 12); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(75, 23); this.button1.TabIndex = 4; this.button1.Text = "Load..."; this.button1.UseVisualStyleBackColor = true; this.button1.Click += new System.EventHandler(this.button1_Click); // // label3 // this.label3.AutoSize = true; this.label3.Location = new System.Drawing.Point(12, 35); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(49, 13); this.label3.TabIndex = 5; this.label3.Text = "File type:"; // // lblFiletype // this.lblFiletype.AutoSize = true; this.lblFiletype.Location = new System.Drawing.Point(67, 35); this.lblFiletype.Name = "lblFiletype"; this.lblFiletype.Size = new System.Drawing.Size(53, 13); this.lblFiletype.TabIndex = 6; this.lblFiletype.Text = "Unknown"; // // label4 // this.label4.AutoSize = true; this.label4.Location = new System.Drawing.Point(12, 12); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(52, 13); this.label4.TabIndex = 7; this.label4.Text = "Filename:"; // // lblFilename // this.lblFilename.AutoSize = true; this.lblFilename.Location = new System.Drawing.Point(67, 12); this.lblFilename.Name = "lblFilename"; this.lblFilename.Size = new System.Drawing.Size(53, 13); this.lblFilename.TabIndex = 8; this.lblFilename.Text = "Unknown"; // // label5 // this.label5.AutoSize = true; this.label5.Location = new System.Drawing.Point(12, 57); this.label5.Name = "label5"; this.label5.Size = new System.Drawing.Size(43, 13); this.label5.TabIndex = 9; this.label5.Text = "Parsed:"; // // lblParsed // this.lblParsed.AutoSize = true; this.lblParsed.Location = new System.Drawing.Point(67, 57); this.lblParsed.Name = "lblParsed"; this.lblParsed.Size = new System.Drawing.Size(53, 13); this.lblParsed.TabIndex = 10; this.lblParsed.Text = "Unknown"; // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(884, 411); this.Controls.Add(this.lblParsed); this.Controls.Add(this.label5); this.Controls.Add(this.lblFilename); this.Controls.Add(this.label4); this.Controls.Add(this.lblFiletype); this.Controls.Add(this.label3); this.Controls.Add(this.button1); this.Controls.Add(this.label2); this.Controls.Add(this.label1); this.Controls.Add(this.dataGridView2); this.Controls.Add(this.dataGridView1); this.MinimumSize = new System.Drawing.Size(200, 438); this.Name = "Form1"; this.Text = "Example 1"; this.SizeChanged += new System.EventHandler(this.Form1_SizeChanged); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); } #endregion private System.Windows.Forms.DataGridView dataGridView1; private System.Windows.Forms.DataGridView dataGridView2; private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label2; private System.Windows.Forms.Button button1; private System.Windows.Forms.Label label3; private System.Windows.Forms.Label lblFiletype; private System.Windows.Forms.Label label4; private System.Windows.Forms.Label lblFilename; private System.Windows.Forms.Label label5; private System.Windows.Forms.Label lblParsed; } } aircrack-ng-1.6/lib/csharp/Example1/Example1/Form1.cs000066400000000000000000000041731361312141100222300ustar00rootroot00000000000000// License: BSD // Copyright (C) 2011-2018 Thomas d'Otreppe using System; using System.Windows.Forms; using WirelessPanda.Readers; namespace Example1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } /// /// Load file /// /// /// private void button1_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Multiselect = false; if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { // Load file Reader reader = new UniversalReader(ofd.FileName); try { // and parse it reader.Read(); // Add Datatables this.dataGridView1.DataSource = reader.Dataset.Tables[Reader.ACCESSPOINTS_DATATABLE]; this.dataGridView2.DataSource = reader.Dataset.Tables[Reader.STATIONS_DATATABLE]; } catch (Exception ex) { MessageBox.Show("Exception: " + ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } // Set file type this.lblFiletype.Text = reader.ReaderType; // Set filename this.lblFilename.Text = reader.Filename; // Indicate if parsing was successful if (reader.ParseSuccess) { this.lblParsed.Text = "Yes"; } else { this.lblParsed.Text = "No"; } } } private void Form1_SizeChanged(object sender, EventArgs e) { Form f = sender as Form; this.label1.Left = (f.Width - this.label1.Width) / 2; this.label2.Left = (f.Width - this.label2.Width) / 2; } } } aircrack-ng-1.6/lib/csharp/Example1/Example1/Form1.resx000066400000000000000000000132711361312141100226030ustar00rootroot00000000000000 text/microsoft-resx 2.0 System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 aircrack-ng-1.6/lib/csharp/Example1/Example1/Program.cs000066400000000000000000000006751361312141100226560ustar00rootroot00000000000000using System; using System.Windows.Forms; namespace Example1 { static class Program { /// /// The main entry point for the application. /// [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); } } } aircrack-ng-1.6/lib/csharp/Example1/Example1/Properties/000077500000000000000000000000001361312141100230445ustar00rootroot00000000000000aircrack-ng-1.6/lib/csharp/Example1/Example1/Properties/AssemblyInfo.cs000066400000000000000000000026231361312141100257710ustar00rootroot00000000000000using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("Example1")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Example1")] [assembly: AssemblyCopyright("Copyright © 2011")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("c8ca20fd-396d-461e-a240-3cb2214597d8")] // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] aircrack-ng-1.6/lib/csharp/Example1/Example1/Properties/Resources.Designer.cs000066400000000000000000000054321361312141100271100ustar00rootroot00000000000000//------------------------------------------------------------------------------ // // This code was generated by a tool. // Runtime Version:4.0.30319.225 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // //------------------------------------------------------------------------------ namespace Example1.Properties { using System; /// /// A strongly-typed resource class, for looking up localized strings, etc. /// // This class was auto-generated by the StronglyTypedResourceBuilder // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { private static global::System.Resources.ResourceManager resourceMan; private static global::System.Globalization.CultureInfo resourceCulture; [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] internal Resources() { } /// /// Returns the cached ResourceManager instance used by this class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Example1.Properties.Resources", typeof(Resources).Assembly); resourceMan = temp; } return resourceMan; } } /// /// Overrides the current thread's CurrentUICulture property for all /// resource lookups using this strongly typed resource class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] internal static global::System.Globalization.CultureInfo Culture { get { return resourceCulture; } set { resourceCulture = value; } } } } aircrack-ng-1.6/lib/csharp/Example1/Example1/Properties/Resources.resx000066400000000000000000000127541361312141100257320ustar00rootroot00000000000000 text/microsoft-resx 2.0 System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 aircrack-ng-1.6/lib/csharp/Example1/Example1/Properties/Settings.Designer.cs000066400000000000000000000021011361312141100267240ustar00rootroot00000000000000//------------------------------------------------------------------------------ // // This code was generated by a tool. // Runtime Version:4.0.30319.225 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // //------------------------------------------------------------------------------ namespace Example1.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); public static Settings Default { get { return defaultInstance; } } } } aircrack-ng-1.6/lib/csharp/Example1/Example1/Properties/Settings.settings000066400000000000000000000003711361312141100264270ustar00rootroot00000000000000 aircrack-ng-1.6/lib/csharp/Example1/Example1/app.config000066400000000000000000000002201361312141100226510ustar00rootroot00000000000000 aircrack-ng-1.6/lib/csharp/MonoExample/000077500000000000000000000000001361312141100200045ustar00rootroot00000000000000aircrack-ng-1.6/lib/csharp/MonoExample/NDesk-dbus/000077500000000000000000000000001361312141100217435ustar00rootroot00000000000000aircrack-ng-1.6/lib/csharp/MonoExample/NDesk-dbus/Address.cs000066400000000000000000000066731361312141100236730ustar00rootroot00000000000000// Copyright 2006 Alp Toker // This software is made available under the MIT License // See COPYING for details using System; using System.Text; using System.Collections.Generic; namespace NDesk.DBus { public class BadAddressException : Exception { public BadAddressException (string reason) : base (reason) {} } class AddressEntry { public string Method; public IDictionary Properties = new Dictionary (); public override string ToString () { StringBuilder sb = new StringBuilder (); sb.Append (Method); sb.Append (':'); bool first = true; foreach (KeyValuePair prop in Properties) { if (first) first = false; else sb.Append (','); sb.Append (prop.Key); sb.Append ('='); sb.Append (Escape (prop.Value)); } return sb.ToString (); } static string Escape (string str) { if (str == null) return String.Empty; StringBuilder sb = new StringBuilder (); int len = str.Length; for (int i = 0 ; i != len ; i++) { char c = str[i]; //everything other than the optionally escaped chars _must_ be escaped if (Char.IsLetterOrDigit (c) || c == '-' || c == '_' || c == '/' || c == '\\' || c == '.') sb.Append (c); else sb.Append (Uri.HexEscape (c)); } return sb.ToString (); } static string Unescape (string str) { if (str == null) return String.Empty; StringBuilder sb = new StringBuilder (); int len = str.Length; int i = 0; while (i != len) { if (Uri.IsHexEncoding (str, i)) sb.Append (Uri.HexUnescape (str, ref i)); else sb.Append (str[i++]); } return sb.ToString (); } public static AddressEntry Parse (string s) { AddressEntry entry = new AddressEntry (); string[] parts = s.Split (':'); if (parts.Length < 2) throw new BadAddressException ("No colon found"); if (parts.Length > 2) throw new BadAddressException ("Too many colons found"); entry.Method = parts[0]; foreach (string propStr in parts[1].Split (',')) { parts = propStr.Split ('='); if (parts.Length < 2) throw new BadAddressException ("No equals sign found"); if (parts.Length > 2) throw new BadAddressException ("Too many equals signs found"); entry.Properties[parts[0]] = Unescape (parts[1]); } return entry; } } static class Address { //(unix:(path|abstract)=.*,guid=.*|tcp:host=.*(,port=.*)?);? ... public static AddressEntry[] Parse (string addresses) { if (addresses == null) throw new ArgumentNullException (addresses); List entries = new List (); foreach (string entryStr in addresses.Split (';')) entries.Add (AddressEntry.Parse (entryStr)); return entries.ToArray (); } const string SYSTEM_BUS_ADDRESS = "unix:path=/var/run/dbus/system_bus_socket"; public static string System { get { string addr = Environment.GetEnvironmentVariable ("DBUS_SYSTEM_BUS_ADDRESS"); if (String.IsNullOrEmpty (addr)) addr = SYSTEM_BUS_ADDRESS; return addr; } } public static string Session { get { return Environment.GetEnvironmentVariable ("DBUS_SESSION_BUS_ADDRESS"); } } public static string Starter { get { return Environment.GetEnvironmentVariable ("DBUS_STARTER_ADDRESS"); } } public static string StarterBusType { get { return Environment.GetEnvironmentVariable ("DBUS_STARTER_BUS_TYPE"); } } } } aircrack-ng-1.6/lib/csharp/MonoExample/NDesk-dbus/AssemblyInfo.cs000066400000000000000000000026071361312141100246720ustar00rootroot00000000000000// Copyright 2006 Alp Toker // This software is made available under the MIT License // See COPYING for details using System.Reflection; using System.Runtime.CompilerServices; [assembly: AssemblyFileVersion("0.6.0")] [assembly: AssemblyInformationalVersion("0.6.0")] [assembly: AssemblyVersion("0.6.0")] [assembly: AssemblyTitle ("NDesk.DBus")] [assembly: AssemblyDescription ("D-Bus IPC protocol library and CLR binding")] [assembly: AssemblyCopyright ("Copyright (C) Alp Toker")] [assembly: AssemblyCompany ("NDesk")] #if STRONG_NAME [assembly: InternalsVisibleTo ("dbus-monitor, PublicKey=0024000004800000440000000602000000240000525341318001000011000000ffbfaa640454654de78297fde2d22dd4bc4b0476fa892c3f8575ad4f048ce0721ce4109f542936083bc4dd83be5f7f97")] [assembly: InternalsVisibleTo ("NDesk.DBus.GLib, PublicKey=0024000004800000440000000602000000240000525341318001000011000000ffbfaa640454654de78297fde2d22dd4bc4b0476fa892c3f8575ad4f048ce0721ce4109f542936083bc4dd83be5f7f97")] [assembly: InternalsVisibleTo ("NDesk.DBus.Proxies, PublicKey=0024000004800000440000000602000000240000525341318001000011000000ffbfaa640454654de78297fde2d22dd4bc4b0476fa892c3f8575ad4f048ce0721ce4109f542936083bc4dd83be5f7f97")] #else [assembly: InternalsVisibleTo ("dbus-monitor")] [assembly: InternalsVisibleTo ("NDesk.DBus.GLib")] [assembly: InternalsVisibleTo ("NDesk.DBus.Proxies")] #endif aircrack-ng-1.6/lib/csharp/MonoExample/NDesk-dbus/Authentication.cs000066400000000000000000000064441361312141100252610ustar00rootroot00000000000000// Copyright 2006 Alp Toker // This software is made available under the MIT License // See COPYING for details using System; using System.Collections.Generic; using System.IO; using System.Text; using System.Globalization; namespace NDesk.DBus.Authentication { enum ClientState { WaitingForData, WaitingForOK, WaitingForReject, } enum ServerState { WaitingForAuth, WaitingForData, WaitingForBegin, } class SaslClient { protected Connection conn; protected SaslClient () { } public SaslClient (Connection conn) { this.conn = conn; } public void Run () { StreamReader sr = new StreamReader (conn.Transport.Stream, Encoding.ASCII); StreamWriter sw = new StreamWriter (conn.Transport.Stream, Encoding.ASCII); sw.NewLine = "\r\n"; string str = conn.Transport.AuthString (); byte[] bs = Encoding.ASCII.GetBytes (str); string authStr = ToHex (bs); sw.WriteLine ("AUTH EXTERNAL {0}", authStr); sw.Flush (); string ok_rep = sr.ReadLine (); string[] parts; parts = ok_rep.Split (' '); if (parts.Length < 1 || parts[0] != "OK") throw new Exception ("Authentication error: AUTH EXTERNAL was not OK: \"" + ok_rep + "\""); /* string guid = parts[1]; byte[] guidData = FromHex (guid); uint unixTime = BitConverter.ToUInt32 (guidData, 0); Console.Error.WriteLine ("guid: " + guid + ", " + "unixTime: " + unixTime + " (" + UnixToDateTime (unixTime) + ")"); */ sw.WriteLine ("BEGIN"); sw.Flush (); } //From Mono.Unix.Native.NativeConvert //should these methods use long or (u)int? public static DateTime UnixToDateTime (long time) { DateTime LocalUnixEpoch = new DateTime (1970, 1, 1); TimeSpan LocalUtcOffset = TimeZone.CurrentTimeZone.GetUtcOffset (DateTime.UtcNow); return LocalUnixEpoch.AddSeconds ((double) time + LocalUtcOffset.TotalSeconds); } public static long DateTimeToUnix (DateTime time) { DateTime LocalUnixEpoch = new DateTime (1970, 1, 1); TimeSpan LocalUtcOffset = TimeZone.CurrentTimeZone.GetUtcOffset (DateTime.UtcNow); TimeSpan unixTime = time.Subtract (LocalUnixEpoch) - LocalUtcOffset; return (long) unixTime.TotalSeconds; } //From Mono.Security.Cryptography //Modified to output lowercase hex static public string ToHex (byte[] input) { if (input == null) return null; StringBuilder sb = new StringBuilder (input.Length * 2); foreach (byte b in input) { sb.Append (b.ToString ("x2", CultureInfo.InvariantCulture)); } return sb.ToString (); } //From Mono.Security.Cryptography static private byte FromHexChar (char c) { if ((c >= 'a') && (c <= 'f')) return (byte) (c - 'a' + 10); if ((c >= 'A') && (c <= 'F')) return (byte) (c - 'A' + 10); if ((c >= '0') && (c <= '9')) return (byte) (c - '0'); throw new ArgumentException ("Invalid hex char"); } //From Mono.Security.Cryptography static public byte[] FromHex (string hex) { if (hex == null) return null; if ((hex.Length & 0x1) == 0x1) throw new ArgumentException ("Length must be a multiple of 2"); byte[] result = new byte [hex.Length >> 1]; int n = 0; int i = 0; while (n < result.Length) { result [n] = (byte) (FromHexChar (hex [i++]) << 4); result [n++] += FromHexChar (hex [i++]); } return result; } } } aircrack-ng-1.6/lib/csharp/MonoExample/NDesk-dbus/Bus.cs000066400000000000000000000073611361312141100230320ustar00rootroot00000000000000// Copyright 2006 Alp Toker // This software is made available under the MIT License // See COPYING for details using System; using System.Collections.Generic; using org.freedesktop.DBus; namespace NDesk.DBus { public sealed class Bus : Connection { static Bus systemBus = null; public static Bus System { get { if (systemBus == null) { try { if (Address.StarterBusType == "system") systemBus = Starter; else systemBus = Bus.Open (Address.System); } catch (Exception e) { throw new Exception ("Unable to open the system message bus.", e); } } return systemBus; } } static Bus sessionBus = null; public static Bus Session { get { if (sessionBus == null) { try { if (Address.StarterBusType == "session") sessionBus = Starter; else sessionBus = Bus.Open (Address.Session); } catch (Exception e) { throw new Exception ("Unable to open the session message bus.", e); } } return sessionBus; } } //TODO: parsing of starter bus type, or maybe do this another way static Bus starterBus = null; public static Bus Starter { get { if (starterBus == null) { try { starterBus = Bus.Open (Address.Starter); } catch (Exception e) { throw new Exception ("Unable to open the starter message bus.", e); } } return starterBus; } } //public static readonly Bus Session = null; //TODO: use the guid, not the whole address string //TODO: consider what happens when a connection has been closed static Dictionary buses = new Dictionary (); //public static Connection Open (string address) public static new Bus Open (string address) { if (address == null) throw new ArgumentNullException ("address"); if (buses.ContainsKey (address)) return buses[address]; Bus bus = new Bus (address); buses[address] = bus; return bus; } IBus bus; static readonly string DBusName = "org.freedesktop.DBus"; static readonly ObjectPath DBusPath = new ObjectPath ("/org/freedesktop/DBus"); public Bus (string address) : base (address) { bus = GetObject (DBusName, DBusPath); /* bus.NameAcquired += delegate (string acquired_name) { Console.WriteLine ("NameAcquired: " + acquired_name); }; */ Register (); } //should this be public? //as long as Bus subclasses Connection, having a Register with a completely different meaning is bad void Register () { if (unique_name != null) throw new Exception ("Bus already has a unique name"); unique_name = bus.Hello (); } public ulong GetUnixUser (string name) { return bus.GetConnectionUnixUser (name); } public RequestNameReply RequestName (string name) { return RequestName (name, NameFlag.None); } public RequestNameReply RequestName (string name, NameFlag flags) { return bus.RequestName (name, flags); } public ReleaseNameReply ReleaseName (string name) { return bus.ReleaseName (name); } public bool NameHasOwner (string name) { return bus.NameHasOwner (name); } public StartReply StartServiceByName (string name) { return StartServiceByName (name, 0); } public StartReply StartServiceByName (string name, uint flags) { return bus.StartServiceByName (name, flags); } internal protected override void AddMatch (string rule) { bus.AddMatch (rule); } internal protected override void RemoveMatch (string rule) { bus.RemoveMatch (rule); } string unique_name = null; public string UniqueName { get { return unique_name; } set { if (unique_name != null) throw new Exception ("Unique name can only be set once"); unique_name = value; } } } } aircrack-ng-1.6/lib/csharp/MonoExample/NDesk-dbus/BusObject.cs000066400000000000000000000205511361312141100241550ustar00rootroot00000000000000// Copyright 2006 Alp Toker // This software is made available under the MIT License // See COPYING for details using System; using System.Reflection; using System.Reflection.Emit; using System.Collections.Generic; namespace NDesk.DBus { class BusObject { protected Connection conn; string bus_name; ObjectPath object_path; //protected BusObject () public BusObject () { } public BusObject (Connection conn, string bus_name, ObjectPath object_path) { this.conn = conn; this.bus_name = bus_name; this.object_path = object_path; } public Connection Connection { get { return conn; } } public string BusName { get { return bus_name; } } public ObjectPath Path { get { return object_path; } } public void ToggleSignal (string iface, string member, Delegate dlg, bool adding) { MatchRule rule = new MatchRule (); rule.MessageType = MessageType.Signal; rule.Interface = iface; rule.Member = member; rule.Path = object_path; if (adding) { if (conn.Handlers.ContainsKey (rule)) conn.Handlers[rule] = Delegate.Combine (conn.Handlers[rule], dlg); else { conn.Handlers[rule] = dlg; conn.AddMatch (rule.ToString ()); } } else { conn.Handlers[rule] = Delegate.Remove (conn.Handlers[rule], dlg); if (conn.Handlers[rule] == null) { conn.RemoveMatch (rule.ToString ()); conn.Handlers.Remove (rule); } } } public void SendSignal (string iface, string member, string inSigStr, MessageWriter writer, Type retType, out Exception exception) { exception = null; //TODO: don't ignore retVal, exception etc. Signature outSig = String.IsNullOrEmpty (inSigStr) ? Signature.Empty : new Signature (inSigStr); Signal signal = new Signal (object_path, iface, member); signal.message.Signature = outSig; Message signalMsg = signal.message; signalMsg.Body = writer.ToArray (); conn.Send (signalMsg); } public object SendMethodCall (string iface, string member, string inSigStr, MessageWriter writer, Type retType, out Exception exception) { exception = null; //TODO: don't ignore retVal, exception etc. Signature inSig = String.IsNullOrEmpty (inSigStr) ? Signature.Empty : new Signature (inSigStr); MethodCall method_call = new MethodCall (object_path, iface, member, bus_name, inSig); Message callMsg = method_call.message; callMsg.Body = writer.ToArray (); //Invoke Code:: //TODO: complete out parameter support /* Type[] outParmTypes = Mapper.GetTypes (ArgDirection.Out, mi.GetParameters ()); Signature outParmSig = Signature.GetSig (outParmTypes); if (outParmSig != Signature.Empty) throw new Exception ("Out parameters not yet supported: out_signature='" + outParmSig.Value + "'"); */ Type[] outTypes = new Type[1]; outTypes[0] = retType; //we default to always requiring replies for now, even though unnecessary //this is to make sure errors are handled synchronously //TODO: don't hard code this bool needsReply = true; //if (mi.ReturnType == typeof (void)) // needsReply = false; callMsg.ReplyExpected = needsReply; callMsg.Signature = inSig; if (!needsReply) { conn.Send (callMsg); return null; } #if PROTO_REPLY_SIGNATURE if (needsReply) { Signature outSig = Signature.GetSig (outTypes); callMsg.Header.Fields[FieldCode.ReplySignature] = outSig; } #endif Message retMsg = conn.SendWithReplyAndBlock (callMsg); object retVal = null; //handle the reply message switch (retMsg.Header.MessageType) { case MessageType.MethodReturn: object[] retVals = MessageHelper.GetDynamicValues (retMsg, outTypes); if (retVals.Length != 0) retVal = retVals[retVals.Length - 1]; break; case MessageType.Error: //TODO: typed exceptions Error error = new Error (retMsg); string errMsg = String.Empty; if (retMsg.Signature.Value.StartsWith ("s")) { MessageReader reader = new MessageReader (retMsg); errMsg = reader.ReadString (); } exception = new Exception (error.ErrorName + ": " + errMsg); break; default: throw new Exception ("Got unexpected message of type " + retMsg.Header.MessageType + " while waiting for a MethodReturn or Error"); } return retVal; } public void Invoke (MethodBase methodBase, string methodName, object[] inArgs, out object[] outArgs, out object retVal, out Exception exception) { outArgs = new object[0]; retVal = null; exception = null; MethodInfo mi = methodBase as MethodInfo; if (mi != null && mi.IsSpecialName && (methodName.StartsWith ("add_") || methodName.StartsWith ("remove_"))) { string[] parts = methodName.Split (new char[]{'_'}, 2); string ename = parts[1]; Delegate dlg = (Delegate)inArgs[0]; ToggleSignal (Mapper.GetInterfaceName (mi), ename, dlg, parts[0] == "add"); return; } Type[] inTypes = Mapper.GetTypes (ArgDirection.In, mi.GetParameters ()); Signature inSig = Signature.GetSig (inTypes); MethodCall method_call; Message callMsg; //build the outbound method call message { //this bit is error-prone (no null checking) and will need rewriting when DProxy is replaced string iface = null; if (mi != null) iface = Mapper.GetInterfaceName (mi); //map property accessors //TODO: this needs to be done properly, not with simple String.Replace //note that IsSpecialName is also for event accessors, but we already handled those and returned if (mi != null && mi.IsSpecialName) { methodName = methodName.Replace ("get_", "Get"); methodName = methodName.Replace ("set_", "Set"); } method_call = new MethodCall (object_path, iface, methodName, bus_name, inSig); callMsg = method_call.message; if (inArgs != null && inArgs.Length != 0) { MessageWriter writer = new MessageWriter (Connection.NativeEndianness); writer.connection = conn; for (int i = 0 ; i != inTypes.Length ; i++) writer.Write (inTypes[i], inArgs[i]); callMsg.Body = writer.ToArray (); } } //TODO: complete out parameter support /* Type[] outParmTypes = Mapper.GetTypes (ArgDirection.Out, mi.GetParameters ()); Signature outParmSig = Signature.GetSig (outParmTypes); if (outParmSig != Signature.Empty) throw new Exception ("Out parameters not yet supported: out_signature='" + outParmSig.Value + "'"); */ Type[] outTypes = new Type[1]; outTypes[0] = mi.ReturnType; //we default to always requiring replies for now, even though unnecessary //this is to make sure errors are handled synchronously //TODO: don't hard code this bool needsReply = true; //if (mi.ReturnType == typeof (void)) // needsReply = false; callMsg.ReplyExpected = needsReply; callMsg.Signature = inSig; if (!needsReply) { conn.Send (callMsg); return; } #if PROTO_REPLY_SIGNATURE if (needsReply) { Signature outSig = Signature.GetSig (outTypes); callMsg.Header.Fields[FieldCode.ReplySignature] = outSig; } #endif Message retMsg = conn.SendWithReplyAndBlock (callMsg); //handle the reply message switch (retMsg.Header.MessageType) { case MessageType.MethodReturn: object[] retVals = MessageHelper.GetDynamicValues (retMsg, outTypes); if (retVals.Length != 0) retVal = retVals[retVals.Length - 1]; break; case MessageType.Error: //TODO: typed exceptions Error error = new Error (retMsg); string errMsg = String.Empty; if (retMsg.Signature.Value.StartsWith ("s")) { MessageReader reader = new MessageReader (retMsg); errMsg = reader.ReadString (); } exception = new Exception (error.ErrorName + ": " + errMsg); break; default: throw new Exception ("Got unexpected message of type " + retMsg.Header.MessageType + " while waiting for a MethodReturn or Error"); } return; } public static object GetObject (Connection conn, string bus_name, ObjectPath object_path, Type declType) { Type proxyType = TypeImplementer.GetImplementation (declType); BusObject inst = (BusObject)Activator.CreateInstance (proxyType); inst.conn = conn; inst.bus_name = bus_name; inst.object_path = object_path; return inst; } public Delegate GetHookupDelegate (EventInfo ei) { DynamicMethod hookupMethod = TypeImplementer.GetHookupMethod (ei); Delegate d = hookupMethod.CreateDelegate (ei.EventHandlerType, this); return d; } } } aircrack-ng-1.6/lib/csharp/MonoExample/NDesk-dbus/Connection.cs000066400000000000000000000344201361312141100243740ustar00rootroot00000000000000// Copyright 2006 Alp Toker // This software is made available under the MIT License // See COPYING for details using System; using System.Collections.Generic; using System.IO; using System.Threading; using System.Reflection; namespace NDesk.DBus { using Authentication; using Transports; public partial class Connection { //TODO: reconsider this field Stream ns = null; Transport transport; internal Transport Transport { get { return transport; } set { transport = value; } } protected Connection () {} internal Connection (Transport transport) { this.transport = transport; transport.Connection = this; //TODO: clean this bit up ns = transport.Stream; } //should this be public? internal Connection (string address) { OpenPrivate (address); Authenticate (); } /* bool isConnected = false; public bool IsConnected { get { return isConnected; } } */ //should we do connection sharing here? public static Connection Open (string address) { Connection conn = new Connection (); conn.OpenPrivate (address); conn.Authenticate (); return conn; } internal void OpenPrivate (string address) { if (address == null) throw new ArgumentNullException ("address"); AddressEntry[] entries = Address.Parse (address); if (entries.Length == 0) throw new Exception ("No addresses were found"); //TODO: try alternative addresses if needed AddressEntry entry = entries[0]; transport = Transport.Create (entry); //TODO: clean this bit up ns = transport.Stream; } void Authenticate () { if (transport != null) transport.WriteCred (); SaslClient auth = new SaslClient (this); auth.Run (); isAuthenticated = true; } bool isAuthenticated = false; internal bool IsAuthenticated { get { return isAuthenticated; } } //Interlocked.Increment() handles the overflow condition for uint correctly, so it's ok to store the value as an int but cast it to uint int serial = 0; uint GenerateSerial () { //return ++serial; return (uint)Interlocked.Increment (ref serial); } internal Message SendWithReplyAndBlock (Message msg) { PendingCall pending = SendWithReply (msg); return pending.Reply; } internal PendingCall SendWithReply (Message msg) { msg.ReplyExpected = true; msg.Header.Serial = GenerateSerial (); //TODO: throttle the maximum number of concurrent PendingCalls PendingCall pending = new PendingCall (this); pendingCalls[msg.Header.Serial] = pending; WriteMessage (msg); return pending; } internal uint Send (Message msg) { msg.Header.Serial = GenerateSerial (); WriteMessage (msg); //Outbound.Enqueue (msg); //temporary //Flush (); return msg.Header.Serial; } object writeLock = new object (); internal void WriteMessage (Message msg) { byte[] HeaderData = msg.GetHeaderData (); long msgLength = HeaderData.Length + (msg.Body != null ? msg.Body.Length : 0); if (msgLength > Protocol.MaxMessageLength) throw new Exception ("Message length " + msgLength + " exceeds maximum allowed " + Protocol.MaxMessageLength + " bytes"); lock (writeLock) { ns.Write (HeaderData, 0, HeaderData.Length); if (msg.Body != null && msg.Body.Length != 0) ns.Write (msg.Body, 0, msg.Body.Length); } } Queue Inbound = new Queue (); /* Queue Outbound = new Queue (); public void Flush () { //should just iterate the enumerator here while (Outbound.Count != 0) { Message msg = Outbound.Dequeue (); WriteMessage (msg); } } public bool ReadWrite (int timeout_milliseconds) { //TODO return true; } public bool ReadWrite () { return ReadWrite (-1); } public bool Dispatch () { //TODO Message msg = Inbound.Dequeue (); //HandleMessage (msg); return true; } public bool ReadWriteDispatch (int timeout_milliseconds) { //TODO return Dispatch (); } public bool ReadWriteDispatch () { return ReadWriteDispatch (-1); } */ internal Message ReadMessage () { byte[] header; byte[] body = null; int read; //16 bytes is the size of the fixed part of the header byte[] hbuf = new byte[16]; read = ns.Read (hbuf, 0, 16); if (read == 0) return null; if (read != 16) throw new Exception ("Header read length mismatch: " + read + " of expected " + "16"); EndianFlag endianness = (EndianFlag)hbuf[0]; MessageReader reader = new MessageReader (endianness, hbuf); //discard the endian byte as we've already read it reader.ReadByte (); //discard message type and flags, which we don't care about here reader.ReadByte (); reader.ReadByte (); byte version = reader.ReadByte (); if (version < Protocol.MinVersion || version > Protocol.MaxVersion) throw new NotSupportedException ("Protocol version '" + version.ToString () + "' is not supported"); if (Protocol.Verbose) if (version != Protocol.Version) Console.Error.WriteLine ("Warning: Protocol version '" + version.ToString () + "' is not explicitly supported but may be compatible"); uint bodyLength = reader.ReadUInt32 (); //discard serial reader.ReadUInt32 (); uint headerLength = reader.ReadUInt32 (); //this check may become relevant if a future version of the protocol allows larger messages /* if (bodyLength > Int32.MaxValue || headerLength > Int32.MaxValue) throw new NotImplementedException ("Long messages are not yet supported"); */ int bodyLen = (int)bodyLength; int toRead = (int)headerLength; //we fixup to include the padding following the header toRead = Protocol.Padded (toRead, 8); long msgLength = toRead + bodyLen; if (msgLength > Protocol.MaxMessageLength) throw new Exception ("Message length " + msgLength + " exceeds maximum allowed " + Protocol.MaxMessageLength + " bytes"); header = new byte[16 + toRead]; Array.Copy (hbuf, header, 16); read = ns.Read (header, 16, toRead); if (read != toRead) throw new Exception ("Message header length mismatch: " + read + " of expected " + toRead); //read the body if (bodyLen != 0) { body = new byte[bodyLen]; read = ns.Read (body, 0, bodyLen); if (read != bodyLen) throw new Exception ("Message body length mismatch: " + read + " of expected " + bodyLen); } Message msg = new Message (); msg.Connection = this; msg.Body = body; msg.SetHeaderData (header); return msg; } //temporary hack internal void DispatchSignals () { lock (Inbound) { while (Inbound.Count != 0) { Message msg = Inbound.Dequeue (); HandleSignal (msg); } } } internal Thread mainThread = Thread.CurrentThread; //temporary hack public void Iterate () { mainThread = Thread.CurrentThread; //Message msg = Inbound.Dequeue (); Message msg = ReadMessage (); HandleMessage (msg); DispatchSignals (); } internal void HandleMessage (Message msg) { //TODO: support disconnection situations properly and move this check elsewhere if (msg == null) throw new ArgumentNullException ("msg", "Cannot handle a null message; maybe the bus was disconnected"); { object field_value; if (msg.Header.Fields.TryGetValue (FieldCode.ReplySerial, out field_value)) { uint reply_serial = (uint)field_value; PendingCall pending; if (pendingCalls.TryGetValue (reply_serial, out pending)) { if (pendingCalls.Remove (reply_serial)) pending.Reply = msg; return; } //we discard reply messages with no corresponding PendingCall if (Protocol.Verbose) Console.Error.WriteLine ("Unexpected reply message received: MessageType='" + msg.Header.MessageType + "', ReplySerial=" + reply_serial); return; } } switch (msg.Header.MessageType) { case MessageType.MethodCall: MethodCall method_call = new MethodCall (msg); HandleMethodCall (method_call); break; case MessageType.Signal: //HandleSignal (msg); lock (Inbound) Inbound.Enqueue (msg); break; case MessageType.Error: //TODO: better exception handling Error error = new Error (msg); string errMsg = String.Empty; if (msg.Signature.Value.StartsWith ("s")) { MessageReader reader = new MessageReader (msg); errMsg = reader.ReadString (); } //throw new Exception ("Remote Error: Signature='" + msg.Signature.Value + "' " + error.ErrorName + ": " + errMsg); //if (Protocol.Verbose) Console.Error.WriteLine ("Remote Error: Signature='" + msg.Signature.Value + "' " + error.ErrorName + ": " + errMsg); break; case MessageType.Invalid: default: throw new Exception ("Invalid message received: MessageType='" + msg.Header.MessageType + "'"); } } Dictionary pendingCalls = new Dictionary (); //this might need reworking with MulticastDelegate internal void HandleSignal (Message msg) { Signal signal = new Signal (msg); //TODO: this is a hack, not necessary when MatchRule is complete MatchRule rule = new MatchRule (); rule.MessageType = MessageType.Signal; rule.Interface = signal.Interface; rule.Member = signal.Member; rule.Path = signal.Path; Delegate dlg; if (Handlers.TryGetValue (rule, out dlg)) { //dlg.DynamicInvoke (GetDynamicValues (msg)); MethodInfo mi = dlg.Method; //signals have no return value dlg.DynamicInvoke (MessageHelper.GetDynamicValues (msg, mi.GetParameters ())); } else { //TODO: how should we handle this condition? sending an Error may not be appropriate in this case if (Protocol.Verbose) Console.Error.WriteLine ("Warning: No signal handler for " + signal.Member); } } internal Dictionary Handlers = new Dictionary (); //very messy internal void MaybeSendUnknownMethodError (MethodCall method_call) { Message msg = MessageHelper.CreateUnknownMethodError (method_call); if (msg != null) Send (msg); } //not particularly efficient and needs to be generalized internal void HandleMethodCall (MethodCall method_call) { //TODO: Ping and Introspect need to be abstracted and moved somewhere more appropriate once message filter infrastructure is complete //FIXME: these special cases are slightly broken for the case where the member but not the interface is specified in the message if (method_call.Interface == "org.freedesktop.DBus.Peer" && method_call.Member == "Ping") { Message reply = MessageHelper.ConstructReply (method_call); Send (reply); return; } if (method_call.Interface == "org.freedesktop.DBus.Introspectable" && method_call.Member == "Introspect") { Introspector intro = new Introspector (); intro.root_path = method_call.Path; intro.WriteStart (); //FIXME: do this properly //this is messy and inefficient List linkNodes = new List (); int depth = method_call.Path.Decomposed.Length; foreach (ObjectPath pth in RegisteredObjects.Keys) { if (pth.Value == (method_call.Path.Value)) { ExportObject exo = (ExportObject)RegisteredObjects[pth]; intro.WriteType (exo.obj.GetType ()); } else { for (ObjectPath cur = pth ; cur != null ; cur = cur.Parent) { if (cur.Value == method_call.Path.Value) { string linkNode = pth.Decomposed[depth]; if (!linkNodes.Contains (linkNode)) { intro.WriteNode (linkNode); linkNodes.Add (linkNode); } } } } } intro.WriteEnd (); Message reply = MessageHelper.ConstructReply (method_call, intro.xml); Send (reply); return; } BusObject bo; if (RegisteredObjects.TryGetValue (method_call.Path, out bo)) { ExportObject eo = (ExportObject)bo; eo.HandleMethodCall (method_call); } else { MaybeSendUnknownMethodError (method_call); } } Dictionary RegisteredObjects = new Dictionary (); //FIXME: this shouldn't be part of the core API //that also applies to much of the other object mapping code public object GetObject (Type type, string bus_name, ObjectPath path) { //if (type == null) // return GetObject (bus_name, path); //if the requested type is an interface, we can implement it efficiently //otherwise we fall back to using a transparent proxy if (type.IsInterface) { return BusObject.GetObject (this, bus_name, path, type); } else { if (Protocol.Verbose) Console.Error.WriteLine ("Warning: Note that MarshalByRefObject use is not recommended; for best performance, define interfaces"); BusObject busObject = new BusObject (this, bus_name, path); DProxy prox = new DProxy (busObject, type); return prox.GetTransparentProxy (); } } public T GetObject (string bus_name, ObjectPath path) { return (T)GetObject (typeof (T), bus_name, path); } [Obsolete ("Use the overload of Register() which does not take a bus_name parameter")] public void Register (string bus_name, ObjectPath path, object obj) { Register (path, obj); } [Obsolete ("Use the overload of Unregister() which does not take a bus_name parameter")] public object Unregister (string bus_name, ObjectPath path) { return Unregister (path); } public void Register (ObjectPath path, object obj) { ExportObject eo = new ExportObject (this, path, obj); eo.Registered = true; //TODO: implement some kind of tree data structure or internal object hierarchy. right now we are ignoring the name and putting all object paths in one namespace, which is bad RegisteredObjects[path] = eo; } public object Unregister (ObjectPath path) { BusObject bo; if (!RegisteredObjects.TryGetValue (path, out bo)) throw new Exception ("Cannot unregister " + path + " as it isn't registered"); RegisteredObjects.Remove (path); ExportObject eo = (ExportObject)bo; eo.Registered = false; return eo.obj; } //these look out of place, but are useful internal protected virtual void AddMatch (string rule) { } internal protected virtual void RemoveMatch (string rule) { } static Connection () { if (BitConverter.IsLittleEndian) NativeEndianness = EndianFlag.Little; else NativeEndianness = EndianFlag.Big; } internal static readonly EndianFlag NativeEndianness; } } aircrack-ng-1.6/lib/csharp/MonoExample/NDesk-dbus/DBus.cs000066400000000000000000000045451361312141100231370ustar00rootroot00000000000000// Copyright 2006 Alp Toker // This software is made available under the MIT License // See COPYING for details using System; using System.Collections.Generic; using NDesk.DBus; namespace org.freedesktop.DBus { [Flags] public enum NameFlag : uint { None = 0, AllowReplacement = 0x1, ReplaceExisting = 0x2, DoNotQueue = 0x4, } public enum RequestNameReply : uint { PrimaryOwner = 1, InQueue, Exists, AlreadyOwner, } public enum ReleaseNameReply : uint { Released = 1, NonExistent, NotOwner, } public enum StartReply : uint { //The service was successfully started. Success = 1, //A connection already owns the given name. AlreadyRunning, } public delegate void NameOwnerChangedHandler (string name, string old_owner, string new_owner); public delegate void NameAcquiredHandler (string name); public delegate void NameLostHandler (string name); [Interface ("org.freedesktop.DBus.Peer")] public interface Peer { void Ping (); [return: Argument ("machine_uuid")] string GetMachineId (); } [Interface ("org.freedesktop.DBus.Introspectable")] public interface Introspectable { [return: Argument ("data")] string Introspect (); } [Interface ("org.freedesktop.DBus.Properties")] public interface Properties { [return: Argument ("value")] object Get (string @interface, string propname); void Set (string @interface, string propname, object value); [return: Argument ("props")] IDictionary GetAll(string @interface); } [Interface ("org.freedesktop.DBus")] public interface IBus : Introspectable { RequestNameReply RequestName (string name, NameFlag flags); ReleaseNameReply ReleaseName (string name); string Hello (); string[] ListNames (); string[] ListActivatableNames (); bool NameHasOwner (string name); event NameOwnerChangedHandler NameOwnerChanged; event NameLostHandler NameLost; event NameAcquiredHandler NameAcquired; StartReply StartServiceByName (string name, uint flags); string GetNameOwner (string name); uint GetConnectionUnixUser (string connection_name); void AddMatch (string rule); void RemoveMatch (string rule); //undocumented in spec string[] ListQueuedOwners (string name); uint GetConnectionUnixProcessID (string connection_name); byte[] GetConnectionSELinuxSecurityContext (string connection_name); void ReloadConfig (); } } aircrack-ng-1.6/lib/csharp/MonoExample/NDesk-dbus/DProxy.cs000066400000000000000000000047051361312141100235250ustar00rootroot00000000000000// Copyright 2006 Alp Toker // This software is made available under the MIT License // See COPYING for details using System; using System.Reflection; using System.Runtime.Remoting.Proxies; using System.Runtime.Remoting.Messaging; namespace NDesk.DBus { //marked internal because this is really an implementation detail and needs to be replaced internal class DProxy : RealProxy { protected BusObject busObject; public DProxy (BusObject busObject, Type type) : base(type) { this.busObject = busObject; } static MethodInfo mi_GetHashCode = typeof (object).GetMethod ("GetHashCode"); static MethodInfo mi_Equals = typeof (object).GetMethod ("Equals", BindingFlags.Instance); static MethodInfo mi_ToString = typeof (object).GetMethod ("ToString"); static MethodInfo mi_GetLifetimeService = typeof (MarshalByRefObject).GetMethod ("GetLifetimeService"); object GetDefaultReturn (MethodBase mi, object[] inArgs) { if (mi == mi_GetHashCode) return busObject.Path.Value.GetHashCode (); if (mi == mi_Equals) return busObject.Path.Value == ((BusObject)((MarshalByRefObject)inArgs[0]).GetLifetimeService ()).Path.Value; if (mi == mi_ToString) return busObject.Path.Value; if (mi == mi_GetLifetimeService) return busObject; return null; } public override IMessage Invoke (IMessage message) { IMethodCallMessage callMessage = (IMethodCallMessage) message; object defaultRetVal = GetDefaultReturn (callMessage.MethodBase, callMessage.InArgs); if (defaultRetVal != null) { MethodReturnMessageWrapper defaultReturnMessage = new MethodReturnMessageWrapper ((IMethodReturnMessage) message); defaultReturnMessage.ReturnValue = defaultRetVal; return defaultReturnMessage; } object[] outArgs; object retVal; Exception exception; busObject.Invoke (callMessage.MethodBase, callMessage.MethodName, callMessage.InArgs, out outArgs, out retVal, out exception); MethodReturnMessageWrapper returnMessage = new MethodReturnMessageWrapper ((IMethodReturnMessage) message); returnMessage.Exception = exception; returnMessage.ReturnValue = retVal; return returnMessage; } /* public override ObjRef CreateObjRef (Type ServerType) { throw new System.NotImplementedException (); } */ ~DProxy () { //FIXME: remove handlers/match rules here if (Protocol.Verbose) Console.Error.WriteLine ("Warning: Finalization of " + busObject.Path + " not yet supported"); } } } aircrack-ng-1.6/lib/csharp/MonoExample/NDesk-dbus/ExportObject.cs000066400000000000000000000052511361312141100247050ustar00rootroot00000000000000// Copyright 2006 Alp Toker // This software is made available under the MIT License // See COPYING for details using System; using System.Reflection; using System.Reflection.Emit; using org.freedesktop.DBus; namespace NDesk.DBus { //TODO: perhaps ExportObject should not derive from BusObject internal class ExportObject : BusObject //, Peer { public readonly object obj; public ExportObject (Connection conn, ObjectPath object_path, object obj) : base (conn, null, object_path) { this.obj = obj; } //maybe add checks to make sure this is not called more than once //it's a bit silly as a property public bool Registered { set { Type type = obj.GetType (); foreach (MemberInfo mi in Mapper.GetPublicMembers (type)) { EventInfo ei = mi as EventInfo; if (ei == null) continue; Delegate dlg = GetHookupDelegate (ei); if (value) ei.AddEventHandler (obj, dlg); else ei.RemoveEventHandler (obj, dlg); } } } public void HandleMethodCall (MethodCall method_call) { Type type = obj.GetType (); //object retObj = type.InvokeMember (msg.Member, BindingFlags.InvokeMethod, null, obj, MessageHelper.GetDynamicValues (msg)); //TODO: there is no member name mapping for properties etc. yet MethodInfo mi = Mapper.GetMethod (type, method_call); if (mi == null) { conn.MaybeSendUnknownMethodError (method_call); return; } object retObj = null; object[] parmValues = MessageHelper.GetDynamicValues (method_call.message, mi.GetParameters ()); try { retObj = mi.Invoke (obj, parmValues); } catch (TargetInvocationException e) { if (!method_call.message.ReplyExpected) return; Exception ie = e.InnerException; //TODO: complete exception sending support Error error = new Error (Mapper.GetInterfaceName (ie.GetType ()), method_call.message.Header.Serial); error.message.Signature = new Signature (DType.String); MessageWriter writer = new MessageWriter (Connection.NativeEndianness); writer.connection = conn; writer.Write (ie.Message); error.message.Body = writer.ToArray (); //TODO: we should be more strict here, but this fallback was added as a quick fix for p2p if (method_call.Sender != null) error.message.Header.Fields[FieldCode.Destination] = method_call.Sender; conn.Send (error.message); return; } if (method_call.message.ReplyExpected) { Message reply = MessageHelper.ConstructDynamicReply (method_call, mi, retObj, parmValues); conn.Send (reply); } } /* public void Ping () { } public string GetMachineId () { //TODO: implement this return String.Empty; } */ } } aircrack-ng-1.6/lib/csharp/MonoExample/NDesk-dbus/Introspection.cs000066400000000000000000000223111361312141100251310ustar00rootroot00000000000000// Copyright 2006 Alp Toker // This software is made available under the MIT License // See COPYING for details using System; using System.Collections.Generic; using System.IO; using System.Xml; using System.Text; using System.Reflection; namespace NDesk.DBus { //TODO: complete this class class Introspector { const string NAMESPACE = "http://www.freedesktop.org/standards/dbus"; const string PUBLIC_IDENTIFIER = "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"; const string SYSTEM_IDENTIFIER = "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"; public StringBuilder sb; public string xml; public ObjectPath root_path = ObjectPath.Root; protected XmlWriter writer; public Introspector () { XmlWriterSettings settings = new XmlWriterSettings (); settings.Indent = true; settings.IndentChars = (" "); settings.OmitXmlDeclaration = true; sb = new StringBuilder (); writer = XmlWriter.Create (sb, settings); } static string GetProductDescription () { String version; Assembly assembly = Assembly.GetExecutingAssembly (); AssemblyName aname = assembly.GetName (); AssemblyInformationalVersionAttribute iversion = Attribute.GetCustomAttribute (assembly, typeof (AssemblyInformationalVersionAttribute)) as AssemblyInformationalVersionAttribute; if (iversion != null) version = iversion.InformationalVersion; else version = aname.Version.ToString (); return aname.Name + " " + version; } public void WriteStart () { writer.WriteDocType ("node", PUBLIC_IDENTIFIER, SYSTEM_IDENTIFIER, null); writer.WriteComment (" " + GetProductDescription () + " "); //the root node element writer.WriteStartElement ("node"); } public void WriteNode (string name) { writer.WriteStartElement ("node"); writer.WriteAttributeString ("name", name); writer.WriteEndElement (); } public void WriteEnd () { /* WriteEnum (typeof (org.freedesktop.DBus.NameFlag)); WriteEnum (typeof (org.freedesktop.DBus.NameReply)); WriteEnum (typeof (org.freedesktop.DBus.ReleaseNameReply)); WriteEnum (typeof (org.freedesktop.DBus.StartReply)); WriteInterface (typeof (org.freedesktop.DBus.IBus)); */ writer.WriteEndElement (); writer.Flush (); xml = sb.ToString (); } //public void WriteNode () public void WriteType (Type target_type) { //writer.WriteStartElement ("node"); //TODO: non-well-known introspection has paths as well, which we don't do yet. read the spec again //hackishly just remove the root '/' to make the path relative for now //writer.WriteAttributeString ("name", target_path.Value.Substring (1)); //writer.WriteAttributeString ("name", "test"); //reflect our own interface manually WriteInterface (typeof (org.freedesktop.DBus.Introspectable)); //reflect the target interface if (target_type != null) { WriteInterface (target_type); foreach (Type ifType in target_type.GetInterfaces ()) WriteInterface (ifType); } //TODO: review recursion of interfaces and inheritance hierarchy //writer.WriteEndElement (); } public void WriteArg (ParameterInfo pi) { WriteArg (pi.ParameterType, Mapper.GetArgumentName (pi), pi.IsOut, false); } public void WriteArgReverse (ParameterInfo pi) { WriteArg (pi.ParameterType, Mapper.GetArgumentName (pi), pi.IsOut, true); } //TODO: clean up and get rid of reverse (or argIsOut) parm public void WriteArg (Type argType, string argName, bool argIsOut, bool reverse) { argType = argIsOut ? argType.GetElementType () : argType; if (argType == typeof (void)) return; writer.WriteStartElement ("arg"); if (!String.IsNullOrEmpty (argName)) writer.WriteAttributeString ("name", argName); //we can't rely on the default direction (qt-dbus requires a direction at time of writing), so we use a boolean to reverse the parameter direction and make it explicit if (argIsOut) writer.WriteAttributeString ("direction", !reverse ? "out" : "in"); else writer.WriteAttributeString ("direction", !reverse ? "in" : "out"); Signature sig = Signature.GetSig (argType); //TODO: avoid writing null (DType.Invalid) to the XML stream writer.WriteAttributeString ("type", sig.Value); //annotations aren't valid in an arg element, so this is disabled //if (argType.IsEnum) // WriteAnnotation ("org.ndesk.DBus.Enum", Mapper.GetInterfaceName (argType)); writer.WriteEndElement (); } public void WriteMethod (MethodInfo mi) { writer.WriteStartElement ("method"); writer.WriteAttributeString ("name", mi.Name); foreach (ParameterInfo pi in mi.GetParameters ()) WriteArg (pi); //Mono <= 1.1.13 doesn't support MethodInfo.ReturnParameter, so avoid it //WriteArgReverse (mi.ReturnParameter); WriteArg (mi.ReturnType, Mapper.GetArgumentName (mi.ReturnTypeCustomAttributes, "ret"), false, true); WriteAnnotations (mi); writer.WriteEndElement (); } public void WriteProperty (PropertyInfo pri) { //expose properties as dbus properties writer.WriteStartElement ("property"); writer.WriteAttributeString ("name", pri.Name); writer.WriteAttributeString ("type", Signature.GetSig (pri.PropertyType).Value); string access = (pri.CanRead ? "read" : String.Empty) + (pri.CanWrite ? "write" : String.Empty); writer.WriteAttributeString ("access", access); WriteAnnotations (pri); writer.WriteEndElement (); //expose properties as methods also //it may not be worth doing this in the long run /* if (pri.CanRead) { writer.WriteStartElement ("method"); writer.WriteAttributeString ("name", "Get" + pri.Name); WriteArgReverse (pri.GetGetMethod ().ReturnParameter); writer.WriteEndElement (); } if (pri.CanWrite) { writer.WriteStartElement ("method"); writer.WriteAttributeString ("name", "Set" + pri.Name); foreach (ParameterInfo pi in pri.GetSetMethod ().GetParameters ()) WriteArg (pi); writer.WriteEndElement (); } */ } public void WriteSignal (EventInfo ei) { writer.WriteStartElement ("signal"); writer.WriteAttributeString ("name", ei.Name); foreach (ParameterInfo pi in ei.EventHandlerType.GetMethod ("Invoke").GetParameters ()) WriteArgReverse (pi); WriteAnnotations (ei); //no need to consider the delegate return value as dbus doesn't support it writer.WriteEndElement (); } const BindingFlags relevantBindingFlags = BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly; public void WriteInterface (Type type) { if (type == null) return; //TODO: this is unreliable, fix it if (!Mapper.IsPublic (type)) return; writer.WriteStartElement ("interface"); writer.WriteAttributeString ("name", Mapper.GetInterfaceName (type)); /* foreach (MemberInfo mbi in type.GetMembers (relevantBindingFlags)) { switch (mbi.MemberType) { case MemberTypes.Method: if (!((MethodInfo)mbi).IsSpecialName) WriteMethod ((MethodInfo)mbi); break; case MemberTypes.Event: WriteSignal ((EventInfo)mbi); break; case MemberTypes.Property: WriteProperty ((PropertyInfo)mbi); break; default: Console.Error.WriteLine ("Warning: Unhandled MemberType '{0}' encountered while introspecting {1}", mbi.MemberType, type.FullName); break; } } */ foreach (MethodInfo mi in type.GetMethods (relevantBindingFlags)) if (!mi.IsSpecialName) WriteMethod (mi); foreach (EventInfo ei in type.GetEvents (relevantBindingFlags)) WriteSignal (ei); foreach (PropertyInfo pri in type.GetProperties (relevantBindingFlags)) WriteProperty (pri); //TODO: indexers //TODO: attributes as annotations? writer.WriteEndElement (); //this recursion seems somewhat inelegant WriteInterface (type.BaseType); } public void WriteAnnotations (ICustomAttributeProvider attrProvider) { if (Mapper.IsDeprecated (attrProvider)) WriteAnnotation ("org.freedesktop.DBus.Deprecated", "true"); } public void WriteAnnotation (string name, string value) { writer.WriteStartElement ("annotation"); writer.WriteAttributeString ("name", name); writer.WriteAttributeString ("value", value); writer.WriteEndElement (); } //this is not in the spec, and is not finalized public void WriteEnum (Type type) { writer.WriteStartElement ("enum"); writer.WriteAttributeString ("name", Mapper.GetInterfaceName (type)); writer.WriteAttributeString ("type", Signature.GetSig (type.GetElementType ()).Value); writer.WriteAttributeString ("flags", (type.IsDefined (typeof (FlagsAttribute), false)) ? "true" : "false"); string[] names = Enum.GetNames (type); int i = 0; foreach (Enum val in Enum.GetValues (type)) { writer.WriteStartElement ("element"); writer.WriteAttributeString ("name", names[i++]); writer.WriteAttributeString ("value", val.ToString ("d")); writer.WriteEndElement (); } writer.WriteEndElement (); } } } aircrack-ng-1.6/lib/csharp/MonoExample/NDesk-dbus/Mapper.cs000066400000000000000000000253401361312141100235220ustar00rootroot00000000000000// Copyright 2006 Alp Toker // This software is made available under the MIT License // See COPYING for details using System; using System.Collections.Generic; using System.Reflection; namespace NDesk.DBus { static class Mapper { //TODO: move these Get*Name helpers somewhere more appropriate public static string GetArgumentName (ParameterInfo pi) { string argName = pi.Name; if (pi.IsRetval && String.IsNullOrEmpty (argName)) argName = "ret"; return GetArgumentName ((ICustomAttributeProvider)pi, argName); } public static string GetArgumentName (ICustomAttributeProvider attrProvider, string defaultName) { string argName = defaultName; //TODO: no need for foreach foreach (ArgumentAttribute aa in attrProvider.GetCustomAttributes (typeof (ArgumentAttribute), true)) argName = aa.Name; return argName; } //TODO: these two methods are quite messy and need review public static IEnumerable GetPublicMembers (Type type) { //note that Type.GetInterfaces() returns all interfaces with flattened hierarchy foreach (Type ifType in type.GetInterfaces ()) foreach (MemberInfo mi in GetDeclaredPublicMembers (ifType)) yield return mi; if (IsPublic (type)) foreach (MemberInfo mi in GetDeclaredPublicMembers (type)) yield return mi; } static IEnumerable GetDeclaredPublicMembers (Type type) { if (IsPublic (type)) foreach (MemberInfo mi in type.GetMembers (BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly)) yield return mi; } //this method walks the interface tree in an undefined manner and returns the first match, or if no matches are found, null //the logic needs review and cleanup //TODO: unify member name mapping as is already done with interfaces and args public static MethodInfo GetMethod (Type type, MethodCall method_call) { foreach (MemberInfo member in Mapper.GetPublicMembers (type)) { //this could be made more efficient by using the given interface name earlier and avoiding walking through all public interfaces if (method_call.Interface != null) if (GetInterfaceName (member) != method_call.Interface) continue; MethodInfo meth = null; Type[] inTypes = null; if (member is PropertyInfo) { PropertyInfo prop = member as PropertyInfo; MethodInfo getter = prop.GetGetMethod (false); MethodInfo setter = prop.GetSetMethod (false); if (getter != null && "Get" + prop.Name == method_call.Member) { meth = getter; inTypes = Type.EmptyTypes; } else if (setter != null && "Set" + prop.Name == method_call.Member) { meth = setter; inTypes = new Type[] {prop.PropertyType}; } } else { meth = member as MethodInfo; if (meth == null) continue; if (meth.Name != method_call.Member) continue; inTypes = Mapper.GetTypes (ArgDirection.In, meth.GetParameters ()); } if (meth == null || inTypes == null) continue; Signature inSig = Signature.GetSig (inTypes); if (inSig != method_call.Signature) continue; return meth; } return null; } public static bool IsPublic (MemberInfo mi) { return IsPublic (mi.DeclaringType); } public static bool IsPublic (Type type) { //we need to have a proper look at what's really public at some point //this will do for now if (type.IsDefined (typeof (InterfaceAttribute), false)) return true; if (type.IsSubclassOf (typeof (MarshalByRefObject))) return true; return false; } public static string GetInterfaceName (MemberInfo mi) { return GetInterfaceName (mi.DeclaringType); } public static string GetInterfaceName (Type type) { string interfaceName = type.FullName; //TODO: better fallbacks and namespace mangling when no InterfaceAttribute is available //TODO: no need for foreach foreach (InterfaceAttribute ia in type.GetCustomAttributes (typeof (InterfaceAttribute), true)) interfaceName = ia.Name; return interfaceName; } public static Type[] GetTypes (ArgDirection dir, ParameterInfo[] parms) { List types = new List (); //TODO: consider InOut/Ref for (int i = 0 ; i != parms.Length ; i++) { switch (dir) { case ArgDirection.In: //docs say IsIn isn't reliable, and this is indeed true //if (parms[i].IsIn) if (!parms[i].IsOut) types.Add (parms[i].ParameterType); break; case ArgDirection.Out: if (parms[i].IsOut) { //TODO: note that IsOut is optional to the compiler, we may want to use IsByRef instead //eg: if (parms[i].ParameterType.IsByRef) types.Add (parms[i].ParameterType.GetElementType ()); } break; } } return types.ToArray (); } public static bool IsDeprecated (ICustomAttributeProvider attrProvider) { return attrProvider.IsDefined (typeof (ObsoleteAttribute), true); } static bool AreEqual (Type[] a, Type[] b) { if (a.Length != b.Length) return false; for (int i = 0 ; i != a.Length ; i++) if (a[i] != b[i]) return false; return true; } //workaround for Mono bug #81035 (memory leak) static List genTypes = new List (); internal static Type GetGenericType (Type defType, Type[] parms) { foreach (Type genType in genTypes) { if (genType.GetGenericTypeDefinition () != defType) continue; Type[] genParms = genType.GetGenericArguments (); if (!AreEqual (genParms, parms)) continue; return genType; } Type type = defType.MakeGenericType (parms); genTypes.Add (type); return type; } } //TODO: this class is messy, move the methods somewhere more appropriate static class MessageHelper { public static Message CreateUnknownMethodError (MethodCall method_call) { if (!method_call.message.ReplyExpected) return null; string errMsg = String.Format ("Method \"{0}\" with signature \"{1}\" on interface \"{2}\" doesn't exist", method_call.Member, method_call.Signature.Value, method_call.Interface); Error error = new Error ("org.freedesktop.DBus.Error.UnknownMethod", method_call.message.Header.Serial); error.message.Signature = new Signature (DType.String); MessageWriter writer = new MessageWriter (Connection.NativeEndianness); writer.Write (errMsg); error.message.Body = writer.ToArray (); //TODO: we should be more strict here, but this fallback was added as a quick fix for p2p if (method_call.Sender != null) error.message.Header.Fields[FieldCode.Destination] = method_call.Sender; return error.message; } public static void WriteDynamicValues (MessageWriter mw, ParameterInfo[] parms, object[] vals) { foreach (ParameterInfo parm in parms) { if (!parm.IsOut) continue; Type actualType = parm.ParameterType.GetElementType (); mw.Write (actualType, vals[parm.Position]); } } public static object[] GetDynamicValues (Message msg, ParameterInfo[] parms) { //TODO: this validation check should provide better information, eg. message dump or a stack trace, or at least the interface/member /* if (Protocol.Verbose) { Signature expected = Signature.GetSig (types); Signature actual = msg.Signature; if (actual != expected) Console.Error.WriteLine ("Warning: The signature of the message does not match that of the handler: " + "Expected '" + expected + "', got '" + actual + "'"); } */ object[] vals = new object[parms.Length]; if (msg.Body != null) { MessageReader reader = new MessageReader (msg); foreach (ParameterInfo parm in parms) { if (parm.IsOut) continue; vals[parm.Position] = reader.ReadValue (parm.ParameterType); } } return vals; } public static object[] GetDynamicValues (Message msg, Type[] types) { //TODO: this validation check should provide better information, eg. message dump or a stack trace, or at least the interface/member if (Protocol.Verbose) { Signature expected = Signature.GetSig (types); Signature actual = msg.Signature; if (actual != expected) Console.Error.WriteLine ("Warning: The signature of the message does not match that of the handler: " + "Expected '" + expected + "', got '" + actual + "'"); } object[] vals = new object[types.Length]; if (msg.Body != null) { MessageReader reader = new MessageReader (msg); for (int i = 0 ; i != types.Length ; i++) vals[i] = reader.ReadValue (types[i]); } return vals; } public static Message ConstructReply (MethodCall method_call, params object[] vals) { MethodReturn method_return = new MethodReturn (method_call.message.Header.Serial); Message replyMsg = method_return.message; Signature inSig = Signature.GetSig (vals); if (vals != null && vals.Length != 0) { MessageWriter writer = new MessageWriter (Connection.NativeEndianness); foreach (object arg in vals) writer.Write (arg.GetType (), arg); replyMsg.Body = writer.ToArray (); } //TODO: we should be more strict here, but this fallback was added as a quick fix for p2p if (method_call.Sender != null) replyMsg.Header.Fields[FieldCode.Destination] = method_call.Sender; replyMsg.Signature = inSig; //replyMsg.WriteHeader (); return replyMsg; } public static Message ConstructDynamicReply (MethodCall method_call, MethodInfo mi, object retVal, object[] vals) { Type retType = mi.ReturnType; MethodReturn method_return = new MethodReturn (method_call.message.Header.Serial); Message replyMsg = method_return.message; Signature outSig = Signature.GetSig (retType); outSig += Signature.GetSig (Mapper.GetTypes (ArgDirection.Out, mi.GetParameters ())); if (outSig != Signature.Empty) { MessageWriter writer = new MessageWriter (Connection.NativeEndianness); //first write the return value, if any if (retType != null && retType != typeof (void)) writer.Write (retType, retVal); //then write the out args WriteDynamicValues (writer, mi.GetParameters (), vals); replyMsg.Body = writer.ToArray (); } //TODO: we should be more strict here, but this fallback was added as a quick fix for p2p if (method_call.Sender != null) replyMsg.Header.Fields[FieldCode.Destination] = method_call.Sender; replyMsg.Signature = outSig; return replyMsg; } } [AttributeUsage (AttributeTargets.Interface | AttributeTargets.Class, AllowMultiple=false, Inherited=true)] public class InterfaceAttribute : Attribute { public string Name; public InterfaceAttribute (string name) { this.Name = name; } } [AttributeUsage (AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple=false, Inherited=true)] public class ArgumentAttribute : Attribute { public string Name; public ArgumentAttribute (string name) { this.Name = name; } } } aircrack-ng-1.6/lib/csharp/MonoExample/NDesk-dbus/MatchRule.cs000066400000000000000000000120761361312141100241640ustar00rootroot00000000000000// Copyright 2007 Alp Toker // This software is made available under the MIT License // See COPYING for details using System; using System.Text; using System.Collections.Generic; namespace NDesk.DBus { //delegate void MessageHandler (Message msg); class MatchRule { public MessageType? MessageType; public string Interface; public string Member; public ObjectPath Path; public string Sender; public string Destination; public readonly SortedDictionary Args = new SortedDictionary (); public MatchRule () { } void Append (StringBuilder sb, string key, string value) { if (sb.Length != 0) sb.Append (","); sb.Append (key + "='"); sb.Append (value); sb.Append ("'"); } void AppendArg (StringBuilder sb, int index, string value) { Append (sb, "arg" + index, value); } public override bool Equals (object o) { MatchRule r = o as MatchRule; if (r == null) return false; if (r.MessageType != MessageType) return false; if (r.Interface != Interface) return false; if (r.Member != Member) return false; //TODO: see why path comparison doesn't work if (r.Path.Value != Path.Value) //if (r.Path != Path) return false; if (r.Sender != Sender) return false; if (r.Destination != Destination) return false; //FIXME: do args return true; } public override int GetHashCode () { //FIXME: not at all optimal return ToString ().GetHashCode (); } public override string ToString () { StringBuilder sb = new StringBuilder (); if (MessageType != null) Append (sb, "type", MessageFilter.MessageTypeToString ((MessageType)MessageType)); if (Interface != null) Append (sb, "interface", Interface); if (Member != null) Append (sb, "member", Member); if (Path != null) //Append (sb, "path", Path.ToString ()); Append (sb, "path", Path.Value); if (Sender != null) Append (sb, "sender", Sender); if (Destination != null) Append (sb, "destination", Destination); if (Args != null) { foreach (KeyValuePair pair in Args) AppendArg (sb, pair.Key, pair.Value); } return sb.ToString (); } //this is useful as a Predicate delegate public bool Matches (Message msg) { if (MessageType != null) if (msg.Header.MessageType != MessageType) return false; object value; if (Interface != null) if (msg.Header.Fields.TryGetValue (FieldCode.Interface, out value)) if ((string)value != Interface) return false; if (Member != null) if (msg.Header.Fields.TryGetValue (FieldCode.Member, out value)) if ((string)value != Member) return false; if (Path != null) if (msg.Header.Fields.TryGetValue (FieldCode.Path, out value)) //if ((ObjectPath)value != Path) if (((ObjectPath)value).Value != Path.Value) return false; if (Sender != null) if (msg.Header.Fields.TryGetValue (FieldCode.Sender, out value)) if ((string)value != Sender) return false; if (Destination != null) if (msg.Header.Fields.TryGetValue (FieldCode.Destination, out value)) if ((string)value != Destination) return false; //FIXME: do args return true; } //this could be made more efficient public static MatchRule Parse (string text) { MatchRule r = new MatchRule (); foreach (string propStr in text.Split (',')) { string[] parts = propStr.Split ('='); if (parts.Length < 2) throw new Exception ("No equals sign found"); if (parts.Length > 2) throw new Exception ("Too many equals signs found"); string key = parts[0].Trim (); string value = parts[1].Trim (); if (!value.StartsWith ("'") || !value.EndsWith ("'")) throw new Exception ("Too many equals signs found"); value = value.Substring (1, value.Length - 2); if (key.StartsWith ("arg")) { int argnum = Int32.Parse (key.Remove (0, "arg".Length)); if (argnum < 0 || argnum > 63) throw new Exception ("arg match must be between 0 and 63 inclusive"); if (r.Args.ContainsKey (argnum)) return null; r.Args[argnum] = value; continue; } //TODO: more consistent error handling switch (key) { case "type": if (r.MessageType != null) return null; r.MessageType = MessageFilter.StringToMessageType (value); break; case "interface": if (r.Interface != null) return null; r.Interface = value; break; case "member": if (r.Member != null) return null; r.Member = value; break; case "path": if (r.Path != null) return null; r.Path = new ObjectPath (value); break; case "sender": if (r.Sender != null) return null; r.Sender = value; break; case "destination": if (r.Destination != null) return null; r.Destination = value; break; default: if (Protocol.Verbose) Console.Error.WriteLine ("Warning: Unrecognized match rule key: " + key); break; } } return r; } } } aircrack-ng-1.6/lib/csharp/MonoExample/NDesk-dbus/Message.cs000066400000000000000000000036731361312141100236670ustar00rootroot00000000000000// Copyright 2006 Alp Toker // This software is made available under the MIT License // See COPYING for details using System; using System.Collections.Generic; using System.IO; namespace NDesk.DBus { class Message { public Message () { Header.Endianness = Connection.NativeEndianness; Header.MessageType = MessageType.MethodCall; Header.Flags = HeaderFlag.NoReplyExpected; //TODO: is this the right place to do this? Header.MajorVersion = Protocol.Version; Header.Fields = new Dictionary (); } public Header Header; public Connection Connection; public Signature Signature { get { object o; if (Header.Fields.TryGetValue (FieldCode.Signature, out o)) return (Signature)o; else return Signature.Empty; } set { if (value == Signature.Empty) Header.Fields.Remove (FieldCode.Signature); else Header.Fields[FieldCode.Signature] = value; } } public bool ReplyExpected { get { return (Header.Flags & HeaderFlag.NoReplyExpected) == HeaderFlag.None; } set { if (value) Header.Flags &= ~HeaderFlag.NoReplyExpected; //flag off else Header.Flags |= HeaderFlag.NoReplyExpected; //flag on } } //public HeaderField[] HeaderFields; //public Dictionary; public byte[] Body; //TODO: make use of Locked /* protected bool locked = false; public bool Locked { get { return locked; } } */ public void SetHeaderData (byte[] data) { EndianFlag endianness = (EndianFlag)data[0]; MessageReader reader = new MessageReader (endianness, data); Header = (Header)reader.ReadStruct (typeof (Header)); } public byte[] GetHeaderData () { if (Body != null) Header.Length = (uint)Body.Length; MessageWriter writer = new MessageWriter (Header.Endianness); writer.WriteValueType (Header, typeof (Header)); writer.CloseWrite (); return writer.ToArray (); } } } aircrack-ng-1.6/lib/csharp/MonoExample/NDesk-dbus/MessageFilter.cs000066400000000000000000000025561361312141100250340ustar00rootroot00000000000000// Copyright 2006 Alp Toker // This software is made available under the MIT License // See COPYING for details using System; namespace NDesk.DBus { class MessageFilter { //this should probably be made to use HeaderField or similar //this class is not generalized yet public static string MessageTypeToString (MessageType mtype) { switch (mtype) { case MessageType.MethodCall: return "method_call"; case MessageType.MethodReturn: return "method_return"; case MessageType.Error: return "error"; case MessageType.Signal: return "signal"; case MessageType.Invalid: return "invalid"; default: throw new Exception ("Bad MessageType: " + mtype); } } public static MessageType StringToMessageType (string text) { switch (text) { case "method_call": return MessageType.MethodCall; case "method_return": return MessageType.MethodReturn; case "error": return MessageType.Error; case "signal": return MessageType.Signal; case "invalid": return MessageType.Invalid; default: throw new Exception ("Bad MessageType: " + text); } } //TODO: remove this -- left here for the benefit of the monitor tool for now public static string CreateMatchRule (MessageType mtype) { return "type='" + MessageTypeToString (mtype) + "'"; } } } aircrack-ng-1.6/lib/csharp/MonoExample/NDesk-dbus/MessageReader.cs000066400000000000000000000223451361312141100250070ustar00rootroot00000000000000// Copyright 2006 Alp Toker // This software is made available under the MIT License // See COPYING for details using System; using System.Text; using System.Collections.Generic; using System.IO; using System.Reflection; namespace NDesk.DBus { class MessageReader { protected EndianFlag endianness; protected byte[] data; //TODO: this should be uint or long to handle long messages protected int pos = 0; protected Message message; public MessageReader (EndianFlag endianness, byte[] data) { if (data == null) throw new ArgumentNullException ("data"); this.endianness = endianness; this.data = data; } public MessageReader (Message message) : this (message.Header.Endianness, message.Body) { if (message == null) throw new ArgumentNullException ("message"); this.message = message; } public object ReadValue (Type type) { if (type == typeof (void)) return null; if (type.IsArray) { return ReadArray (type.GetElementType ()); } else if (type == typeof (ObjectPath)) { return ReadObjectPath (); } else if (type == typeof (Signature)) { return ReadSignature (); } else if (type == typeof (object)) { return ReadVariant (); } else if (type == typeof (string)) { return ReadString (); } else if (type.IsGenericType && type.GetGenericTypeDefinition () == typeof (IDictionary<,>)) { Type[] genArgs = type.GetGenericArguments (); //Type dictType = typeof (Dictionary<,>).MakeGenericType (genArgs); //workaround for Mono bug #81035 (memory leak) Type dictType = Mapper.GetGenericType (typeof (Dictionary<,>), genArgs); System.Collections.IDictionary idict = (System.Collections.IDictionary)Activator.CreateInstance(dictType, new object[0]); GetValueToDict (genArgs[0], genArgs[1], idict); return idict; } else if (Mapper.IsPublic (type)) { return GetObject (type); } else if (!type.IsPrimitive && !type.IsEnum) { return ReadStruct (type); } else { object val; DType dtype = Signature.TypeToDType (type); val = ReadValue (dtype); if (type.IsEnum) val = Enum.ToObject (type, val); return val; } } //helper method, should not be used generally public object ReadValue (DType dtype) { switch (dtype) { case DType.Byte: return ReadByte (); case DType.Boolean: return ReadBoolean (); case DType.Int16: return ReadInt16 (); case DType.UInt16: return ReadUInt16 (); case DType.Int32: return ReadInt32 (); case DType.UInt32: return ReadUInt32 (); case DType.Int64: return ReadInt64 (); case DType.UInt64: return ReadUInt64 (); #if !DISABLE_SINGLE case DType.Single: return ReadSingle (); #endif case DType.Double: return ReadDouble (); case DType.String: return ReadString (); case DType.ObjectPath: return ReadObjectPath (); case DType.Signature: return ReadSignature (); case DType.Variant: return ReadVariant (); default: throw new Exception ("Unhandled D-Bus type: " + dtype); } } public object GetObject (Type type) { ObjectPath path = ReadObjectPath (); return message.Connection.GetObject (type, (string)message.Header.Fields[FieldCode.Sender], path); } public byte ReadByte () { return data[pos++]; } public bool ReadBoolean () { uint intval = ReadUInt32 (); switch (intval) { case 0: return false; case 1: return true; default: throw new Exception ("Read value " + intval + " at position " + pos + " while expecting boolean (0/1)"); } } unsafe protected void MarshalUShort (byte *dst) { ReadPad (2); if (endianness == Connection.NativeEndianness) { dst[0] = data[pos + 0]; dst[1] = data[pos + 1]; } else { dst[0] = data[pos + 1]; dst[1] = data[pos + 0]; } pos += 2; } unsafe public short ReadInt16 () { short val; MarshalUShort ((byte*)&val); return val; } unsafe public ushort ReadUInt16 () { ushort val; MarshalUShort ((byte*)&val); return val; } unsafe protected void MarshalUInt (byte *dst) { ReadPad (4); if (endianness == Connection.NativeEndianness) { dst[0] = data[pos + 0]; dst[1] = data[pos + 1]; dst[2] = data[pos + 2]; dst[3] = data[pos + 3]; } else { dst[0] = data[pos + 3]; dst[1] = data[pos + 2]; dst[2] = data[pos + 1]; dst[3] = data[pos + 0]; } pos += 4; } unsafe public int ReadInt32 () { int val; MarshalUInt ((byte*)&val); return val; } unsafe public uint ReadUInt32 () { uint val; MarshalUInt ((byte*)&val); return val; } unsafe protected void MarshalULong (byte *dst) { ReadPad (8); if (endianness == Connection.NativeEndianness) { for (int i = 0; i < 8; ++i) dst[i] = data[pos + i]; } else { for (int i = 0; i < 8; ++i) dst[i] = data[pos + (7 - i)]; } pos += 8; } unsafe public long ReadInt64 () { long val; MarshalULong ((byte*)&val); return val; } unsafe public ulong ReadUInt64 () { ulong val; MarshalULong ((byte*)&val); return val; } #if !DISABLE_SINGLE unsafe public float ReadSingle () { float val; MarshalUInt ((byte*)&val); return val; } #endif unsafe public double ReadDouble () { double val; MarshalULong ((byte*)&val); return val; } public string ReadString () { uint ln = ReadUInt32 (); string val = Encoding.UTF8.GetString (data, pos, (int)ln); pos += (int)ln; ReadNull (); return val; } public ObjectPath ReadObjectPath () { //exactly the same as string return new ObjectPath (ReadString ()); } public Signature ReadSignature () { byte ln = ReadByte (); if (ln > Protocol.MaxSignatureLength) throw new Exception ("Signature length " + ln + " exceeds maximum allowed " + Protocol.MaxSignatureLength + " bytes"); byte[] sigData = new byte[ln]; Array.Copy (data, pos, sigData, 0, (int)ln); pos += (int)ln; ReadNull (); return new Signature (sigData); } public object ReadVariant () { return ReadVariant (ReadSignature ()); } object ReadVariant (Signature sig) { return ReadValue (sig.ToType ()); } //not pretty or efficient but works public void GetValueToDict (Type keyType, Type valType, System.Collections.IDictionary val) { uint ln = ReadUInt32 (); if (ln > Protocol.MaxArrayLength) throw new Exception ("Dict length " + ln + " exceeds maximum allowed " + Protocol.MaxArrayLength + " bytes"); //advance to the alignment of the element //ReadPad (Protocol.GetAlignment (Signature.TypeToDType (type))); ReadPad (8); int endPos = pos + (int)ln; //while (stream.Position != endPos) while (pos < endPos) { ReadPad (8); val.Add (ReadValue (keyType), ReadValue (valType)); } if (pos != endPos) throw new Exception ("Read pos " + pos + " != ep " + endPos); } //this could be made generic to avoid boxing public Array ReadArray (Type elemType) { uint ln = ReadUInt32 (); if (ln > Protocol.MaxArrayLength) throw new Exception ("Array length " + ln + " exceeds maximum allowed " + Protocol.MaxArrayLength + " bytes"); //TODO: more fast paths for primitive arrays if (elemType == typeof (byte)) { byte[] valb = new byte[ln]; Array.Copy (data, pos, valb, 0, (int)ln); pos += (int)ln; return valb; } //advance to the alignment of the element ReadPad (Protocol.GetAlignment (Signature.TypeToDType (elemType))); int endPos = pos + (int)ln; //List vals = new List (); System.Collections.ArrayList vals = new System.Collections.ArrayList (); //while (stream.Position != endPos) while (pos < endPos) vals.Add (ReadValue (elemType)); if (pos != endPos) throw new Exception ("Read pos " + pos + " != ep " + endPos); return vals.ToArray (elemType); } //struct //probably the wrong place for this //there might be more elegant solutions public object ReadStruct (Type type) { ReadPad (8); object val = Activator.CreateInstance (type); /* if (type.IsGenericType && type.GetGenericTypeDefinition () == typeof (KeyValuePair<,>)) { object elem; System.Reflection.PropertyInfo key_prop = type.GetProperty ("Key"); GetValue (key_prop.PropertyType, out elem); key_prop.SetValue (val, elem, null); System.Reflection.PropertyInfo val_prop = type.GetProperty ("Value"); GetValue (val_prop.PropertyType, out elem); val_prop.SetValue (val, elem, null); return; } */ FieldInfo[] fis = type.GetFields (BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); foreach (System.Reflection.FieldInfo fi in fis) fi.SetValue (val, ReadValue (fi.FieldType)); return val; } public void ReadNull () { if (data[pos] != 0) throw new Exception ("Read non-zero byte at position " + pos + " while expecting null terminator"); pos++; } /* public void ReadPad (int alignment) { pos = Protocol.Padded (pos, alignment); } */ public void ReadPad (int alignment) { for (int endPos = Protocol.Padded (pos, alignment) ; pos != endPos ; pos++) if (data[pos] != 0) throw new Exception ("Read non-zero byte at position " + pos + " while expecting padding"); } } } aircrack-ng-1.6/lib/csharp/MonoExample/NDesk-dbus/MessageWriter.cs000066400000000000000000000241021361312141100250520ustar00rootroot00000000000000// Copyright 2006 Alp Toker // This software is made available under the MIT License // See COPYING for details using System; using System.Text; using System.Collections.Generic; using System.IO; using System.Reflection; namespace NDesk.DBus { class MessageWriter { protected EndianFlag endianness; protected MemoryStream stream; public Connection connection; //a default constructor is a bad idea for now as we want to make sure the header and content-type match public MessageWriter () : this (Connection.NativeEndianness) {} public MessageWriter (EndianFlag endianness) { this.endianness = endianness; stream = new MemoryStream (); } public byte[] ToArray () { //TODO: mark the writer locked or something here return stream.ToArray (); } public void CloseWrite () { int needed = Protocol.PadNeeded ((int)stream.Position, 8); for (int i = 0 ; i != needed ; i++) stream.WriteByte (0); } public void Write (byte val) { stream.WriteByte (val); } public void Write (bool val) { Write ((uint) (val ? 1 : 0)); } unsafe protected void MarshalUShort (byte *data) { WritePad (2); byte[] dst = new byte[2]; if (endianness == Connection.NativeEndianness) { dst[0] = data[0]; dst[1] = data[1]; } else { dst[0] = data[1]; dst[1] = data[0]; } stream.Write (dst, 0, 2); } unsafe public void Write (short val) { MarshalUShort ((byte*)&val); } unsafe public void Write (ushort val) { MarshalUShort ((byte*)&val); } unsafe protected void MarshalUInt (byte *data) { WritePad (4); byte[] dst = new byte[4]; if (endianness == Connection.NativeEndianness) { dst[0] = data[0]; dst[1] = data[1]; dst[2] = data[2]; dst[3] = data[3]; } else { dst[0] = data[3]; dst[1] = data[2]; dst[2] = data[1]; dst[3] = data[0]; } stream.Write (dst, 0, 4); } unsafe public void Write (int val) { MarshalUInt ((byte*)&val); } unsafe public void Write (uint val) { MarshalUInt ((byte*)&val); } unsafe protected void MarshalULong (byte *data) { WritePad (8); byte[] dst = new byte[8]; if (endianness == Connection.NativeEndianness) { for (int i = 0; i < 8; ++i) dst[i] = data[i]; } else { for (int i = 0; i < 8; ++i) dst[i] = data[7 - i]; } stream.Write (dst, 0, 8); } unsafe public void Write (long val) { MarshalULong ((byte*)&val); } unsafe public void Write (ulong val) { MarshalULong ((byte*)&val); } #if !DISABLE_SINGLE unsafe public void Write (float val) { MarshalUInt ((byte*)&val); } #endif unsafe public void Write (double val) { MarshalULong ((byte*)&val); } public void Write (string val) { byte[] utf8_data = Encoding.UTF8.GetBytes (val); Write ((uint)utf8_data.Length); stream.Write (utf8_data, 0, utf8_data.Length); WriteNull (); } public void Write (ObjectPath val) { Write (val.Value); } public void Write (Signature val) { byte[] ascii_data = val.GetBuffer (); if (ascii_data.Length > Protocol.MaxSignatureLength) throw new Exception ("Signature length " + ascii_data.Length + " exceeds maximum allowed " + Protocol.MaxSignatureLength + " bytes"); Write ((byte)ascii_data.Length); stream.Write (ascii_data, 0, ascii_data.Length); WriteNull (); } public void WriteComplex (object val, Type type) { if (type == typeof (void)) return; if (type.IsArray) { WriteArray (val, type.GetElementType ()); } else if (type.IsGenericType && (type.GetGenericTypeDefinition () == typeof (IDictionary<,>) || type.GetGenericTypeDefinition () == typeof (Dictionary<,>))) { Type[] genArgs = type.GetGenericArguments (); System.Collections.IDictionary idict = (System.Collections.IDictionary)val; WriteFromDict (genArgs[0], genArgs[1], idict); } else if (Mapper.IsPublic (type)) { WriteObject (type, val); } else if (!type.IsPrimitive && !type.IsEnum) { WriteValueType (val, type); /* } else if (type.IsGenericType && type.GetGenericTypeDefinition () == typeof (Nullable<>)) { //is it possible to support nullable types? Type[] genArgs = type.GetGenericArguments (); WriteVariant (genArgs[0], val); */ } else { throw new Exception ("Can't write"); } } public void Write (Type type, object val) { if (type == typeof (void)) return; if (type.IsArray) { WriteArray (val, type.GetElementType ()); } else if (type == typeof (ObjectPath)) { Write ((ObjectPath)val); } else if (type == typeof (Signature)) { Write ((Signature)val); } else if (type == typeof (object)) { Write (val); } else if (type == typeof (string)) { Write ((string)val); } else if (type.IsGenericType && (type.GetGenericTypeDefinition () == typeof (IDictionary<,>) || type.GetGenericTypeDefinition () == typeof (Dictionary<,>))) { Type[] genArgs = type.GetGenericArguments (); System.Collections.IDictionary idict = (System.Collections.IDictionary)val; WriteFromDict (genArgs[0], genArgs[1], idict); } else if (Mapper.IsPublic (type)) { WriteObject (type, val); } else if (!type.IsPrimitive && !type.IsEnum) { WriteValueType (val, type); } else { Write (Signature.TypeToDType (type), val); } } //helper method, should not be used as it boxes needlessly public void Write (DType dtype, object val) { switch (dtype) { case DType.Byte: { Write ((byte)val); } break; case DType.Boolean: { Write ((bool)val); } break; case DType.Int16: { Write ((short)val); } break; case DType.UInt16: { Write ((ushort)val); } break; case DType.Int32: { Write ((int)val); } break; case DType.UInt32: { Write ((uint)val); } break; case DType.Int64: { Write ((long)val); } break; case DType.UInt64: { Write ((ulong)val); } break; #if !DISABLE_SINGLE case DType.Single: { Write ((float)val); } break; #endif case DType.Double: { Write ((double)val); } break; case DType.String: { Write ((string)val); } break; case DType.ObjectPath: { Write ((ObjectPath)val); } break; case DType.Signature: { Write ((Signature)val); } break; case DType.Variant: { Write ((object)val); } break; default: throw new Exception ("Unhandled D-Bus type: " + dtype); } } public void WriteObject (Type type, object val) { ObjectPath path; BusObject bobj = val as BusObject; if (bobj == null && val is MarshalByRefObject) { bobj = ((MarshalByRefObject)val).GetLifetimeService () as BusObject; } if (bobj == null) throw new Exception ("No object reference to write"); path = bobj.Path; Write (path); } //variant public void Write (object val) { //TODO: maybe support sending null variants if (val == null) throw new NotSupportedException ("Cannot send null variant"); Type type = val.GetType (); WriteVariant (type, val); } public void WriteVariant (Type type, object val) { Signature sig = Signature.GetSig (type); Write (sig); Write (type, val); } //this requires a seekable stream for now public void WriteArray (object obj, Type elemType) { Array val = (Array)obj; //TODO: more fast paths for primitive arrays if (elemType == typeof (byte)) { if (val.Length > Protocol.MaxArrayLength) throw new Exception ("Array length " + val.Length + " exceeds maximum allowed " + Protocol.MaxArrayLength + " bytes"); Write ((uint)val.Length); stream.Write ((byte[])val, 0, val.Length); return; } long origPos = stream.Position; Write ((uint)0); //advance to the alignment of the element WritePad (Protocol.GetAlignment (Signature.TypeToDType (elemType))); long startPos = stream.Position; foreach (object elem in val) Write (elemType, elem); long endPos = stream.Position; uint ln = (uint)(endPos - startPos); stream.Position = origPos; if (ln > Protocol.MaxArrayLength) throw new Exception ("Array length " + ln + " exceeds maximum allowed " + Protocol.MaxArrayLength + " bytes"); Write (ln); stream.Position = endPos; } public void WriteFromDict (Type keyType, Type valType, System.Collections.IDictionary val) { long origPos = stream.Position; Write ((uint)0); //advance to the alignment of the element //WritePad (Protocol.GetAlignment (Signature.TypeToDType (type))); WritePad (8); long startPos = stream.Position; foreach (System.Collections.DictionaryEntry entry in val) { WritePad (8); Write (keyType, entry.Key); Write (valType, entry.Value); } long endPos = stream.Position; uint ln = (uint)(endPos - startPos); stream.Position = origPos; if (ln > Protocol.MaxArrayLength) throw new Exception ("Dict length " + ln + " exceeds maximum allowed " + Protocol.MaxArrayLength + " bytes"); Write (ln); stream.Position = endPos; } public void WriteValueType (object val, Type type) { MethodInfo mi = TypeImplementer.GetWriteMethod (type); mi.Invoke (null, new object[] {this, val}); } /* public void WriteValueTypeOld (object val, Type type) { WritePad (8); if (type.IsGenericType && type.GetGenericTypeDefinition () == typeof (KeyValuePair<,>)) { System.Reflection.PropertyInfo key_prop = type.GetProperty ("Key"); Write (key_prop.PropertyType, key_prop.GetValue (val, null)); System.Reflection.PropertyInfo val_prop = type.GetProperty ("Value"); Write (val_prop.PropertyType, val_prop.GetValue (val, null)); return; } FieldInfo[] fis = type.GetFields (BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); foreach (System.Reflection.FieldInfo fi in fis) { object elem; elem = fi.GetValue (val); Write (fi.FieldType, elem); } } */ public void WriteNull () { stream.WriteByte (0); } public void WritePad (int alignment) { stream.Position = Protocol.Padded ((int)stream.Position, alignment); } } } aircrack-ng-1.6/lib/csharp/MonoExample/NDesk-dbus/NDesk-dbus.csproj000066400000000000000000000057111361312141100251300ustar00rootroot00000000000000 Debug AnyCPU 10.0.0 2.0 {223B034E-A2F0-4BC7-875A-F9B5972C0670} Library NDeskdbus NDesk-dbus false ndesk.snk v2.0 true full false bin\Debug DEBUG prompt 4 false /unsafe none false bin\Release prompt 4 false /unsafe aircrack-ng-1.6/lib/csharp/MonoExample/NDesk-dbus/NDesk-dbus.pidb000066400000000000000000002337461361312141100245610ustar00rootroot00000000000000System.Collections.Hashtable LoadFactorVersionComparerHashCodeProviderHashSizeKeysValues System.Collections.IComparer$System.Collections.IHashCodeProviderQ8?   LastValidTaskListTokensVersionFIXME:2;TODO:1;HACK:1;UNDONE:0T fSignalyyg|C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Wrapper.csh NDesk.DBus{hiMessagejPathhk ObjectPathl InterfacemMembernSender } }D)hk}o interface})pmember}= "hiXfError`` wg|C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Wrapper.csh NDesk.DBusbhiMessagej ErrorNametk ReplySerialu  d d6jl error_namedm reply_serial d) l l!rhilf MethodReturnJJ^g|C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Wrapper.csh NDesk.DBusLhiMessagej ReplySerial]  N N*Uk reply_serial N W W([hiW f MethodCallHg|C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Wrapper.csh NDesk.DBushiMessagejPath?hk ObjectPathl Interface@mMemberAn DestinationBoSenderCp SignatureGhp  q%)hk!q interface-rmemberAs destinationPt signaturehpg ' '&=hi'[f UnixTransport  $gC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\UnixTransport.cshNDesk.DBus.Transportshi TransportjOpen  1kentryl NDesk.DBusm AddressEntry +n AuthString'!j#)#%oabstract#/0 fTypeImplementer  igC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\TypeImplementer.csh NDesk.DBus iasmBjSystem.Reflection.EmitkAssemblyBuilderlmodBjm ModuleBuildernmap oSystem.Collections.Genericp DictionaryqsendMethodCallMethodJrSystem.Reflections MethodInfotsendSignalMethodKrsutoggleSignalMethodLrsvhookup_methodsN.oprw EventInfojx DynamicMethodygetTypeFromHandleMethodsrsz argumentNullExceptionConstructortr{ConstructorInfo|messageWriterConstructorur{}messageWriterWriteMethodvrs~messageWriterWritePadwrs writeMethodsy&oprs InitHackGetImplementation70declType. Implement22?HtypeBj TypeBuilder2-iface29GetHookupMethodOO=_jxeirwO:aapjx declMethodrsa; invokeMethodrsaR interfaceafmemberazGetWriteMethod{{3rst{1 GenWriter9ilgj ILGenerator-7GenMarshalWriteBj3_=GenHookupMethodhj3rsCrsZnf Transport  6g~C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Transport.cshNDesk.DBus.Transportsi connection#j NDesk.DBusk ConnectionlStream1m System.IOln SocketHandle2 oCreate  6!hfpentryjq AddressEntry 0rOpen3pjq3+s AuthString4t WriteCred5k%&,jk'))+xfSocketTransport  ;gC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\SocketTransport.cshNDesk.DBus.Transportshi TransportjsocketkSystem.Net.SocketslSocketmOpen1nentryo NDesk.DBusp AddressEntry+m!!+&qhost!rport !&m((#0jkl(s WriteCred22$5t AuthString77':fDType 7g~C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Signature.csh NDesk.DBusiInvalid jByte kBoolean lInt16 !mUInt16 "nInt32 #oUInt32 $pInt64 %qUInt64 &rSingle 'sDouble (tString )u ObjectPath *v Signature +wArray -xStruct /y DictEntry 0zVariant 1{ StructBegin 3| StructEnd 4}DictEntryBegin 5~ DictEntryEnd 6-f ArgDirectiong~C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Signature.csh NDesk.DBusiIn jOut ef SignatureB g~C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Signature.csh NDesk.DBusiEmpty$hft jSystemkBytel op_Equality <.mahf-nbhf:o op_Inequality 00<3mhf0-nhf0:55)>&5'p GetHashCode@@%C q op_Addition EEBHhfrs1hfE1ss2hfE?tConcatKK>NhfrhfK-shfK;uCopyPP/ShfvsighfP+ U U"X`U Z Z"]`jkZ ` `#c`hwDType` e e%r`hwex GetBufferxx{jk^%yMakeArraySignature)hfz MakeStruct@hf{elemshf:| MakeDictEntryQhf}keyTypehf4~ valueTypehfGMakeDictLhf}hf/~hfBGetElementSignature* hfToTypesjTypeToTypeTypeCodeToDType<JhwtypeCodejTypeCode3 TypeToDTypeMM0rhw_M+#pos GetSig,/not supported by libdbus at time of writing1hfobjsjObject,0hftypesj*-hf_(this} }}}!hwLength ValueIsDictIsArray%fProtocolg}C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Protocol.csh NDesk.DBus i MinVersionjVersionk MaxVersionlMaxMessageLength mMaxArrayLength nMaxSignatureLength o MaxArrayDepth pMaxStructDepth q MaxNameLength rVerboses PadNeeded7 tpos $u alignment -vPadded4 t !u *w GetAlignment/ xdtypehyDType)  df ObjectPathH{{ g}C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Protocol.csh NDesk.DBusiRoot}%hfjValue #`)&'k GetHashCode% ^%l DecomposedmSystemnStringoParenthff HeaderFlagtgFlagsss(tyh}C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Protocol.csi NDesk.DBusjNone vkNoReplyExpected wl NoAutoStart x.f EndianFlagmmqg}C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Protocol.csh NDesk.DBusiLittle ojBig p)f FieldCode]]kg}C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Protocol.csh NDesk.DBus iInvalid _jPath `k Interface alMember bm ErrorName cn ReplySerial do Destination epSender fq Signature gf MessageTypeOO[g}C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Protocol.csh NDesk.DBusiInvalid Rj MethodCall Tk MethodReturn VlError XmSignal ZfHeaderB 5g}C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Protocol.csh NDesk.DBusi Endianness hj EndianFlagk MessageTypehklFlagshm HeaderFlagn MajorVersionoLength pSerial qFields(rSystem.Collections.Generics IDictionaryht FieldCodef PendingCall  >gC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\PendingCall.csh NDesk.DBusiconn hj Connectionkreply hlMessagemlockObj nwaiters   'ihj"oReply;hl00:p Completed= qSystemrActionhlfAddressnng|C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Address.csh NDesk.DBusiSYSTEM_BUS_ADDRESS~jParseq q8|hk AddressEntryl addressesq.mSystemnSessionoStarterpStarterBusTypef AddressEntrylg|C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Address.csh NDesk.DBusiMethodj Properties%kSystem.Collections.Genericl IDictionary^%(mEscape**$=nstr* oUnescape??&On?"pParseRR.khf.R,NfBadAddressException  "g|C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Address.csh NDesk.DBus - @ireason &f MessageFilter  9gC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\MessageFilter.csh NDesk.DBusiMessageTypeToString?jmtypehk MessageType9lStringToMessageType!!>2hkW!9mCreateMatchRule55;8jhk55fMessage  Yg|C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Message.csh NDesk.DBusiHeaderhij ConnectionhjkBody9lSystemmByte n SetHeaderDataFF*LlmF%o GetHeaderDataNN!Xlmp Signature(hp""'q ReplyExpected*+4,..3f MatchRule  g~C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\MatchRule.csh NDesk.DBusi MessageTypejSystemkNullablehil InterfacemMembernPathho ObjectPathpSenderq DestinationrArgs0sSystem.Collections.GenerictSortedDictionary   uAppend;#vsb)`5w AppendArg%%=(v%! %)`%7**)H&*'x GetHashCodeJJ%N ^PP%myMatchespp$zmsgh{Messagep |Parse.hfW) f Introspector5gC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Introspection.csh NDesk.DBusi NAMESPACEjPUBLIC_IDENTIFIERkSYSTEM_IDENTIFIERlsbmxmln root_pathho ObjectPathpwriterq System.Xmlr XmlWritersrelevantBindingFlagstSystem.Reflectionu BindingFlags  %vGetProductDescription'')6w WriteStart88@x WriteNodeBB&G!B!yWriteEndIIWz WriteTypeZZ+q{ target_typeZ|WriteArgss*v}pit~ ParameterInfos'WriteArgReversexx1{}t~x.|~~SargType~argName~.argIsOut~<reverse~K WriteMethod*mit MethodInfo' WriteProperty/prit PropertyInfo+ WriteSignal)eit EventInfo&WriteInterface)_$WriteAnnotationsG attrProvidertICustomAttributeProvider:WriteAnnotation:!'`4 WriteEnum""$4_"f ExportObjecthgC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\ExportObject.csh NDesk.DBushi BusObject'  Ljconnhk Connection#l object_pathhm ObjectPath4'HnHandleMethodCall..8[o method_callhp MethodCall.,q Registered,+fDProxy  Ng{C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\DProxy.csh NDesk.DBusiSystem.Runtime.Remoting.Proxiesj RealProxyk busObjecthl BusObjectmmi_GetHashCodenSystem.Reflectiono MethodInfop mi_Equalsnoq mi_ToStringnormi_GetLifetimeServiceno  1khl_,sGetDefaultReturn ;'tminu MethodBase'vinArgswSystemxObject4))5?y!System.Runtime.Remoting.MessagingzIMessageyz)-{.dtor HH MlfIBusIg InterfaceHHh NDesk.DBusiInterfaceAttributejorg.freedesktop.DBusI_kyC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\DBus.csjjlIntrospectablem RequestNameKjnRequestNameReply!K(oflagsjpNameFlagK7q ReleaseNameLjrReleaseNameReply!L(sHelloM t ListNamesN uSystemvStringwListActivatableNamesO uvx NameHasOwnerP!PyStartServiceByNameTjz StartReply!T)o T4{ GetNameOwnerU !U|GetConnectionUnixUserV }connection_nameV&~AddMatchWruleW RemoveMatchXXListQueuedOwners[ uv![%GetConnectionUnixProcessID\ }\+#GetConnectionSELinuxSecurityContext] uByte}]6 ReloadConfig^NameOwnerChangedQ!NameOwnerChangedHandlerNameLostRNameLostHandler NameAcquiredSNameAcquiredHandlerf Properties?g Interface>>h NDesk.DBusiInterfaceAttributejorg.freedesktop.DBus.Properties?FkyC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\DBus.cslorg.freedesktop.DBusmGetB nArgumentA A hoArgumentAttribute`p interfaceBqpropnameB)rSetCpCqC'`C8sGetAllEnD D hotpropsuSystem.Collections.Genericv IDictionarypE+#fIntrospectable8g Interface77h NDesk.DBusiInterfaceAttributej#org.freedesktop.DBus.Introspectable8!<kyC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\DBus.cslorg.freedesktop.DBusm Introspect; nArgument: : hoArgumentAttributeOfPeer0g Interface//h NDesk.DBusiInterfaceAttributejorg.freedesktop.DBus.Peer05kyC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\DBus.cslorg.freedesktop.DBusmPing2n GetMachineId4 oArgument3 3 hpArgumentAttributeq machine_uuidfNameLostHandler-gyC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\DBus.cs-!-/fNameAcquiredHandler,gyC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\DBus.cs,!,3YfNameOwnerChangedHandler+gyC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\DBus.cs+!+7h old_owner+Di new_owner+V@f StartReply##)gyC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\DBus.cshorg.freedesktop.DBusiSuccess &jAlreadyRunning (gfReleaseNameReply!gyC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\DBus.cshorg.freedesktop.DBusiReleased j NonExistent kNotOwner fRequestNameReplygyC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\DBus.cshorg.freedesktop.DBusi PrimaryOwner jInQueue kExists l AlreadyOwner fNameFlag gFlags  ( hyC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\DBus.csiorg.freedesktop.DBusjNone kAllowReplacement lReplaceExisting m DoNotQueue Gf Connection! gC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Connection.csh NDesk.DBus ins j System.IOkStreaml transport mNDesk.DBus.Transportsn TransportoisAuthenticated`pseriali q writeLock rInboundsSystem.Collections.GenerictQueuehuMessagev mainThread,wSystem.ThreadingxThready pendingCallsp sz Dictionary h{ PendingCall|Handlers+szh} MatchRule0~RegisteredObjects$szh ObjectPathh BusObjectNativeEndianness'h EndianFlag   ,'lmn " * *'.address*Open;;1Bhf;) OpenPrivateDD-TD% AuthenticateVV^GenerateSerialjjn SendWithReplyAndBlockpp7thumsghup3 SendWithReplyvv3h{huv/Send# hu WriteMessage+hu' ReadMessage"huDispatchSignals""#*Iterate//7 HandleMessage99,nhu9( HandleSignalss+hus'MaybeSendUnknownMethodErrorE method_callh MethodCall9HandleMethodCall:h. GetObjectH_!bus_name.)hC ;T!)h6RegisterObsoleteGUse the overload of Register() which does not take a bus_name parameterF )h5'B UnregisterIUse the overload of Unregister() which does not take a bus_name parameter>$)h95)h$'1- )h(AddMatch&#9rule4 RemoveMatch&#<7  n mnIsAuthenticatedabfce f BusObject  /g~C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\BusObject.csh NDesk.DBusiconnhj Connectionkbus_name l object_pathhm ObjectPath    Nihj k-lhmBn ToggleSignal33TIoiface3$pmember32qdlg03Cradding3Ms SendSignalKKZoK"pK0tinSigStrK?uwriterhv MessageWriterKWwretTypeKdx exceptionK{ySendMethodCall\\o\(p\6t\Euhv\]w\jx\z methodBase{System.Reflection| MethodBase"} methodName5~inArgsSystemObjectJoutArgs_retValsx GetObjectk'ihj.k;lhmPdeclTypebGetHookupDelegate))3.0ei{ EventInfo)0j#hj "BusName%&*')Path,-1hm.01 fBusH  gxC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Bus.csh NDesk.DBushi Connectionj systemBus hfk sessionBus hfl starterBus4hfmbusesH!nSystem.Collections.Generico DictionaryhfpbusYqorg.freedesktop.DBusrIBussDBusName[tDBusPath\hu ObjectPathv unique_name  wOpenKK.WhfxaddressK& ^ ^hx^yRegisterllrz GetUnixUsertt)w!t${ RequestNameyy4|q|RequestNameReply!y/{~~Dq|!~/}flagsq~NameFlag~> ReleaseName4qReleaseNameReply!/ NameHasOwner)!$StartServiceByName5q StartReply!0Aq!0} ;AddMatch$:rule5 RemoveMatch$=8SystemhfSession!"1hf#0Starter56Bhf7A UniqueName^f SaslClientgC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Authentication.cshNDesk.DBus.Authenticationiconnj NDesk.DBusk Connection  ! # #&&ijk#!lRun((HmUnixToDateTimeLL4Qntime L/oDateTimeToUnixSS4Z nS/pToHex^^,hqinputrSystemsByte^&t FromHexCharkk+tuck)vFromHexww,rswhexw(f ServerStategC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Authentication.cshNDesk.DBus.AuthenticationiWaitingForAuth jWaitingForData kWaitingForBegin f ClientState  gC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Authentication.cshNDesk.DBus.AuthenticationiWaitingForData j WaitingForOK kWaitingForReject Sf Notificationsg Interfaceghorg.freedesktop.Notifications iC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Notifications.csjorg.freedesktopkIntrospectablel PropertiesmGetServerInformationjnServerInformationoGetCapabilities pSystemqStringrCloseNotificationsid  tNotify uapp_names &vicon1wsummary>xbodyNyactionspq]zhints{System.Collections.Generic| IDictionary}timeout fServerInformationH!gC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Notifications.cshorg.freedesktop"iVendorjVersionk SpecVersion fC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\AssemblyInfo.csgAssemblyFileVersion  hSystem.ReflectioniAssemblyFileVersionAttributej0.6.0fkAssemblyInformationalVersion hl%AssemblyInformationalVersionAttributejfmAssemblyVersion hnAssemblyVersionAttributejfo AssemblyTitle hpAssemblyTitleAttributeq NDesk.DBusfrAssemblyDescription hsAssemblyDescriptionAttributet*D-Bus IPC protocol library and CLR bindingfuAssemblyCopyright hvAssemblyCopyrightAttributewCopyright (C) Alp TokerfxAssemblyCompany  hyAssemblyCompanyAttributezNDeskf{InternalsVisibleTo  |System.Runtime.CompilerServices}InternalsVisibleToAttribute~ dbus-monitorf{  |}NDesk.DBus.GLibf{  |}NDesk.DBus.Proxies     GMonoDevelop.Core, Version=2.6.0.0, Culture=neutral, PublicKeyToken=nullSystem.Collections.Generic.List`1[[MonoDevelop.Projects.Dom.ReferenceEntry, MonoDevelop.Core, Version=2.6.0.0, Culture=neutral, PublicKeyToken=null]]_items_size_version)MonoDevelop.Projects.Dom.ReferenceEntry[] System.Collections.Generic.Dictionary`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[MonoDevelop.Projects.Dom.Serialization.ClassEntry, MonoDevelop.Core, Version=2.6.0.0, Culture=neutral, PublicKeyToken=null]]VersionComparerHashSize KeyValuePairsSystem.Collections.Generic.GenericEqualityComparer`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]System.Collections.Generic.KeyValuePair`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[MonoDevelop.Projects.Dom.Serialization.ClassEntry, MonoDevelop.Core, Version=2.6.0.0, Culture=neutral, PublicKeyToken=null]][] Y System.Collections.Generic.Dictionary`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[MonoDevelop.Projects.Dom.Serialization.FileEntry, MonoDevelop.Core, Version=2.6.0.0, Culture=neutral, PublicKeyToken=null]]VersionComparerHashSize KeyValuePairsSystem.Collections.Generic.GenericEqualityComparer`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]System.Collections.Generic.KeyValuePair`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[MonoDevelop.Projects.Dom.Serialization.FileEntry, MonoDevelop.Core, Version=2.6.0.0, Culture=neutral, PublicKeyToken=null]][]P Y System.Collections.Hashtable LoadFactorVersionComparerHashCodeProviderHashSizeKeysValues System.Collections.IComparer$System.Collections.IHashCodeProviderQ8?  'MonoDevelop.Projects.Dom.ReferenceEntry     System.Collections.Generic.GenericEqualityComparer`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] /System.Collections.Generic.KeyValuePair`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[MonoDevelop.Projects.Dom.Serialization.ClassEntry, MonoDevelop.Core, Version=2.6.0.0, Culture=neutral, PublicKeyToken=null]]System.Collections.Generic.KeyValuePair`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[MonoDevelop.Projects.Dom.Serialization.ClassEntry, MonoDevelop.Core, Version=2.6.0.0, Culture=neutral, PublicKeyToken=null]]keyvalue1MonoDevelop.Projects.Dom.Serialization.ClassEntryNDesk.DBus.Signal NDesk.DBus.Error NDesk.DBus.MethodReturn NDesk.DBus.MethodCall #NDesk.DBus.Transports.UnixTransport "NDesk.DBus.TypeImplementer #%NDesk.DBus.Transports.Transport &(%NDesk.DBus.Transports.SocketTransport )+NDesk.DBus.DType ,.NDesk.DBus.ArgDirection /1NDesk.DBus.Signature 24NDesk.DBus.Protocol 57NDesk.DBus.ObjectPath 8:NDesk.DBus.HeaderFlag ;=NDesk.DBus.EndianFlag >@NDesk.DBus.FieldCode ACNDesk.DBus.MessageType DFNDesk.DBus.Header GINDesk.DBus.PendingCall JLNDesk.DBus.Address MONDesk.DBus.AddressEntry PRNDesk.DBus.BadAddressException SUNDesk.DBus.MessageFilter VXNDesk.DBus.Message Y[NDesk.DBus.MatchRule \^NDesk.DBus.Introspector _aNDesk.DBus.ExportObject bdNDesk.DBus.DProxy egorg.freedesktop.DBus.IBus hjorg.freedesktop.DBus.Properties km#org.freedesktop.DBus.Introspectable nporg.freedesktop.DBus.Peer qsNameLostHandler tvNameAcquiredHandler wyNameOwnerChangedHandler z|org.freedesktop.DBus.StartReply }%org.freedesktop.DBus.ReleaseNameReply %org.freedesktop.DBus.RequestNameReply |org.freedesktop.DBus.NameFlag yNDesk.DBus.Connection vNDesk.DBus.BusObject sNDesk.DBus.Bus p$NDesk.DBus.Authentication.SaslClient m%NDesk.DBus.Authentication.ServerState j%NDesk.DBus.Authentication.ClientState gorg.freedesktop.Notifications d!org.freedesktop.ServerInformation  System.Collections.Generic.KeyValuePair`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[MonoDevelop.Projects.Dom.Serialization.FileEntry, MonoDevelop.Core, Version=2.6.0.0, Culture=neutral, PublicKeyToken=null]]aSystem.Collections.Generic.KeyValuePair`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[MonoDevelop.Projects.Dom.Serialization.FileEntry, MonoDevelop.Core, Version=2.6.0.0, Culture=neutral, PublicKeyToken=null]]keyvalue0MonoDevelop.Projects.Dom.Serialization.FileEntryC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\AssemblyInfo.cs ^aC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Authentication.cs [axC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Bus.cs Xa~C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\BusObject.cs UaC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Connection.cs RayC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\DBus.cs Oa{C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\DProxy.cs LaC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\ExportObject.cs IaC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Introspection.cs Fa{C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Mapper.cs Ca~C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\MatchRule.cs @a|C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Message.cs =aC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\MessageFilter.cs :aC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\MessageReader.cs 7aC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\MessageWriter.cs 4a|C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Address.cs 1aC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\PendingCall.cs .a}C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Protocol.cs +a~C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Signature.cs (aC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\SocketTransport.cs %a~C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Transport.cs "aC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\TypeImplementer.cs aC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\UnixNativeTransport.cs aC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\UnixTransport.cs a|C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Wrapper.cs aC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\Notifications.cs  )System.Runtime.Remoting.Proxies.RealProxySystem.Exception  'MonoDevelop.Projects.Dom.ReferenceEntry databaseUriHAssembly:MS.NET:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dllJAssembly:MS.NET:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorlib.dllLAssembly:MS.NET:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Xml.dllLAssembly:MS.NET:C:\Program Files\GtkSharp\2.12\lib\Mono.Posix\Mono.Posix.dll1MonoDevelop.Projects.Dom.Serialization.ClassEntry positionnspacenametypeParameterCount subclassesflagsctype modifiers typeModifier System.Collections.ArrayList3MonoDevelop.Projects.Dom.Serialization.ContentFlags"MonoDevelop.Projects.Dom.ClassType"MonoDevelop.Projects.Dom.Modifiers%MonoDevelop.Projects.Dom.TypeModifierL NDesk.DBusSignal  3MonoDevelop.Projects.Dom.Serialization.ContentFlagsvalue__N"MonoDevelop.Projects.Dom.ClassTypevalue__"MonoDevelop.Projects.Dom.Modifiersvalue__%MonoDevelop.Projects.Dom.TypeModifiervalue__4 Error  N  MethodReturn  N  MethodCall  N [  NDesk.DBus.Transports UnixTransport  # NDesk.DBusTypeImplementer  &NDesk.DBus.Transports Transport  8) NDesk.DBus.Transports!SocketTransport  ,!& NDesk.DBus'DType  /$ &- ArgDirection  2'& &3 Signature  xNB568 NDesk.DBus9Protocol  N8: 8? ObjectPath  8NH;!> 8E HeaderFlag  >? 8K EndianFlag  A@ 8Q FieldCode  D C 8W MessageType  GD 8]Header  BJkGb NDesk.DBusc PendingCall  NMJh NDesk.DBusiAddress  8PM ho AddressEntry  StP huBadAddressException  NVQz NDesk.DBus{ MessageFilter  YMT NDesk.DBusMessage ~ 8N}|{\X NDesk.DBus MatchRule x Nwvu_] NDesk.DBus Introspector r Nqpobag NDesk.DBus ExportObject l :Nkjie\j NDesk.DBusDProxy f NedchKoorg.freedesktop.DBusIBus ` _^]kw  Properties Y XWVnS{ Introspectable R QPOqz} Peer L KJItNameLostHandler F  EDCw NameAcquiredHandler @  ?>=z NameOwnerChangedHandler :  987}`  StartReply 4 321 ReleaseNameReply . -,+ RequestNameReply ( '&% NameFlag " ! X NDesk.DBus Connection  8N NDesk.DBus BusObject  8N NDesk.DBusBus  :N  H NDesk.DBus.Authentication SaslClient  NU  ServerState  ۴  ClientState  `org.freedesktop  Notifications   ServerInformation  H0MonoDevelop.Projects.Dom.Serialization.FileEntryfilePath parseTimeparseErrorRetries commentTasksclasses System.Collections.Generic.List`1[[MonoDevelop.Projects.Dom.Tag, MonoDevelop.Core, Version=2.6.0.0, Culture=neutral, PublicKeyToken=null]] Ҝ͈   y;8Ɉ   y;8Ɉ   wwɈ   wwɈ   4B_Ɉ # $ y;8Ɉ & e wwɈ ) b ͈ , _ wwɈ  y;8Ɉ 0 \ y;8Ɉ 3 Y y;8Ɉ 6 V y;8Ɉ  wwɈ  y;8Ɉ ; < DP&Ɉ > J y;8Ɉ A B y;8Ɉ D E y;8Ɉ G ) y;8Ɉ J & DP&Ɉ M # y;8Ɉ  y;8Ɉ Q  y;8Ɉ T U ͈ W XSystem.Collections.ArrayList_items_size_version Y Z [ \ ] ^ _System.Collections.Generic.List`1[[MonoDevelop.Projects.Dom.Tag, MonoDevelop.Core, Version=2.6.0.0, Culture=neutral, PublicKeyToken=null]]_items_size_versionMonoDevelop.Projects.Dom.Tag[] ` `1MonoDevelop.Projects.Dom.Serialization.ClassEntry  d e   f# `$ 1MonoDevelop.Projects.Dom.Serialization.ClassEntry } z w t q n k h& s) t, u0 v3 w6 x; `<1MonoDevelop.Projects.Dom.Serialization.ClassEntry S P M> `A `B1MonoDevelop.Projects.Dom.Serialization.ClassEntry G D A > ; 8 5D  E1MonoDevelop.Projects.Dom.Serialization.ClassEntry 2 / ,G J M `Q `T U1MonoDevelop.Projects.Dom.Serialization.ClassEntry    W `X1MonoDevelop.Projects.Dom.Serialization.ClassEntry Y e Z S [   ) ) \  ]   h^  _  b `MonoDevelop.Projects.Dom.TagdMonoDevelop.Projects.Dom.Tag    eMonoDevelop.Projects.Dom.Tag          fMonoDevelop.Projects.Dom.Tag                sMonoDevelop.Projects.Dom.Tag  tMonoDevelop.Projects.Dom.Tag      uMonoDevelop.Projects.Dom.Tag        vMonoDevelop.Projects.Dom.Tag      wMonoDevelop.Projects.Dom.Tag   xMonoDevelop.Projects.Dom.Tag  MonoDevelop.Projects.Dom.Tag           MonoDevelop.Projects.Dom.Tag  MonoDevelop.Projects.Dom.Tag  MonoDevelop.Projects.Dom.Tag      NDesk.DBus.Transports UnixTransport  NDesk.DBus.TransportsSocketTransport  org.freedesktop Notifications    org.freedesktop.DBusIBus   NDesk.DBusBus  :NH NDesk.DBus ExportObject  :NMonoDevelop.Projects.Dom.Tagkey Comment+k__BackingField#Comment+k__BackingFieldComment+k__BackingFieldComment+k__BackingField(Comment+k__BackingField*Comment+k__BackingField$Comment+k__BackingField"MonoDevelop.Projects.Dom.DomRegion$MonoDevelop.Projects.Dom.CommentType TODO  ?TODO: parsing of starter bus type, or maybe do this another way"MonoDevelop.Projects.Dom.DomRegionstartend$MonoDevelop.Projects.Dom.DomLocation$MonoDevelop.Projects.Dom.DomLocation$MonoDevelop.Projects.Dom.DomLocationk__BackingFieldk__BackingField33D$MonoDevelop.Projects.Dom.CommentTypevalue__  0TODO: use the guid, not the whole address stringFF5  =TODO: consider what happens when a connection has been closedGGB  )TODO: don't ignore retVal, exception etc.OO/  $)TODO: don't ignore retVal, exception etc.``/  *$TODO: complete out parameter supportkk*  0TODO: don't hard code thisyy   6TODO: typed exceptions  <DTODO: this needs to be done properly, not with simple String.ReplaceK  B$TODO: complete out parameter support*  HTODO: don't hard code this   NTODO: typed exceptions    TTODO: reconsider this field   ZTODO: clean this bit up%%  `)TODO: try alternative addresses if neededMM/  fTODO: clean this bit upRR  l Outbound = new Queue (); public void Flush () { //should just iterate the enumerator here while (Outbound.Count != 0) { Message msg = Outbound.Dequeue (); WriteMessage (msg); } } public bool ReadWrite (int timeout_milliseconds) { //TODO return true; } public bool ReadWrite () { return ReadWrite (-1); } public bool Dispatch () { //TODO Message msg = Inbound.Dequeue (); //HandleMessage (msg); return true; } public bool ReadWriteDispatch (int timeout_milliseconds) { //TODO return Dispatch (); } public bool ReadWriteDispatch () { return ReadWriteDispatch (-1); } */  xMTODO: support disconnection situations properly and move this check elsewhere;;S  ~TODO: better exception handling__'~  >TODO: this is a hack, not necessary when MatchRule is complete{zwywDx  _TODO: how should we handle this condition? sending an Error may not be appropriate in this caseutsfr  TODO: Ping and Introspect need to be abstracted and moved somewhere more appropriate once message filter infrastructure is completeonmlFIXME ~FIXME: these special cases are slightly broken for the case where the member but not the interface is specified in the messageihgf  FIXME: do this properlycba`  -FIXME: this shouldn't be part of the core API]\[2Z  TODO: implement some kind of tree data structure or internal object hierarchy. right now we are ignoring the name and putting all object paths in one namespace, which is badWVUT  'FIXME: remove handlers/match rules hereQPJOJ-N  ;TODO: perhaps ExportObject should not derive from BusObjectKJ I ?H  =TODO: there is no member name mapping for properties etc. yetED3C3CB  (TODO: complete exception sending support?>E=E/<  WTODO: we should be more strict here, but this fallback was added as a quick fix for p2p98O7O^6  ~ public void Ping () { } public string GetMachineId () { //TODO: implement this return String.Empty; } */32]1g0  TODO: complete this class-,+*  `TODO: non-well-known introspection has paths as well, which we don't do yet. read the spec again'&^%^f$  >TODO: review recursion of interfaces and inheritance hierarchy! nnD  8TODO: clean up and get rid of reverse (or argIsOut) parm}}=  :TODO: avoid writing null (DType.Invalid) to the XML stream@   TODO: this is unreliable, fix it &   TODO: indexers    TODO: attributes as annotations?  &  *TODO: see why path comparison doesn't work::0  FIXME: do argsEE  FIXME: not at all optimalLL  FIXME: do args  $TODO: more consistent error handling+   )TODO: is this the right place to do this?/Z  &TODO: make use of Locked;;  ,JTODO: remove this -- left here for the benefit of the monitor tool for now44O  2ATODO: Reflection should be done at a higher level than this class  D  8 TODO: this class needs some work%  > //TODO: remove this hack to handle bad case when Data is null if (a.data == null || b.data == null) throw new Exception ("Encountered Signature with null buffer"); */  DHTODO: this should be private, but MessageWriter and Monitor still use itvvM  Jn //FIXME: hack to handle bad case when Data is null if (data == null) return String.Empty; */  P //TODO: complete this public bool IsPrimitive { get { if (this == Signature.Empty) return true; return false; } } */  VTODO: improve this  \(FIXME: this method is bad, get rid of itLL-  b#TODO: maybe throw an exception herepp)  hKTODO: remove Struct and DictEntry -- they are not relevant to wire protocol..P  nTODO: use Socket directly##  tTODO: design this properly..  z,TODO: complete and use these wrapper classes  0  FFIXME: signature sending/receiving is currently ambiguous in this code~}J|  uFIXME: in fact, these classes are totally broken and end up doing no-op, do not use without understanding the problemyxwyv  5TODO: consider setting Sender here for p2p situationssrq;p  =TODO: filled by the bus so reliable, but not the case for p2pml/k/Cj Caircrack-ng-1.6/lib/csharp/MonoExample/NDesk-dbus/Notifications.cs000066400000000000000000000015201361312141100251010ustar00rootroot00000000000000// Copyright 2006 Alp Toker // This software is made available under the MIT License // See COPYING for details using System; using System.Collections.Generic; using NDesk.DBus; using org.freedesktop.DBus; // Hand-written interfaces for bootstrapping namespace org.freedesktop { public struct ServerInformation { public string Name; public string Vendor; public string Version; public string SpecVersion; } [Interface ("org.freedesktop.Notifications")] public interface Notifications : Introspectable, Properties { ServerInformation GetServerInformation (); string[] GetCapabilities (); void CloseNotification (uint id); uint Notify (string app_name, uint id, string icon, string summary, string body, string[] actions, IDictionary hints, int timeout); } } aircrack-ng-1.6/lib/csharp/MonoExample/NDesk-dbus/PendingCall.cs000066400000000000000000000020711361312141100244520ustar00rootroot00000000000000// Copyright 2007 Alp Toker // This software is made available under the MIT License // See COPYING for details using System; using System.Threading; namespace NDesk.DBus { class PendingCall { Connection conn; Message reply = null; object lockObj = new object (); public PendingCall (Connection conn) { this.conn = conn; } int waiters = 0; public Message Reply { get { if (Thread.CurrentThread == conn.mainThread) { /* while (reply == null) conn.Iterate (); */ while (reply == null) conn.HandleMessage (conn.ReadMessage ()); conn.DispatchSignals (); } else { lock (lockObj) { Interlocked.Increment (ref waiters); while (reply == null) Monitor.Wait (lockObj); Interlocked.Decrement (ref waiters); } } return reply; } set { lock (lockObj) { reply = value; if (waiters > 0) Monitor.PulseAll (lockObj); if (Completed != null) Completed (reply); } } } public event Action Completed; } } aircrack-ng-1.6/lib/csharp/MonoExample/NDesk-dbus/Protocol.cs000066400000000000000000000153061361312141100241000ustar00rootroot00000000000000// Copyright 2006 Alp Toker // This software is made available under the MIT License // See COPYING for details using System; using System.Collections.Generic; namespace NDesk.DBus { //yyyyuua{yv} struct Header { public EndianFlag Endianness; public MessageType MessageType; public HeaderFlag Flags; public byte MajorVersion; public uint Length; public uint Serial; //public HeaderField[] Fields; public IDictionary Fields; /* public static DType TypeForField (FieldCode f) { switch (f) { case FieldCode.Invalid: return DType.Invalid; case FieldCode.Path: return DType.ObjectPath; case FieldCode.Interface: return DType.String; case FieldCode.Member: return DType.String; case FieldCode.ErrorName: return DType.String; case FieldCode.ReplySerial: return DType.UInt32; case FieldCode.Destination: return DType.String; case FieldCode.Sender: return DType.String; case FieldCode.Signature: return DType.Signature; #if PROTO_REPLY_SIGNATURE case FieldCode.ReplySignature: //note: not supported in dbus return DType.Signature; #endif default: return DType.Invalid; } } */ } /* public struct HeaderField { //public HeaderField (FieldCode code, object value) //{ // this.Code = code; // this.Value = value; //} public static HeaderField Create (FieldCode code, object value) { HeaderField hf; hf.Code = code; hf.Value = value; return hf; } public FieldCode Code; public object Value; } */ enum MessageType : byte { //This is an invalid type. Invalid, //Method call. MethodCall, //Method reply with returned data. MethodReturn, //Error reply. If the first argument exists and is a string, it is an error message. Error, //Signal emission. Signal, } enum FieldCode : byte { Invalid, Path, Interface, Member, ErrorName, ReplySerial, Destination, Sender, Signature, #if PROTO_REPLY_SIGNATURE ReplySignature, //note: not supported in dbus #endif } enum EndianFlag : byte { Little = (byte)'l', Big = (byte)'B', } [Flags] enum HeaderFlag : byte { None = 0, NoReplyExpected = 0x1, NoAutoStart = 0x2, } public sealed class ObjectPath //: IComparable, IComparable, IEquatable { public static readonly ObjectPath Root = new ObjectPath ("/"); internal readonly string Value; public ObjectPath (string value) { if (value == null) throw new ArgumentNullException ("value"); this.Value = value; } public override bool Equals (object o) { ObjectPath b = o as ObjectPath; if (b == null) return false; return Value.Equals (b.Value); } public override int GetHashCode () { return Value.GetHashCode (); } public override string ToString () { return Value; } //this may or may not prove useful internal string[] Decomposed { get { return Value.Split (new char[] {'/'}, StringSplitOptions.RemoveEmptyEntries); /* } set { Value = String.Join ("/", value); */ } } internal ObjectPath Parent { get { if (Value == Root.Value) return null; string par = Value.Substring (0, Value.LastIndexOf ('/')); if (par == String.Empty) par = "/"; return new ObjectPath (par); } } /* public int CompareTo (object value) { return 1; } public int CompareTo (ObjectPath value) { return 1; } public bool Equals (ObjectPath value) { return false; } */ } static class Protocol { //protocol versions that we support public const byte MinVersion = 0; public const byte Version = 1; public const byte MaxVersion = Version; public const uint MaxMessageLength = 134217728; //2 to the 27th power public const uint MaxArrayLength = 67108864; //2 to the 26th power public const uint MaxSignatureLength = 255; public const uint MaxArrayDepth = 32; public const uint MaxStructDepth = 32; //this is not strictly related to Protocol since names are passed around as strings internal const uint MaxNameLength = 255; public static int PadNeeded (int pos, int alignment) { int pad = pos % alignment; pad = pad == 0 ? 0 : alignment - pad; return pad; } public static int Padded (int pos, int alignment) { int pad = pos % alignment; if (pad != 0) pos += alignment - pad; return pos; } public static int GetAlignment (DType dtype) { switch (dtype) { case DType.Byte: return 1; case DType.Boolean: return 4; case DType.Int16: case DType.UInt16: return 2; case DType.Int32: case DType.UInt32: return 4; case DType.Int64: case DType.UInt64: return 8; #if !DISABLE_SINGLE case DType.Single: //Not yet supported! return 4; #endif case DType.Double: return 8; case DType.String: return 4; case DType.ObjectPath: return 4; case DType.Signature: return 1; case DType.Array: return 4; case DType.Struct: return 8; case DType.Variant: return 1; case DType.DictEntry: return 8; case DType.Invalid: default: throw new Exception ("Cannot determine alignment of " + dtype); } } //this class may not be the best place for Verbose public readonly static bool Verbose; static Protocol () { Verbose = !String.IsNullOrEmpty (Environment.GetEnvironmentVariable ("DBUS_VERBOSE")); } } #if UNDOCUMENTED_IN_SPEC /* "org.freedesktop.DBus.Error.Failed" "org.freedesktop.DBus.Error.NoMemory" "org.freedesktop.DBus.Error.ServiceUnknown" "org.freedesktop.DBus.Error.NameHasNoOwner" "org.freedesktop.DBus.Error.NoReply" "org.freedesktop.DBus.Error.IOError" "org.freedesktop.DBus.Error.BadAddress" "org.freedesktop.DBus.Error.NotSupported" "org.freedesktop.DBus.Error.LimitsExceeded" "org.freedesktop.DBus.Error.AccessDenied" "org.freedesktop.DBus.Error.AuthFailed" "org.freedesktop.DBus.Error.NoServer" "org.freedesktop.DBus.Error.Timeout" "org.freedesktop.DBus.Error.NoNetwork" "org.freedesktop.DBus.Error.AddressInUse" "org.freedesktop.DBus.Error.Disconnected" "org.freedesktop.DBus.Error.InvalidArgs" "org.freedesktop.DBus.Error.FileNotFound" "org.freedesktop.DBus.Error.UnknownMethod" "org.freedesktop.DBus.Error.TimedOut" "org.freedesktop.DBus.Error.MatchRuleNotFound" "org.freedesktop.DBus.Error.MatchRuleInvalid" "org.freedesktop.DBus.Error.Spawn.ExecFailed" "org.freedesktop.DBus.Error.Spawn.ForkFailed" "org.freedesktop.DBus.Error.Spawn.ChildExited" "org.freedesktop.DBus.Error.Spawn.ChildSignaled" "org.freedesktop.DBus.Error.Spawn.Failed" "org.freedesktop.DBus.Error.UnixProcessIdUnknown" "org.freedesktop.DBus.Error.InvalidSignature" "org.freedesktop.DBus.Error.SELinuxSecurityContextUnknown" */ #endif } aircrack-ng-1.6/lib/csharp/MonoExample/NDesk-dbus/Signature.cs000066400000000000000000000306411361312141100242370ustar00rootroot00000000000000// Copyright 2006 Alp Toker // This software is made available under the MIT License // See COPYING for details using System; using System.Text; using System.Collections.Generic; //TODO: Reflection should be done at a higher level than this class using System.Reflection; namespace NDesk.DBus { //maybe this should be nullable? struct Signature { //TODO: this class needs some work //Data should probably include the null terminator public static readonly Signature Empty = new Signature (String.Empty); public static bool operator == (Signature a, Signature b) { /* //TODO: remove this hack to handle bad case when Data is null if (a.data == null || b.data == null) throw new Exception ("Encountered Signature with null buffer"); */ /* if (a.data == null && b.data == null) return true; if (a.data == null || b.data == null) return false; */ if (a.data.Length != b.data.Length) return false; for (int i = 0 ; i != a.data.Length ; i++) if (a.data[i] != b.data[i]) return false; return true; } public static bool operator != (Signature a, Signature b) { return !(a == b); } public override bool Equals (object o) { if (o == null) return false; if (!(o is Signature)) return false; return this == (Signature)o; } public override int GetHashCode () { return data.GetHashCode (); } public static Signature operator + (Signature s1, Signature s2) { return Concat (s1, s2); } //these need to be optimized public static Signature Concat (Signature s1, Signature s2) { return new Signature (s1.Value + s2.Value); } public static Signature Copy (Signature sig) { return new Signature (sig.data); } public Signature (string value) { this.data = Encoding.ASCII.GetBytes (value); } public Signature (byte[] value) { this.data = (byte[])value.Clone (); } //this will become obsolete soon internal Signature (DType value) { this.data = new byte[] {(byte)value}; } internal Signature (DType[] value) { this.data = new byte[value.Length]; /* MemoryStream ms = new MemoryStream (this.data); foreach (DType t in value) ms.WriteByte ((byte)t); */ for (int i = 0 ; i != value.Length ; i++) this.data[i] = (byte)value[i]; } byte[] data; //TODO: this should be private, but MessageWriter and Monitor still use it //[Obsolete] public byte[] GetBuffer () { return data; } internal DType this[int index] { get { return (DType)data[index]; } } public int Length { get { return data.Length; } } //[Obsolete] public string Value { get { /* //FIXME: hack to handle bad case when Data is null if (data == null) return String.Empty; */ return Encoding.ASCII.GetString (data); } } public override string ToString () { return Value; /* StringBuilder sb = new StringBuilder (); foreach (DType t in data) { //we shouldn't rely on object mapping here, but it's an easy way to get string representations for now Type type = DTypeToType (t); if (type != null) { sb.Append (type.Name); } else { char c = (char)t; if (!Char.IsControl (c)) sb.Append (c); else sb.Append (@"\" + (int)c); } sb.Append (" "); } return sb.ToString (); */ } public Signature MakeArraySignature () { return new Signature (DType.Array) + this; } public static Signature MakeStruct (params Signature[] elems) { Signature sig = Signature.Empty; sig += new Signature (DType.StructBegin); foreach (Signature elem in elems) sig += elem; sig += new Signature (DType.StructEnd); return sig; } public static Signature MakeDictEntry (Signature keyType, Signature valueType) { Signature sig = Signature.Empty; sig += new Signature (DType.DictEntryBegin); sig += keyType; sig += valueType; sig += new Signature (DType.DictEntryEnd); return sig; } public static Signature MakeDict (Signature keyType, Signature valueType) { return MakeDictEntry (keyType, valueType).MakeArraySignature (); } /* //TODO: complete this public bool IsPrimitive { get { if (this == Signature.Empty) return true; return false; } } */ public bool IsDict { get { if (Length < 3) return false; if (!IsArray) return false; if (this[2] != DType.DictEntryBegin) return false; return true; } } public bool IsArray { get { if (Length < 2) return false; if (this[0] != DType.Array) return false; return true; } } public Signature GetElementSignature () { if (!IsArray) throw new Exception ("Cannot get the element signature of a non-array (signature was '" + this + "')"); //TODO: improve this if (Length != 2) throw new NotSupportedException ("Parsing signatures with more than one primitive value is not supported (signature was '" + this + "')"); return new Signature (this[1]); } public Type[] ToTypes () { List types = new List (); for (int i = 0 ; i != data.Length ; types.Add (ToType (ref i))); return types.ToArray (); } public Type ToType () { int pos = 0; Type ret = ToType (ref pos); if (pos != data.Length) throw new Exception ("Signature '" + Value + "' is not a single complete type"); return ret; } internal static DType TypeCodeToDType (TypeCode typeCode) { switch (typeCode) { case TypeCode.Empty: return DType.Invalid; case TypeCode.Object: return DType.Invalid; case TypeCode.DBNull: return DType.Invalid; case TypeCode.Boolean: return DType.Boolean; case TypeCode.Char: return DType.UInt16; case TypeCode.SByte: return DType.Byte; case TypeCode.Byte: return DType.Byte; case TypeCode.Int16: return DType.Int16; case TypeCode.UInt16: return DType.UInt16; case TypeCode.Int32: return DType.Int32; case TypeCode.UInt32: return DType.UInt32; case TypeCode.Int64: return DType.Int64; case TypeCode.UInt64: return DType.UInt64; case TypeCode.Single: return DType.Single; case TypeCode.Double: return DType.Double; case TypeCode.Decimal: return DType.Invalid; case TypeCode.DateTime: return DType.Invalid; case TypeCode.String: return DType.String; default: return DType.Invalid; } } //FIXME: this method is bad, get rid of it internal static DType TypeToDType (Type type) { if (type == typeof (void)) return DType.Invalid; if (type == typeof (string)) return DType.String; if (type == typeof (ObjectPath)) return DType.ObjectPath; if (type == typeof (Signature)) return DType.Signature; if (type == typeof (object)) return DType.Variant; if (type.IsPrimitive) return TypeCodeToDType (Type.GetTypeCode (type)); if (type.IsEnum) return TypeToDType (Enum.GetUnderlyingType (type)); //needs work if (type.IsArray) return DType.Array; //if (type.UnderlyingSystemType != null) // return TypeToDType (type.UnderlyingSystemType); if (Mapper.IsPublic (type)) return DType.ObjectPath; if (!type.IsPrimitive && !type.IsEnum) return DType.Struct; //TODO: maybe throw an exception here return DType.Invalid; } /* public static DType TypeToDType (Type type) { if (type == null) return DType.Invalid; else if (type == typeof (byte)) return DType.Byte; else if (type == typeof (bool)) return DType.Boolean; else if (type == typeof (short)) return DType.Int16; else if (type == typeof (ushort)) return DType.UInt16; else if (type == typeof (int)) return DType.Int32; else if (type == typeof (uint)) return DType.UInt32; else if (type == typeof (long)) return DType.Int64; else if (type == typeof (ulong)) return DType.UInt64; else if (type == typeof (float)) //not supported by libdbus at time of writing return DType.Single; else if (type == typeof (double)) return DType.Double; else if (type == typeof (string)) return DType.String; else if (type == typeof (ObjectPath)) return DType.ObjectPath; else if (type == typeof (Signature)) return DType.Signature; else return DType.Invalid; } */ public Type ToType (ref int pos) { DType dtype = (DType)data[pos++]; switch (dtype) { case DType.Invalid: return typeof (void); case DType.Byte: return typeof (byte); case DType.Boolean: return typeof (bool); case DType.Int16: return typeof (short); case DType.UInt16: return typeof (ushort); case DType.Int32: return typeof (int); case DType.UInt32: return typeof (uint); case DType.Int64: return typeof (long); case DType.UInt64: return typeof (ulong); case DType.Single: ////not supported by libdbus at time of writing return typeof (float); case DType.Double: return typeof (double); case DType.String: return typeof (string); case DType.ObjectPath: return typeof (ObjectPath); case DType.Signature: return typeof (Signature); case DType.Array: //peek to see if this is in fact a dictionary if ((DType)data[pos] == DType.DictEntryBegin) { //skip over the { pos++; Type keyType = ToType (ref pos); Type valueType = ToType (ref pos); //skip over the } pos++; //return typeof (IDictionary<,>).MakeGenericType (new Type[] {keyType, valueType}); //workaround for Mono bug #81035 (memory leak) return Mapper.GetGenericType (typeof (IDictionary<,>), new Type[] {keyType, valueType}); } else { return ToType (ref pos).MakeArrayType (); } case DType.Struct: return typeof (ValueType); case DType.DictEntry: return typeof (System.Collections.Generic.KeyValuePair<,>); case DType.Variant: return typeof (object); default: throw new NotSupportedException ("Parsing or converting this signature is not yet supported (signature was '" + this + "'), at DType." + dtype); } } public static Signature GetSig (object[] objs) { return GetSig (Type.GetTypeArray (objs)); } public static Signature GetSig (Type[] types) { if (types == null) throw new ArgumentNullException ("types"); Signature sig = Signature.Empty; foreach (Type type in types) sig += GetSig (type); return sig; } public static Signature GetSig (Type type) { if (type == null) throw new ArgumentNullException ("type"); //this is inelegant, but works for now if (type == typeof (Signature)) return new Signature (DType.Signature); if (type == typeof (ObjectPath)) return new Signature (DType.ObjectPath); if (type == typeof (void)) return Signature.Empty; if (type == typeof (string)) return new Signature (DType.String); if (type == typeof (object)) return new Signature (DType.Variant); if (type.IsArray) return GetSig (type.GetElementType ()).MakeArraySignature (); if (type.IsGenericType && (type.GetGenericTypeDefinition () == typeof (IDictionary<,>) || type.GetGenericTypeDefinition () == typeof (Dictionary<,>))) { Type[] genArgs = type.GetGenericArguments (); return Signature.MakeDict (GetSig (genArgs[0]), GetSig (genArgs[1])); } if (Mapper.IsPublic (type)) { return new Signature (DType.ObjectPath); } if (!type.IsPrimitive && !type.IsEnum) { Signature sig = Signature.Empty; foreach (FieldInfo fi in type.GetFields (BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)) sig += GetSig (fi.FieldType); return Signature.MakeStruct (sig); } DType dtype = Signature.TypeToDType (type); return new Signature (dtype); } } enum ArgDirection { In, Out, } enum DType : byte { Invalid = (byte)'\0', Byte = (byte)'y', Boolean = (byte)'b', Int16 = (byte)'n', UInt16 = (byte)'q', Int32 = (byte)'i', UInt32 = (byte)'u', Int64 = (byte)'x', UInt64 = (byte)'t', Single = (byte)'f', //This is not yet supported! Double = (byte)'d', String = (byte)'s', ObjectPath = (byte)'o', Signature = (byte)'g', Array = (byte)'a', //TODO: remove Struct and DictEntry -- they are not relevant to wire protocol Struct = (byte)'r', DictEntry = (byte)'e', Variant = (byte)'v', StructBegin = (byte)'(', StructEnd = (byte)')', DictEntryBegin = (byte)'{', DictEntryEnd = (byte)'}', } } aircrack-ng-1.6/lib/csharp/MonoExample/NDesk-dbus/SocketTransport.cs000066400000000000000000000024021361312141100254350ustar00rootroot00000000000000// Copyright 2006 Alp Toker // This software is made available under the MIT License // See COPYING for details using System; using System.IO; using System.Net; using System.Net.Sockets; namespace NDesk.DBus.Transports { class SocketTransport : Transport { protected Socket socket; public override void Open (AddressEntry entry) { string host, portStr; int port; if (!entry.Properties.TryGetValue ("host", out host)) throw new Exception ("No host specified"); if (!entry.Properties.TryGetValue ("port", out portStr)) throw new Exception ("No port specified"); if (!Int32.TryParse (portStr, out port)) throw new Exception ("Invalid port: \"" + port + "\""); Open (host, port); } public void Open (string host, int port) { //TODO: use Socket directly TcpClient client = new TcpClient (host, port); Stream = client.GetStream (); } public void Open (Socket socket) { this.socket = socket; socket.Blocking = true; SocketHandle = (long)socket.Handle; //Stream = new UnixStream ((int)socket.Handle); Stream = new NetworkStream (socket); } public override void WriteCred () { Stream.WriteByte (0); } public override string AuthString () { return String.Empty; } } } aircrack-ng-1.6/lib/csharp/MonoExample/NDesk-dbus/Transport.cs000066400000000000000000000022301361312141100242630ustar00rootroot00000000000000// Copyright 2006 Alp Toker // This software is made available under the MIT License // See COPYING for details using System; using System.IO; namespace NDesk.DBus.Transports { abstract class Transport { public static Transport Create (AddressEntry entry) { switch (entry.Method) { case "tcp": { Transport transport = new SocketTransport (); transport.Open (entry); return transport; } #if !PORTABLE case "unix": { //Transport transport = new UnixMonoTransport (); Transport transport = new UnixNativeTransport (); transport.Open (entry); return transport; } #endif default: throw new NotSupportedException ("Transport method \"" + entry.Method + "\" not supported"); } } protected Connection connection; public Connection Connection { get { return connection; } set { connection = value; } } //TODO: design this properly //this is just a temporary solution public Stream Stream; public long SocketHandle; public abstract void Open (AddressEntry entry); public abstract string AuthString (); public abstract void WriteCred (); } } aircrack-ng-1.6/lib/csharp/MonoExample/NDesk-dbus/TypeImplementer.cs000066400000000000000000000262731361312141100254270ustar00rootroot00000000000000// Copyright 2007 Alp Toker // This software is made available under the MIT License // See COPYING for details using System; using System.Reflection; using System.Reflection.Emit; using System.Collections.Generic; namespace NDesk.DBus { static class TypeImplementer { static AssemblyBuilder asmB; static ModuleBuilder modB; static void InitHack () { if (asmB != null) return; asmB = AppDomain.CurrentDomain.DefineDynamicAssembly (new AssemblyName ("NDesk.DBus.Proxies"), AssemblyBuilderAccess.Run); modB = asmB.DefineDynamicModule ("ProxyModule"); } static Dictionary map = new Dictionary (); public static Type GetImplementation (Type declType) { Type retT; if (map.TryGetValue (declType, out retT)) return retT; InitHack (); TypeBuilder typeB = modB.DefineType (declType.Name + "Proxy", TypeAttributes.Class | TypeAttributes.Public, typeof (BusObject)); Implement (typeB, declType); foreach (Type iface in declType.GetInterfaces ()) Implement (typeB, iface); retT = typeB.CreateType (); map[declType] = retT; return retT; } public static void Implement (TypeBuilder typeB, Type iface) { typeB.AddInterfaceImplementation (iface); foreach (MethodInfo declMethod in iface.GetMethods ()) { ParameterInfo[] parms = declMethod.GetParameters (); Type[] parmTypes = new Type[parms.Length]; for (int i = 0 ; i < parms.Length ; i++) parmTypes[i] = parms[i].ParameterType; MethodAttributes attrs = declMethod.Attributes ^ MethodAttributes.Abstract; MethodBuilder method_builder = typeB.DefineMethod (declMethod.Name, attrs, declMethod.ReturnType, parmTypes); typeB.DefineMethodOverride (method_builder, declMethod); //define in/out/ref/name for each of the parameters for (int i = 0; i < parms.Length ; i++) method_builder.DefineParameter (i, parms[i].Attributes, parms[i].Name); ILGenerator ilg = method_builder.GetILGenerator (); GenHookupMethod (ilg, declMethod, sendMethodCallMethod, Mapper.GetInterfaceName (iface), declMethod.Name); } } static MethodInfo sendMethodCallMethod = typeof (BusObject).GetMethod ("SendMethodCall"); static MethodInfo sendSignalMethod = typeof (BusObject).GetMethod ("SendSignal"); static MethodInfo toggleSignalMethod = typeof (BusObject).GetMethod ("ToggleSignal"); static Dictionary hookup_methods = new Dictionary (); public static DynamicMethod GetHookupMethod (EventInfo ei) { DynamicMethod hookupMethod; if (hookup_methods.TryGetValue (ei, out hookupMethod)) return hookupMethod; if (ei.EventHandlerType.IsAssignableFrom (typeof (System.EventHandler))) Console.Error.WriteLine ("Warning: Cannot yet fully expose EventHandler and its subclasses: " + ei.EventHandlerType); MethodInfo declMethod = ei.EventHandlerType.GetMethod ("Invoke"); hookupMethod = GetHookupMethod (declMethod, sendSignalMethod, Mapper.GetInterfaceName (ei), ei.Name); hookup_methods[ei] = hookupMethod; return hookupMethod; } public static DynamicMethod GetHookupMethod (MethodInfo declMethod, MethodInfo invokeMethod, string @interface, string member) { ParameterInfo[] delegateParms = declMethod.GetParameters (); Type[] hookupParms = new Type[delegateParms.Length+1]; hookupParms[0] = typeof (BusObject); for (int i = 0; i < delegateParms.Length ; i++) hookupParms[i+1] = delegateParms[i].ParameterType; DynamicMethod hookupMethod = new DynamicMethod ("Handle" + member, declMethod.ReturnType, hookupParms, typeof (MessageWriter)); ILGenerator ilg = hookupMethod.GetILGenerator (); GenHookupMethod (ilg, declMethod, invokeMethod, @interface, member); return hookupMethod; } //static MethodInfo getMethodFromHandleMethod = typeof (MethodBase).GetMethod ("GetMethodFromHandle", new Type[] {typeof (RuntimeMethodHandle)}); static MethodInfo getTypeFromHandleMethod = typeof (Type).GetMethod ("GetTypeFromHandle", new Type[] {typeof (RuntimeTypeHandle)}); static ConstructorInfo argumentNullExceptionConstructor = typeof (ArgumentNullException).GetConstructor (new Type[] {typeof (string)}); static ConstructorInfo messageWriterConstructor = typeof (MessageWriter).GetConstructor (Type.EmptyTypes); static MethodInfo messageWriterWriteMethod = typeof (MessageWriter).GetMethod ("WriteComplex", new Type[] {typeof (object), typeof (Type)}); static MethodInfo messageWriterWritePad = typeof (MessageWriter).GetMethod ("WritePad", new Type[] {typeof (int)}); static Dictionary writeMethods = new Dictionary (); public static MethodInfo GetWriteMethod (Type t) { MethodInfo meth; if (writeMethods.TryGetValue (t, out meth)) return meth; /* Type tUnder = t; if (t.IsEnum) tUnder = Enum.GetUnderlyingType (t); meth = typeof (MessageWriter).GetMethod ("Write", BindingFlags.ExactBinding | BindingFlags.Instance | BindingFlags.Public, null, new Type[] {tUnder}, null); if (meth != null) { writeMethods[t] = meth; return meth; } */ DynamicMethod method_builder = new DynamicMethod ("Write" + t.Name, typeof (void), new Type[] {typeof (MessageWriter), t}, typeof (MessageWriter)); ILGenerator ilg = method_builder.GetILGenerator (); ilg.Emit (OpCodes.Ldarg_0); ilg.Emit (OpCodes.Ldarg_1); GenMarshalWrite (ilg, t); ilg.Emit (OpCodes.Ret); meth = method_builder; writeMethods[t] = meth; return meth; } //takes the Writer instance and the value of Type t off the stack, writes it public static void GenWriter (ILGenerator ilg, Type t) { Type tUnder = t; //bool imprecise = false; if (t.IsEnum) { tUnder = Enum.GetUnderlyingType (t); //imprecise = true; } //MethodInfo exactWriteMethod = typeof (MessageWriter).GetMethod ("Write", new Type[] {tUnder}); MethodInfo exactWriteMethod = typeof (MessageWriter).GetMethod ("Write", BindingFlags.ExactBinding | BindingFlags.Instance | BindingFlags.Public, null, new Type[] {tUnder}, null); //ExactBinding InvokeMethod if (exactWriteMethod != null) { //if (imprecise) // ilg.Emit (OpCodes.Castclass, tUnder); ilg.Emit (exactWriteMethod.IsFinal ? OpCodes.Call : OpCodes.Callvirt, exactWriteMethod); } else { //..boxed if necessary if (t.IsValueType) ilg.Emit (OpCodes.Box, t); //the Type parameter ilg.Emit (OpCodes.Ldtoken, t); ilg.Emit (OpCodes.Call, getTypeFromHandleMethod); ilg.Emit (messageWriterWriteMethod.IsFinal ? OpCodes.Call : OpCodes.Callvirt, messageWriterWriteMethod); } } //takes a writer and a reference to an object off the stack public static void GenMarshalWrite (ILGenerator ilg, Type type) { LocalBuilder val = ilg.DeclareLocal (type); ilg.Emit (OpCodes.Stloc, val); LocalBuilder writer = ilg.DeclareLocal (typeof (MessageWriter)); ilg.Emit (OpCodes.Stloc, writer); FieldInfo[] fis = type.GetFields (BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); //align to 8 for structs ilg.Emit (OpCodes.Ldloc, writer); ilg.Emit (OpCodes.Ldc_I4, 8); ilg.Emit (messageWriterWritePad.IsFinal ? OpCodes.Call : OpCodes.Callvirt, messageWriterWritePad); foreach (FieldInfo fi in fis) { Type t = fi.FieldType; //the Writer to write to ilg.Emit (OpCodes.Ldloc, writer); //the object parameter ilg.Emit (OpCodes.Ldloc, val); ilg.Emit (OpCodes.Ldfld, fi); GenWriter (ilg, t); } } public static void GenHookupMethod (ILGenerator ilg, MethodInfo declMethod, MethodInfo invokeMethod, string @interface, string member) { ParameterInfo[] parms = declMethod.GetParameters (); Type retType = declMethod.ReturnType; //the BusObject instance ilg.Emit (OpCodes.Ldarg_0); //MethodInfo /* ilg.Emit (OpCodes.Ldtoken, declMethod); ilg.Emit (OpCodes.Call, getMethodFromHandleMethod); */ //interface ilg.Emit (OpCodes.Ldstr, @interface); //special case event add/remove methods if (declMethod.IsSpecialName && (declMethod.Name.StartsWith ("add_") || declMethod.Name.StartsWith ("remove_"))) { string[] parts = declMethod.Name.Split (new char[]{'_'}, 2); string ename = parts[1]; //Delegate dlg = (Delegate)inArgs[0]; bool adding = parts[0] == "add"; ilg.Emit (OpCodes.Ldstr, ename); ilg.Emit (OpCodes.Ldarg_1); ilg.Emit (OpCodes.Ldc_I4, adding ? 1 : 0); ilg.Emit (OpCodes.Tailcall); ilg.Emit (toggleSignalMethod.IsFinal ? OpCodes.Call : OpCodes.Callvirt, toggleSignalMethod); ilg.Emit (OpCodes.Ret); return; } //property accessor mapping if (declMethod.IsSpecialName) { if (member.StartsWith ("get_")) member = "Get" + member.Substring (4); else if (member.StartsWith ("set_")) member = "Set" + member.Substring (4); } //member ilg.Emit (OpCodes.Ldstr, member); //signature Signature inSig = Signature.Empty; Signature outSig = Signature.Empty; if (!declMethod.IsSpecialName) foreach (ParameterInfo parm in parms) { if (parm.IsOut) outSig += Signature.GetSig (parm.ParameterType.GetElementType ()); else inSig += Signature.GetSig (parm.ParameterType); } ilg.Emit (OpCodes.Ldstr, inSig.Value); LocalBuilder writer = ilg.DeclareLocal (typeof (MessageWriter)); ilg.Emit (OpCodes.Newobj, messageWriterConstructor); ilg.Emit (OpCodes.Stloc, writer); foreach (ParameterInfo parm in parms) { if (parm.IsOut) continue; Type t = parm.ParameterType; //offset by one to account for "this" int i = parm.Position + 1; //null checking of parameters (but not their recursive contents) if (!t.IsValueType) { Label notNull = ilg.DefineLabel (); //if the value is null... ilg.Emit (OpCodes.Ldarg, i); ilg.Emit (OpCodes.Brtrue_S, notNull); //...throw Exception string paramName = parm.Name; ilg.Emit (OpCodes.Ldstr, paramName); ilg.Emit (OpCodes.Newobj, argumentNullExceptionConstructor); ilg.Emit (OpCodes.Throw); //was not null, so all is well ilg.MarkLabel (notNull); } ilg.Emit (OpCodes.Ldloc, writer); //the parameter ilg.Emit (OpCodes.Ldarg, i); GenWriter (ilg, t); } ilg.Emit (OpCodes.Ldloc, writer); //the expected return Type ilg.Emit (OpCodes.Ldtoken, retType); ilg.Emit (OpCodes.Call, getTypeFromHandleMethod); LocalBuilder exc = ilg.DeclareLocal (typeof (Exception)); ilg.Emit (OpCodes.Ldloca_S, exc); //make the call ilg.Emit (invokeMethod.IsFinal ? OpCodes.Call : OpCodes.Callvirt, invokeMethod); //define a label we'll use to deal with a non-null Exception Label noErr = ilg.DefineLabel (); //if the out Exception is not null... ilg.Emit (OpCodes.Ldloc, exc); ilg.Emit (OpCodes.Brfalse_S, noErr); //...throw it. ilg.Emit (OpCodes.Ldloc, exc); ilg.Emit (OpCodes.Throw); //Exception was null, so all is well ilg.MarkLabel (noErr); if (retType == typeof (void)) { //we aren't expecting a return value, so throw away the (hopefully) null return if (invokeMethod.ReturnType != typeof (void)) ilg.Emit (OpCodes.Pop); } else { if (retType.IsValueType) ilg.Emit (OpCodes.Unbox_Any, retType); else ilg.Emit (OpCodes.Castclass, retType); } ilg.Emit (OpCodes.Ret); } } } aircrack-ng-1.6/lib/csharp/MonoExample/NDesk-dbus/UnixNativeTransport.cs000066400000000000000000000163501361312141100263060ustar00rootroot00000000000000// Copyright 2006 Alp Toker // This software is made available under the MIT License // See COPYING for details //We send BSD-style credentials on all platforms //Doesn't seem to break Linux (but is redundant there) //This may turn out to be a bad idea #define HAVE_CMSGCRED using System; using System.IO; using System.Text; using System.Runtime.InteropServices; using Mono.Unix; using Mono.Unix.Native; namespace NDesk.DBus.Transports { class UnixSocket { public const short AF_UNIX = 1; //TODO: SOCK_STREAM is 2 on Solaris public const short SOCK_STREAM = 1; //TODO: some of these are provided by libsocket instead of libc on Solaris [DllImport ("libc", SetLastError=true)] protected static extern int socket (int domain, int type, int protocol); [DllImport ("libc", SetLastError=true)] protected static extern int connect (int sockfd, byte[] serv_addr, uint addrlen); [DllImport ("libc", SetLastError=true)] protected static extern int bind (int sockfd, byte[] my_addr, uint addrlen); [DllImport ("libc", SetLastError=true)] protected static extern int listen (int sockfd, int backlog); //TODO: this prototype is probably wrong, fix it [DllImport ("libc", SetLastError=true)] protected static extern int accept (int sockfd, byte[] addr, ref uint addrlen); //TODO: confirm and make use of these functions [DllImport ("libc", SetLastError=true)] protected static extern int getsockopt (int s, int optname, IntPtr optval, ref uint optlen); [DllImport ("libc", SetLastError=true)] protected static extern int setsockopt (int s, int optname, IntPtr optval, uint optlen); [DllImport ("libc", SetLastError=true)] public static extern int recvmsg (int s, IntPtr msg, int flags); [DllImport ("libc", SetLastError=true)] public static extern int sendmsg (int s, IntPtr msg, int flags); public int Handle; public UnixSocket (int handle) { this.Handle = handle; } public UnixSocket () { //TODO: don't hard-code PF_UNIX and SOCK_STREAM or SocketType.Stream //AddressFamily family, SocketType type, ProtocolType proto int r = socket (AF_UNIX, SOCK_STREAM, 0); //we should get the Exception from UnixMarshal and throw it here for a better stack trace, but the relevant API seems to be private UnixMarshal.ThrowExceptionForLastErrorIf (r); Handle = r; } protected bool connected = false; //TODO: consider memory management public void Connect (byte[] remote_end) { int r = connect (Handle, remote_end, (uint)remote_end.Length); //we should get the Exception from UnixMarshal and throw it here for a better stack trace, but the relevant API seems to be private UnixMarshal.ThrowExceptionForLastErrorIf (r); connected = true; } //assigns a name to the socket public void Bind (byte[] local_end) { int r = bind (Handle, local_end, (uint)local_end.Length); UnixMarshal.ThrowExceptionForLastErrorIf (r); } public void Listen (int backlog) { int r = listen (Handle, backlog); UnixMarshal.ThrowExceptionForLastErrorIf (r); } public UnixSocket Accept () { byte[] addr = new byte[110]; uint addrlen = (uint)addr.Length; int r = accept (Handle, addr, ref addrlen); UnixMarshal.ThrowExceptionForLastErrorIf (r); //TODO: use the returned addr //TODO: fix probable memory leak here //string str = Encoding.Default.GetString (addr, 0, (int)addrlen); return new UnixSocket (r); } } struct IOVector { public IntPtr Base; public int Length; } class UnixNativeTransport : UnixTransport { protected UnixSocket socket; public override void Open (string path, bool @abstract) { if (String.IsNullOrEmpty (path)) throw new ArgumentException ("path"); if (@abstract) socket = OpenAbstractUnix (path); else socket = OpenUnix (path); //socket.Blocking = true; SocketHandle = (long)socket.Handle; Stream = new UnixStream ((int)socket.Handle); } //send peer credentials null byte //different platforms do this in different ways #if HAVE_CMSGCRED unsafe void WriteBsdCred () { //null credentials byte byte buf = 0; IOVector iov = new IOVector (); iov.Base = (IntPtr)(&buf); iov.Length = 1; msghdr msg = new msghdr (); msg.msg_iov = &iov; msg.msg_iovlen = 1; cmsg cm = new cmsg (); msg.msg_control = (IntPtr)(&cm); msg.msg_controllen = (uint)sizeof (cmsg); cm.hdr.cmsg_len = (uint)sizeof (cmsg); cm.hdr.cmsg_level = 0xffff; //SOL_SOCKET cm.hdr.cmsg_type = 0x03; //SCM_CREDS int written = UnixSocket.sendmsg (socket.Handle, (IntPtr)(&msg), 0); UnixMarshal.ThrowExceptionForLastErrorIf (written); if (written != 1) throw new Exception ("Failed to write credentials"); } #endif public override void WriteCred () { #if HAVE_CMSGCRED try { WriteBsdCred (); } catch { if (Protocol.Verbose) Console.Error.WriteLine ("Warning: WriteBsdCred() failed; falling back to ordinary WriteCred()"); //null credentials byte byte buf = 0; Stream.WriteByte (buf); } #else //null credentials byte byte buf = 0; Stream.WriteByte (buf); #endif } protected UnixSocket OpenAbstractUnix (string path) { byte[] p = Encoding.Default.GetBytes (path); byte[] sa = new byte[2 + 1 + p.Length]; //we use BitConverter to stay endian-safe byte[] afData = BitConverter.GetBytes (UnixSocket.AF_UNIX); sa[0] = afData[0]; sa[1] = afData[1]; sa[2] = 0; //null prefix for abstract domain socket addresses, see unix(7) for (int i = 0 ; i != p.Length ; i++) sa[3 + i] = p[i]; UnixSocket client = new UnixSocket (); client.Connect (sa); return client; } public UnixSocket OpenUnix (string path) { byte[] p = Encoding.Default.GetBytes (path); byte[] sa = new byte[2 + p.Length + 1]; //we use BitConverter to stay endian-safe byte[] afData = BitConverter.GetBytes (UnixSocket.AF_UNIX); sa[0] = afData[0]; sa[1] = afData[1]; for (int i = 0 ; i != p.Length ; i++) sa[2 + i] = p[i]; sa[2 + p.Length] = 0; //null suffix for domain socket addresses, see unix(7) UnixSocket client = new UnixSocket (); client.Connect (sa); return client; } } #if HAVE_CMSGCRED /* public struct msg { public IntPtr msg_next; public long msg_type; public ushort msg_ts; short msg_spot; IntPtr label; } */ unsafe struct msghdr { public IntPtr msg_name; //optional address public uint msg_namelen; //size of address public IOVector *msg_iov; //scatter/gather array public int msg_iovlen; //# elements in msg_iov public IntPtr msg_control; //ancillary data, see below public uint msg_controllen; //ancillary data buffer len public int msg_flags; //flags on received message } struct cmsghdr { public uint cmsg_len; //data byte count, including header public int cmsg_level; //originating protocol public int cmsg_type; //protocol-specific type } unsafe struct cmsgcred { public int cmcred_pid; //PID of sending process public uint cmcred_uid; //real UID of sending process public uint cmcred_euid; //effective UID of sending process public uint cmcred_gid; //real GID of sending process public short cmcred_ngroups; //number or groups public fixed uint cmcred_groups[16]; //groups, CMGROUP_MAX } struct cmsg { public cmsghdr hdr; public cmsgcred cred; } #endif } aircrack-ng-1.6/lib/csharp/MonoExample/NDesk-dbus/UnixTransport.cs000066400000000000000000000014251361312141100251340ustar00rootroot00000000000000// Copyright 2006 Alp Toker // This software is made available under the MIT License // See COPYING for details using System; using System.IO; using Mono.Unix; namespace NDesk.DBus.Transports { abstract class UnixTransport : Transport { public override void Open (AddressEntry entry) { string path; bool abstr; if (entry.Properties.TryGetValue ("path", out path)) abstr = false; else if (entry.Properties.TryGetValue ("abstract", out path)) abstr = true; else throw new Exception ("No path specified for UNIX transport"); Open (path, abstr); } public override string AuthString () { long uid = UnixUserInfo.GetRealUserId (); return uid.ToString (); } public abstract void Open (string path, bool @abstract); } } aircrack-ng-1.6/lib/csharp/MonoExample/NDesk-dbus/Wrapper.cs000066400000000000000000000116561361312141100237230ustar00rootroot00000000000000// Copyright 2006 Alp Toker // This software is made available under the MIT License // See COPYING for details using System; using System.Collections.Generic; using System.IO; namespace NDesk.DBus { //TODO: complete and use these wrapper classes //not sure exactly what I'm thinking but there seems to be sense here //FIXME: signature sending/receiving is currently ambiguous in this code //FIXME: in fact, these classes are totally broken and end up doing no-op, do not use without understanding the problem class MethodCall { public Message message = new Message (); public MethodCall (ObjectPath path, string @interface, string member, string destination, Signature signature) { message.Header.MessageType = MessageType.MethodCall; message.ReplyExpected = true; message.Header.Fields[FieldCode.Path] = path; if (@interface != null) message.Header.Fields[FieldCode.Interface] = @interface; message.Header.Fields[FieldCode.Member] = member; message.Header.Fields[FieldCode.Destination] = destination; //TODO: consider setting Sender here for p2p situations //this will allow us to remove the p2p hacks in MethodCall and Message #if PROTO_REPLY_SIGNATURE //TODO #endif //message.Header.Fields[FieldCode.Signature] = signature; //use the wrapper in Message because it checks for emptiness message.Signature = signature; } public MethodCall (Message message) { this.message = message; Path = (ObjectPath)message.Header.Fields[FieldCode.Path]; if (message.Header.Fields.ContainsKey (FieldCode.Interface)) Interface = (string)message.Header.Fields[FieldCode.Interface]; Member = (string)message.Header.Fields[FieldCode.Member]; Destination = (string)message.Header.Fields[FieldCode.Destination]; //TODO: filled by the bus so reliable, but not the case for p2p //so we make it optional here, but this needs some more thought if (message.Header.Fields.ContainsKey (FieldCode.Sender)) Sender = (string)message.Header.Fields[FieldCode.Sender]; #if PROTO_REPLY_SIGNATURE //TODO: note that an empty ReplySignature should really be treated differently to the field not existing! if (message.Header.Fields.ContainsKey (FieldCode.ReplySignature)) ReplySignature = (Signature)message.Header.Fields[FieldCode.ReplySignature]; else ReplySignature = Signature.Empty; #endif //Signature = (Signature)message.Header.Fields[FieldCode.Signature]; //use the wrapper in Message because it checks for emptiness Signature = message.Signature; } public ObjectPath Path; public string Interface; public string Member; public string Destination; public string Sender; #if PROTO_REPLY_SIGNATURE public Signature ReplySignature; #endif public Signature Signature; } class MethodReturn { public Message message = new Message (); public MethodReturn (uint reply_serial) { message.Header.MessageType = MessageType.MethodReturn; message.Header.Flags = HeaderFlag.NoReplyExpected | HeaderFlag.NoAutoStart; message.Header.Fields[FieldCode.ReplySerial] = reply_serial; //signature optional? //message.Header.Fields[FieldCode.Signature] = signature; } public MethodReturn (Message message) { this.message = message; ReplySerial = (uint)message.Header.Fields[FieldCode.ReplySerial]; } public uint ReplySerial; } class Error { public Message message = new Message (); public Error (string error_name, uint reply_serial) { message.Header.MessageType = MessageType.Error; message.Header.Flags = HeaderFlag.NoReplyExpected | HeaderFlag.NoAutoStart; message.Header.Fields[FieldCode.ErrorName] = error_name; message.Header.Fields[FieldCode.ReplySerial] = reply_serial; } public Error (Message message) { this.message = message; ErrorName = (string)message.Header.Fields[FieldCode.ErrorName]; ReplySerial = (uint)message.Header.Fields[FieldCode.ReplySerial]; //Signature = (Signature)message.Header.Fields[FieldCode.Signature]; } public string ErrorName; public uint ReplySerial; //public Signature Signature; } class Signal { public Message message = new Message (); public Signal (ObjectPath path, string @interface, string member) { message.Header.MessageType = MessageType.Signal; message.Header.Flags = HeaderFlag.NoReplyExpected | HeaderFlag.NoAutoStart; message.Header.Fields[FieldCode.Path] = path; message.Header.Fields[FieldCode.Interface] = @interface; message.Header.Fields[FieldCode.Member] = member; } public Signal (Message message) { this.message = message; Path = (ObjectPath)message.Header.Fields[FieldCode.Path]; Interface = (string)message.Header.Fields[FieldCode.Interface]; Member = (string)message.Header.Fields[FieldCode.Member]; if (message.Header.Fields.ContainsKey (FieldCode.Sender)) Sender = (string)message.Header.Fields[FieldCode.Sender]; } public ObjectPath Path; public string Interface; public string Member; public string Sender; } } aircrack-ng-1.6/lib/csharp/MonoExample/NDesk-dbus/ndesk.snk000066400000000000000000000003541361312141100235660ustar00rootroot00000000000000$RSA2dTeM炗-ԼKv,?uOrT)6;݃_tRci?DZʍAh(H빧2$ѕw^E@*iGICD.!@a6t2 mϧd>7}G.uAU@;tKd_'X<{ qafM6[۸/5on *R­el~jaircrack-ng-1.6/lib/csharp/MonoExample/NewStationNotify.sln000066400000000000000000000035171361312141100240140ustar00rootroot00000000000000 Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NewStationNotify", "NewStationNotify\NewStationNotify.csproj", "{82B5448F-10AA-4BE0-9C20-DEA6441C9146}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NDesk-dbus", "NDesk-dbus\NDesk-dbus.csproj", "{223B034E-A2F0-4BC7-875A-F9B5972C0670}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WirelessPanda", "..\WirelessPanda\WirelessPanda.csproj", "{F3A06E01-20E6-4CF8-AD62-1034A0B4EAE3}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x86 = Debug|x86 Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {223B034E-A2F0-4BC7-875A-F9B5972C0670}.Debug|x86.ActiveCfg = Debug|Any CPU {223B034E-A2F0-4BC7-875A-F9B5972C0670}.Debug|x86.Build.0 = Debug|Any CPU {223B034E-A2F0-4BC7-875A-F9B5972C0670}.Release|x86.ActiveCfg = Release|Any CPU {223B034E-A2F0-4BC7-875A-F9B5972C0670}.Release|x86.Build.0 = Release|Any CPU {82B5448F-10AA-4BE0-9C20-DEA6441C9146}.Debug|x86.ActiveCfg = Debug|x86 {82B5448F-10AA-4BE0-9C20-DEA6441C9146}.Debug|x86.Build.0 = Debug|x86 {82B5448F-10AA-4BE0-9C20-DEA6441C9146}.Release|x86.ActiveCfg = Release|x86 {82B5448F-10AA-4BE0-9C20-DEA6441C9146}.Release|x86.Build.0 = Release|x86 {F3A06E01-20E6-4CF8-AD62-1034A0B4EAE3}.Debug|x86.ActiveCfg = Debug|Any CPU {F3A06E01-20E6-4CF8-AD62-1034A0B4EAE3}.Debug|x86.Build.0 = Debug|Any CPU {F3A06E01-20E6-4CF8-AD62-1034A0B4EAE3}.Release|x86.ActiveCfg = Release|Any CPU {F3A06E01-20E6-4CF8-AD62-1034A0B4EAE3}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(MonoDevelopProperties) = preSolution StartupItem = NewStationNotify\NewStationNotify.csproj EndGlobalSection EndGlobal aircrack-ng-1.6/lib/csharp/MonoExample/NewStationNotify/000077500000000000000000000000001361312141100232705ustar00rootroot00000000000000aircrack-ng-1.6/lib/csharp/MonoExample/NewStationNotify/AssemblyInfo.cs000066400000000000000000000020011361312141100262030ustar00rootroot00000000000000using System.Reflection; using System.Runtime.CompilerServices; // Information about this assembly is defined by the following attributes. // Change them to the values specific to your project. [assembly: AssemblyTitle("NewStationNotify")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("")] [assembly: AssemblyCopyright("Thomas d'Otreppe")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". // The form "{Major}.{Minor}.*" will automatically update the build and revision, // and "{Major}.{Minor}.{Build}.*" will update just the revision. [assembly: AssemblyVersion("1.0.*")] // The following attributes are used to specify the signing key for the assembly, // if desired. See the Mono documentation for more information about signing. //[assembly: AssemblyDelaySign(false)] //[assembly: AssemblyKeyFile("")] aircrack-ng-1.6/lib/csharp/MonoExample/NewStationNotify/Main.cs000066400000000000000000000023661361312141100245120ustar00rootroot00000000000000// License: BSD/LGPL // Copyright (C) 2011-2018 Thomas d'Otreppe // using System.Threading; using WirelessPanda.Readers; using WirelessPanda; using System.Collections; using System.Collections.Generic; using System; namespace NewStationNotify { class MainClass { public static void Main (string[] args) { Console.WriteLine(DateTime.Now + " - Program started"); Reader r = new UniversalReader("/home/user/dump-01.csv"); List stationList = new List(); // Read the file r.Read(); // Add existing stations to the list stationList.AddRange(r.Stations); while (true) { // Sleep 5 seconds Thread.Sleep(5000); Console.WriteLine(DateTime.Now + " - Checking for updates"); // Update file r.Read(); // Get station list foreach(Station sta in r.Stations) { // If new station, update us if (!stationList.Contains(sta)) { stationList.Add(sta); // Display it on the command line Console.WriteLine(DateTime.Now + " - New station: " + sta.StationMAC); // Display it as a notification Notification.Notify(sta.BSSID, sta.StationMAC); } } } } } } aircrack-ng-1.6/lib/csharp/MonoExample/NewStationNotify/NewStationNotify.csproj000066400000000000000000000043031361312141100277760ustar00rootroot00000000000000 Debug x86 8.0.50727 2.0 {82B5448F-10AA-4BE0-9C20-DEA6441C9146} Exe NewStationNotify NewStationNotify v4.0 true full false bin\Debug DEBUG prompt 4 x86 true none false bin\Release prompt 4 x86 true {223B034E-A2F0-4BC7-875A-F9B5972C0670} NDesk-dbus {F3A06E01-20E6-4CF8-AD62-1034A0B4EAE3} WirelessPanda aircrack-ng-1.6/lib/csharp/MonoExample/NewStationNotify/NewStationNotify.pidb000066400000000000000000000205461361312141100274230ustar00rootroot00000000000000System.Collections.Hashtable LoadFactorVersionComparerHashCodeProviderHashSizeKeysValues System.Collections.IComparer$System.Collections.IHashCodeProviderQ8?   LastValidTaskListTokensVersionFIXME:2;TODO:1;HACK:1;UNDONE:0T f Notification  =gC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NewStationNotify\Notification.cshNewStationNotify iNotifyj8 Shows a notification on the screen 9<kBSSID$lstaMac2xf MainClass  6gC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NewStationNotify\Main.cshNewStationNotifyiMain*5jSystemkString% fC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NewStationNotify\AssemblyInfo.csg AssemblyTitle  hSystem.ReflectioniAssemblyTitleAttributejNewStationNotifyfkAssemblyDescription  hlAssemblyDescriptionAttributefmAssemblyConfiguration hnAssemblyConfigurationAttributefoAssemblyCompany hpAssemblyCompanyAttributefqAssemblyProduct hrAssemblyProductAttributefsAssemblyCopyright htAssemblyCopyrightAttributeuThomas d'OtreppefvAssemblyTrademark hwAssemblyTrademarkAttributefxAssemblyCulture  hyAssemblyCultureAttributefzAssemblyVersion  h{AssemblyVersionAttribute|1.0.*     GMonoDevelop.Core, Version=2.6.0.0, Culture=neutral, PublicKeyToken=nullSystem.Collections.Generic.List`1[[MonoDevelop.Projects.Dom.ReferenceEntry, MonoDevelop.Core, Version=2.6.0.0, Culture=neutral, PublicKeyToken=null]]_items_size_version)MonoDevelop.Projects.Dom.ReferenceEntry[] System.Collections.Generic.Dictionary`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[MonoDevelop.Projects.Dom.Serialization.ClassEntry, MonoDevelop.Core, Version=2.6.0.0, Culture=neutral, PublicKeyToken=null]]VersionComparerHashSize KeyValuePairsSystem.Collections.Generic.GenericEqualityComparer`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]System.Collections.Generic.KeyValuePair`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[MonoDevelop.Projects.Dom.Serialization.ClassEntry, MonoDevelop.Core, Version=2.6.0.0, Culture=neutral, PublicKeyToken=null]][]P  System.Collections.Generic.Dictionary`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[MonoDevelop.Projects.Dom.Serialization.FileEntry, MonoDevelop.Core, Version=2.6.0.0, Culture=neutral, PublicKeyToken=null]]VersionComparerHashSize KeyValuePairsSystem.Collections.Generic.GenericEqualityComparer`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]System.Collections.Generic.KeyValuePair`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[MonoDevelop.Projects.Dom.Serialization.FileEntry, MonoDevelop.Core, Version=2.6.0.0, Culture=neutral, PublicKeyToken=null]][]  System.Collections.Hashtable LoadFactorVersionComparerHashCodeProviderHashSizeKeysValues System.Collections.IComparer$System.Collections.IHashCodeProviderQ8?  'MonoDevelop.Projects.Dom.ReferenceEntry     System.Collections.Generic.GenericEqualityComparer`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] System.Collections.Generic.KeyValuePair`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[MonoDevelop.Projects.Dom.Serialization.ClassEntry, MonoDevelop.Core, Version=2.6.0.0, Culture=neutral, PublicKeyToken=null]]System.Collections.Generic.KeyValuePair`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[MonoDevelop.Projects.Dom.Serialization.ClassEntry, MonoDevelop.Core, Version=2.6.0.0, Culture=neutral, PublicKeyToken=null]]keyvalue1MonoDevelop.Projects.Dom.Serialization.ClassEntryNewStationNotify.Notification NewStationNotify.MainClass  System.Collections.Generic.KeyValuePair`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[MonoDevelop.Projects.Dom.Serialization.FileEntry, MonoDevelop.Core, Version=2.6.0.0, Culture=neutral, PublicKeyToken=null]]System.Collections.Generic.KeyValuePair`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[MonoDevelop.Projects.Dom.Serialization.FileEntry, MonoDevelop.Core, Version=2.6.0.0, Culture=neutral, PublicKeyToken=null]]keyvalue0MonoDevelop.Projects.Dom.Serialization.FileEntryC:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NewStationNotify\Main.cs C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NewStationNotify\AssemblyInfo.cs C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NewStationNotify\Notification.cs   'MonoDevelop.Projects.Dom.ReferenceEntry databaseUri!JAssembly:MS.NET:C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll"HAssembly:MS.NET:C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\System.dll#Project:C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\MonoExample\NDesk-dbus\NDesk-dbus.csproj$Project:C:\Documents and Settings\The Baron\My Documents\Visual Studio 2010\Projects\WirelessPanda\WirelessPanda\WirelessPanda.csproj1MonoDevelop.Projects.Dom.Serialization.ClassEntry positionnspacenametypeParameterCount subclassesflagsctype modifiers typeModifier System.Collections.ArrayList3MonoDevelop.Projects.Dom.Serialization.ContentFlags"MonoDevelop.Projects.Dom.ClassType"MonoDevelop.Projects.Dom.Modifiers%MonoDevelop.Projects.Dom.TypeModifierL%NewStationNotify& Notification 3MonoDevelop.Projects.Dom.Serialization.ContentFlagsvalue__N"MonoDevelop.Projects.Dom.ClassTypevalue__"MonoDevelop.Projects.Dom.Modifiersvalue__%MonoDevelop.Projects.Dom.TypeModifiervalue__> %, MainClass 0MonoDevelop.Projects.Dom.Serialization.FileEntryfilePath parseTimeparseErrorRetries commentTasksclasses System.Collections.Generic.List`1[[MonoDevelop.Projects.Dom.Tag, MonoDevelop.Core, Version=2.6.0.0, Culture=neutral, PublicKeyToken=null]] e\͈ 2  Ia͈ 5   }V͈ 7 2System.Collections.Generic.List`1[[MonoDevelop.Projects.Dom.Tag, MonoDevelop.Core, Version=2.6.0.0, Culture=neutral, PublicKeyToken=null]]_items_size_versionMonoDevelop.Projects.Dom.Tag[] 952 972 99MonoDevelop.Projects.Dom.Tag aircrack-ng-1.6/lib/csharp/MonoExample/NewStationNotify/Notification.cs000066400000000000000000000046771361312141100262630ustar00rootroot00000000000000// License: BSD // Copyright (C) 2011-2018 Thomas d'Otreppe using System; using System.Collections.Generic; using NDesk.DBus; using org.freedesktop; namespace NewStationNotify { public class Notification { public Notification () { } /// /// Shows a notification on the screen. This has been tested on a N900 and will probably not work with anything else but it can be used as a base. /// public static void Notify(String BSSID, String staMac) { Bus bus = Bus.Session; Notifications nf = bus.GetObject ("org.freedesktop.Notifications", new ObjectPath ("/org/freedesktop/Notifications")); Dictionary hints = new Dictionary (); if (string.IsNullOrEmpty(BSSID)) { nf.Notify ("Notification", 0, "control_bluetooth_paired", "New unassociated station", staMac, new string[0], hints, 0); } else { nf.Notify ("Notification", 0, "control_bluetooth_paired", "New associated station", staMac + " (AP: " + BSSID + ")", new string[0], hints, 0); } /* // Ugly hack for the N900 to notify the user since this can't be done with dbus-send // because it does not support empty array. StreamWriter sw = new StreamWriter("/home/user/notify.py"); if (string.IsNullOrEmpty(BSSID)) { sw.WriteLine("import dbus\n" + "bus = dbus.SessionBus()\n" + "proxy = bus.get_object('org.freedesktop.Notifications', '/org/freedesktop/Notifications')\n" + "interface = dbus.Interface(proxy,dbus_interface='org.freedesktop.Notifications')\n" + "interface.Notify('Notification', 0, 'control_bluetooth_paired', 'New unassociated station', '{0}', [], {{}}, 0)", staMac); } else { sw.WriteLine("import dbus\n" + "bus = dbus.SessionBus()\n" + "proxy = bus.get_object('org.freedesktop.Notifications', '/org/freedesktop/Notifications')\n" + "interface = dbus.Interface(proxy,dbus_interface='org.freedesktop.Notifications')\n" + "interface.Notify('Notification', 0, 'control_bluetooth_paired', 'New associated station', '{0} is associated to {1}', [], {{}}, 0)", staMac, BSSID); } sw.Close(); Process p = new Process(); p.StartInfo.UseShellExecute = false; p.StartInfo.FileName = "/usr/bin/python"; p.StartInfo.Arguments = "/home/user/notify.py"; p.Start(); p.WaitForExit(); FileInfo f = new FileInfo("/home/user/notify.py"); f.Delete(); */ } } } aircrack-ng-1.6/lib/csharp/WirelessPanda/000077500000000000000000000000001361312141100203215ustar00rootroot00000000000000aircrack-ng-1.6/lib/csharp/WirelessPanda/AccessPoint.cs000066400000000000000000000272401361312141100230700ustar00rootroot00000000000000// License: BSD/LGPL // Copyright (C) 2011-2018 Thomas d'Otreppe using System; using System.Collections.Generic; namespace WirelessPanda { public class AccessPoint : WirelessDevice, IEquatable { #region Properties /// /// Max Rate /// public double MaxRate { get { return (double)this.getDictValue("Max Rate"); } set { this.setDictValue("Max Rate", value); } } /// /// Max Seen Rate /// public double MaxSeenRate { get { return (double)this.getDictValue("Max Seen Rate"); } set { this.setDictValue("Max Seen Rate", value); } } /// /// Privacy /// public string Privacy { get { return (string)this.getDictValue("Privacy"); } set { this.setDictValue("Privacy", value); } } /// /// Cipher /// public string Cipher { get { return (string)this.getDictValue("Cipher"); } set { this.setDictValue("Cipher", value); } } /// /// Authentication /// public string Authentication { get { return (string)this.getDictValue("Authentication"); } set { this.setDictValue("Authentication", value); } } /// /// # Data Frames /// public ulong DataFrames { get { return (ulong)this.getDictValue("Data"); } set { this.setDictValue("Data", value); } } /// /// Beacons /// public long Beacons { get { return (long)this.getDictValue("Beacons"); } set { this.setDictValue("Beacons", value); } } /// /// IP Address /// public string IP { get { return (string)this.getDictValue("IP"); } set { this.setDictValue("IP", value); } } /// /// IP Type /// public int IPType { get { return (int)this.getDictValue("IP Type"); } set { this.setDictValue("IP Type", value); } } /// /// ESSID /// public string ESSID { get { return (string)this.getDictValue("ESSID"); } set { this.setDictValue("ESSID", value); } } /// /// ESSID Length /// public byte ESSIDLength { get { return (byte)this.getDictValue("ESSID Length"); } set { this.setDictValue("ESSID Length", value); } } /// /// Key /// public string Key { get { return (string)this.getDictValue("Key"); } set { this.setDictValue("Key", value); } } /// /// Network Type /// public string NetworkType { get { return (string)this.getDictValue("Network Type"); } set { this.setDictValue("Network Type", value); } } /// /// Info /// public string Info { get { return (string)this.getDictValue("Info"); } set { this.setDictValue("Info", value); } } /// /// Encoding /// public string Encoding { get { return (string)this.getDictValue("Encoding"); } set { this.setDictValue("Encoding", value); } } /// /// Cloaked ? /// public bool Cloaked { get { return (bool)this.getDictValue("Cloaked"); } set { this.setDictValue("Cloaked", value); } } /// /// Encryption /// public string Encryption { get { return (string)this.getDictValue("Encryption"); } set { this.setDictValue("Encryption", value); } } /// /// Is the traffic decrypted? /// public bool Decrypted { get { return (bool)this.getDictValue("Decrypted"); } set { this.setDictValue("Decrypted", value); } } /// /// # Beacon Frames /// public ulong Beacon { get { return (ulong)this.getDictValue("Beacon"); } set { this.setDictValue("Beacon", value); } } /// /// # LLC Frames /// public ulong LLC { get { return (ulong)this.getDictValue("LLC"); } set { this.setDictValue("LLC", value); } } /// /// # Crypt Frames /// public ulong Crypt { get { return (ulong)this.getDictValue("Crypt"); } set { this.setDictValue("Crypt", value); } } /// /// # Weak Frames /// public ulong Weak { get { return (ulong)this.getDictValue("Weak"); } set { this.setDictValue("Weak", value); } } /// /// Total Nb of Frames /// public ulong Total { get { return (ulong)this.getDictValue("Total"); } set { this.setDictValue("Total", value); } } /// /// Carrier /// public string Carrier { get { return (string)this.getDictValue("Carrier"); } set { this.setDictValue("Carrier", value); } } /// /// Best Quality /// public int BestQuality { get { return (int)this.getDictValue("BestQuality"); } set { this.setDictValue("BestQuality", value); } } /// /// Best Signal /// public int BestSignal { get { return (int)this.getDictValue("Best Signal"); } set { this.setDictValue("Best Signal", value); } } /// /// Best Noise /// public int BestNoise { get { return (int)this.getDictValue("Best Noise"); } set { this.setDictValue("Best Noise", value); } } /// /// Min Location /// public Coordinates MinLocation { get { return (Coordinates)this.getDictValue("Min Location"); } set { this.setDictValue("Min Location", value); } } /// /// Best Location /// public Coordinates BestLocation { get { return (Coordinates)this.getDictValue("Best Location"); } set { this.setDictValue("Best Location", value); } } /// /// Max Location /// public Coordinates MaxLocation { get { return (Coordinates)this.getDictValue("Max Location"); } set { this.setDictValue("Max Location", value); } } /// /// Data Size /// public ulong DataSize { get { return (ulong)this.getDictValue("Data Size"); } set { this.setDictValue("Data Size", value); } } #endregion /// /// Internal list of client /// private List _clientList = new List(); /// /// Add a client to our list /// /// public void addClient(Station sta) { this._clientList.Add(sta); sta.AP = this; } /// /// Returns the client list /// public List ClientList { get { return this._clientList; } } /// /// Implements IEquatable /// /// Other AccessPoint to compare to /// true if equals, false if not public bool Equals(AccessPoint other) { try { if (this.BSSID == other.BSSID) { return true; } } catch { } return false; } } } aircrack-ng-1.6/lib/csharp/WirelessPanda/Coordinates.cs000066400000000000000000000104331361312141100231230ustar00rootroot00000000000000// License: BSD/LGPL // Copyright (C) 2011-2018 Thomas d'Otreppe using System; using System.Collections; using System.Text; namespace WirelessPanda { public class Coordinates { #region Dictionary stuff private Hashtable _dictionary = new Hashtable(); private void setDictValue(string elem, double value) { if (this._dictionary.ContainsKey(elem)) { this._dictionary.Remove(elem); } this._dictionary.Add(elem, value); } private double getDictValue(string elem) { if (this._dictionary.ContainsKey(elem)) { return (double)this._dictionary[elem]; } throw new MissingFieldException("Value <" + elem + "> is not set or does not exist"); } #endregion #region Properties /// /// Latitude /// public double Latitude { get { return this.getDictValue("Latitude"); } set { this.setDictValue("Latitude", value); } } /// /// Longitude /// public double Longitude { get { return this.getDictValue("Longitude"); } set { this.setDictValue("Longitude", value); } } /// /// Altitude (in meters) /// public double Altitude { get { return this.getDictValue("Altitude"); } set { this.setDictValue("Altitude", value); } } /// /// Speed (UOM: probably knot but unsure) /// public double Speed { get { return this.getDictValue("Speed"); } set { this.setDictValue("Speed", value); } } #endregion public Coordinates(string latitude = null, string longitude = null, string altitude = null, string speed = null) { if (!string.IsNullOrEmpty(latitude)) { this.Latitude = double.Parse(latitude); } if (!string.IsNullOrEmpty(longitude)) { this.Longitude = double.Parse(longitude); } if (!string.IsNullOrEmpty(altitude)) { this.Altitude = double.Parse(altitude); } if (!string.IsNullOrEmpty(speed)) { this.Speed = double.Parse(speed); } } public Coordinates(double latitude, double longitude) { this.Latitude = latitude; } public Coordinates(double latitude, double longitude, double altitude) : this(latitude, longitude) { this.Altitude = latitude; } public Coordinates(double latitude, double longitude, double altitude, double speed) : this(latitude, longitude, altitude) { this.Speed = speed; } public override string ToString() { StringBuilder sb = new StringBuilder(); try { sb.Append(this.Latitude); sb.Append(", "); sb.Append(this.Longitude); if (this._dictionary.ContainsKey("Altitude")) { sb.Append(" - Altitude: "); sb.Append(this.Altitude); } if (this._dictionary.ContainsKey("Speed")) { sb.Append(" - Speed: "); sb.Append(this.Speed); } } catch { if (sb.Length > 0) { sb.Remove(0, sb.Length); } } return sb.ToString(); } } } aircrack-ng-1.6/lib/csharp/WirelessPanda/Properties/000077500000000000000000000000001361312141100224555ustar00rootroot00000000000000aircrack-ng-1.6/lib/csharp/WirelessPanda/Properties/AssemblyInfo.cs000066400000000000000000000026711361312141100254050ustar00rootroot00000000000000using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("WirelessPanda")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Aircrack-ng")] [assembly: AssemblyProduct("WirelessPanda")] [assembly: AssemblyCopyright("Copyright © Aircrack-ng team 2011")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("17562500-6dc8-4460-a427-440ea5f27f26")] // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] aircrack-ng-1.6/lib/csharp/WirelessPanda/Readers/000077500000000000000000000000001361312141100217065ustar00rootroot00000000000000aircrack-ng-1.6/lib/csharp/WirelessPanda/Readers/NetXMLReader.cs000066400000000000000000000024661361312141100244770ustar00rootroot00000000000000using System; namespace WirelessPanda.Readers { // See http://msdn.microsoft.com/en-us/library/cc189056(v=vs.95).aspx public class NetXMLReader : Reader { /// /// Date format (Same format for Kismet CSV and NetXML) /// protected override string DATE_FORMAT { get { return "ddd MMM dd HH:mm:ss yyyy"; } } /// /// Date format (Same format for Kismet CSV and NetXML) /// protected override string ALT_DATE_FORMAT { get { return "ddd MMM d HH:mm:ss yyyy"; } } /// /// Reader type /// public override string ReaderType { get { return "Kismet NetXML"; } } /// /// Constructor /// /// Filename (doesn't need to exist now but MUST when using Read() ) public NetXMLReader(string filename) : base(filename) { throw new NotImplementedException("NetXML parser not implemented yet"); } } } aircrack-ng-1.6/lib/csharp/WirelessPanda/Readers/Reader.cs000066400000000000000000000312411361312141100234400ustar00rootroot00000000000000// License: BSD/LGPL // Copyright (C) 2011-2018 Thomas d'Otreppe using System; using System.Collections; using System.Collections.Generic; using System.Data; using System.IO; namespace WirelessPanda.Readers { public class Reader { public const string ACCESSPOINTS_DATATABLE = "Access Points"; public const string STATIONS_DATATABLE = "Stations"; #region Private members private DataSet _dataset = new DataSet(); private List _accessPoints = new List(); private List _stations = new List(); private string _filename = string.Empty; private bool _parseSuccess = false; #endregion #region Properties /// /// Returns true if the file exist /// public bool FileExist { get { return File.Exists(this._filename); } } /// /// DataSet containing 2 tables: "Access Points" and "Stations" /// public virtual DataSet Dataset { get { return this._dataset; } } /// /// Was the file parsed successfully? /// public bool ParseSuccess { get { return this._parseSuccess; } protected set { this._parseSuccess = value; } } /// /// Array of access points /// public virtual AccessPoint[] AccessPoints { get { return this._accessPoints.ToArray().Clone() as AccessPoint[]; } } /// /// Array of stations /// public virtual Station[] Stations { get { return this._stations.ToArray().Clone() as Station[]; } } /// /// Filename /// public string Filename { get { return this._filename; } } /// /// Reader type /// public virtual string ReaderType { get { return "Unknown"; } } /// /// Reader type /// protected virtual string DATE_FORMAT { get { return null; } } /// /// Reader type /// protected virtual string ALT_DATE_FORMAT { get { return null; } } #endregion /// /// Constructor /// /// Filename (doesn't need to exist now but MUST when using Read() ) public Reader(string filename) { if (string.IsNullOrEmpty(filename)) { throw new FileNotFoundException("Filename cannot be null or empty"); } this._filename = filename; } protected void Clear() { // Clear all the values and re-create datatables this._dataset.Tables.Clear(); this._accessPoints.Clear(); this._stations.Clear(); this._parseSuccess = false; } /// /// Open the file and returns its content /// /// /// File does not exist /// Fails to open file protected string[] getStrippedFileContent() { if (string.IsNullOrEmpty(this.Filename)) { throw new FileNotFoundException("Filename cannot be null or empty"); } FileInfo f = new FileInfo(this.Filename); if (!f.Exists) { throw new FileNotFoundException("File <" + this.Filename + "> does not exist"); } // Returns an array with one empty string if (f.Length == 0) { return new string[] { string.Empty }; } StreamReader sr = null; // Open the file try { sr = f.OpenText(); } catch (Exception e) { throw new Exception("Failed to open <" + this.Filename + ">", e); } List lines = new List(); // Read the file try { while (!sr.EndOfStream) { lines.Add(sr.ReadLine().Trim()); } } catch { /* Done or failure so stop */} // Close file try { sr.Close(); } catch { } return lines.ToArray(); } /// /// Read/Update the content of the file /// /// true if successful public virtual bool Read() { return this.ParseSuccess; } /// /// Generate the columns for the DataTable from the Hashtable (and in a specific order if needed) /// /// /// private DataColumn[] getColumnsFromHashtable(Hashtable ht, Hashtable order) { List columnList = new List(); if (ht != null) { if (order == null) { // No specific order but that's not going to happen foreach (string key in ht.Keys) { Type t = ht[key].GetType(); columnList.Add(new DataColumn(key, t)); } } else { for (int i = 0; i < order.Count; i++) { Type t = ht[(string)order[i]].GetType(); columnList.Add(new DataColumn((string)order[i], t)); } } } return columnList.ToArray(); } /// /// Add a station to the list /// /// Station /// protected bool addStation(Station s) { if (s == null) { return false; } // Create DataTable if needed if (!this._dataset.Tables.Contains(STATIONS_DATATABLE)) { // Create Stations DataTable DataTable dtStations = new DataTable(STATIONS_DATATABLE); dtStations.CaseSensitive = true; // Create columns dtStations.Columns.AddRange(this.getColumnsFromHashtable(s.FieldsDictionary, s.FieldsOrder)); // And add it to the dataset this._dataset.Tables.Add(dtStations); } // Add row DataRow dr = this._dataset.Tables[STATIONS_DATATABLE].NewRow(); // Set value for each field foreach (string key in s.FieldsDictionary.Keys) { dr[key] = s.FieldsDictionary[key]; } // Add row this._dataset.Tables[STATIONS_DATATABLE].Rows.Add(dr); // Add station to the list this._stations.Add(s); return true; } /// /// Link clients to their associated AP /// protected void LinkAPClients() { foreach (Station s in this._stations) { if (string.IsNullOrEmpty(s.BSSID)) { continue; } foreach (AccessPoint ap in this._accessPoints) { if (ap.BSSID == s.BSSID) { ap.addClient(s); break; } } } //this._dataset.Tables[ACCESSPOINTS_DATATABLE].ChildRelations.Add(new DataRelation("Cients", this._dataset.Tables[ACCESSPOINTS_DATATABLE].Columns["BSSID"], this._dataset.Tables[STATIONS_DATATABLE].Columns["BSSID"])); //this._dataset.Tables[STATIONS_DATATABLE].ParentRelations.Add(new DataRelation("Associated AP", this._dataset.Tables[ACCESSPOINTS_DATATABLE].Columns["BSSID"], this._dataset.Tables[STATIONS_DATATABLE].Columns["BSSID"])); } /// /// Add Access Point to the list /// /// Access Point /// protected bool addAccessPoint(AccessPoint ap) { if (ap == null) { return false; } // Create DataTable if needed if (!this._dataset.Tables.Contains(ACCESSPOINTS_DATATABLE)) { // Create Access Points DataTable DataTable dtAPs = new DataTable(ACCESSPOINTS_DATATABLE); dtAPs.CaseSensitive = true; // Create columns dtAPs.Columns.AddRange(this.getColumnsFromHashtable(ap.FieldsDictionary, ap.FieldsOrder)); this._dataset.Tables.Add(dtAPs); } // Add row DataRow dr = this._dataset.Tables[ACCESSPOINTS_DATATABLE].NewRow(); foreach (string key in ap.FieldsDictionary.Keys) { dr[key] = ap.FieldsDictionary[key]; } // Add row this._dataset.Tables[ACCESSPOINTS_DATATABLE].Rows.Add(dr); // Add the Access Point to the list this._accessPoints.Add(ap); return true; } /// /// Return the type of the file (and obviously, also the "name" of the reader to use /// /// Path to the file /// Null if type is unknown or a string with the type public static string getFileType(string path) { Reader r = new CsvReader(path); try { r.Read(); } catch { r = new KismetCsvReader(path); try { r.Read(); } catch { r = new NetXMLReader(path); try { r.Read(); } catch { } } } if (!r.ParseSuccess) { return null; } return r.ReaderType; } /// /// Parse a string containing the date and time /// /// Date string /// DateTime value /// Date/Time string cannot be null or empty /// Date Format is not set protected DateTime parseDateTime(string s) { if (string.IsNullOrEmpty(this.DATE_FORMAT)) { throw new FormatException("Date Format is not set"); } if (string.IsNullOrEmpty(s)) { throw new ArgumentNullException("Date/Time string cannot be null or empty"); } // Parse it DateTime ret = new DateTime(); try { ret = DateTime.ParseExact(s.Trim(), DATE_FORMAT, null); } catch { ret = DateTime.ParseExact(s.Trim(), ALT_DATE_FORMAT, null); } return ret; } } } aircrack-ng-1.6/lib/csharp/WirelessPanda/Readers/UniversalReader.cs000066400000000000000000000056201361312141100253330ustar00rootroot00000000000000// License: BSD/LGPL // Copyright (C) 2011-2018 Thomas d'Otreppe using System; using System.Data; namespace WirelessPanda.Readers { public class UniversalReader : Reader { /// /// Reader /// private Reader _reader = null; /// /// File type /// /// So that we have to check it only once private string _fileType = string.Empty; #region Properties /// /// DataSet containing 2 tables: "Access Points" and "Stations" /// public override DataSet Dataset { get { return this._reader.Dataset; } } /// /// Array of access points /// public override AccessPoint[] AccessPoints { get { return this._reader.AccessPoints; } } /// /// Array of stations /// public override Station[] Stations { get { return this._reader.Stations; } } /// /// Reader type /// public override string ReaderType { get { return "Universal: Airodump-ng CSV, Kismet CSV, Kismet NetXML"; } } #endregion /// /// Constructor /// /// Filename (doesn't need to exist now but MUST when using Read() ) public UniversalReader(string filename) : base(filename) { } /// /// Read/Update the content of the file /// /// true if successful public override bool Read() { this.ParseSuccess = false; if (string.IsNullOrEmpty(this._fileType)) { this._fileType = Reader.getFileType(this.Filename); } switch (this._fileType) { case "Airodump-ng CSV": this._reader = new CsvReader(this.Filename); break; case "Kismet CSV": this._reader = new KismetCsvReader(this.Filename); break; case "Kismet NetXML": this._reader = new NetXMLReader(this.Filename); break; default: throw new FormatException("Unknown file format, can't parse"); break; } this.ParseSuccess = this._reader.Read(); return this.ParseSuccess; } } } aircrack-ng-1.6/lib/csharp/WirelessPanda/Readers/csvReader.cs000066400000000000000000000176711361312141100241670ustar00rootroot00000000000000// License: BSD/LGPL // Copyright (C) 2011-2018 Thomas d'Otreppe using System; using System.Collections.Generic; namespace WirelessPanda.Readers { public class CsvReader : Reader { /// /// Date format (Same format for 0.x and 1.x) /// protected override string DATE_FORMAT { get { return "yyyy-MM-dd HH:mm:ss"; } } public enum CSVFileFormat { v0X, v1X, Unknown } /// /// Get the file format /// public CSVFileFormat FileFormat { get { return this._fileFormat; } } private CSVFileFormat _fileFormat = CSVFileFormat.Unknown; /// /// Reader type /// public override string ReaderType { get { return "Airodump-ng CSV"; } } /// /// Constructor /// /// Filename (doesn't need to exist now but MUST when using Read() ) public CsvReader(string filename) : base(filename) { } /// /// Read/Update the content of the file /// /// true if successful /// Airodump-ng CSV format unknown public override bool Read() { // Reset parsing status this.ParseSuccess = false; // Get the content of the file string[] content = this.getStrippedFileContent(); // Get file format this._fileFormat = this.getFormat(content); if (this._fileFormat == CSVFileFormat.Unknown) { throw new FormatException("Airodump-ng CSV format unknown"); } // Parse AP ... int i = 2; // Start at line 3 (skipping header) for (; i < content.Length && !string.IsNullOrEmpty(content[i]); i++) { string [] splitted = content[i].Split(','); switch (this._fileFormat) { case CSVFileFormat.v0X: if (splitted.Length < 11) { continue; } break; case CSVFileFormat.v1X: if (splitted.Length < 15) { continue; } break; } AccessPoint ap = new AccessPoint(); ap.BSSID = splitted[0].Trim(); ap.FirstTimeSeen = this.parseDateTime(splitted[1]); ap.LastTimeSeen = this.parseDateTime(splitted[2]); ap.Channel = int.Parse(splitted[3].Trim()); ap.MaxRate = double.Parse(splitted[4].Trim()); ap.Privacy = splitted[5].Trim(); switch (this._fileFormat) { case CSVFileFormat.v0X: ap.Power = int.Parse(splitted[6].Trim()); ap.Beacons = long.Parse(splitted[7].Trim()); ap.DataFrames = ulong.Parse(splitted[8].Trim()); ap.IP = splitted[9].Replace(" ", ""); ap.ESSID = splitted[10].Substring(1); // TODO: Improve it because it may contain a ',' ap.ESSIDLength = (byte)ap.ESSID.Length; break; case CSVFileFormat.v1X: ap.Cipher = splitted[6].Trim(); ap.Authentication = splitted[7].Trim(); ap.Power = int.Parse(splitted[8].Trim()); ap.Beacons = long.Parse(splitted[9].Trim()); ap.DataFrames = ulong.Parse(splitted[10].Trim()); ap.IP = splitted[11].Replace(" ", ""); ap.ESSIDLength = byte.Parse(splitted[12].Trim()); ap.ESSID = splitted[13].Substring(1); // TODO: Improve it because it may contain a ',' ap.Key = splitted[14]; break; } // Add AP to the list this.addAccessPoint(ap); } // ... Parse stations i += 2; // Skip station header for (; i < content.Length && !string.IsNullOrEmpty(content[i]); i++) { string[] splitted = content[i].Split(','); // Skip to the next if not long enough if (splitted.Length < 6) { continue; } // Parse station information Station sta = new Station(); sta.StationMAC = splitted[0].Trim(); sta.FirstTimeSeen = this.parseDateTime(splitted[1]); sta.LastTimeSeen = this.parseDateTime(splitted[2]); sta.Power = int.Parse(splitted[3].Trim()); sta.NbPackets = ulong.Parse(splitted[4].Trim()); sta.BSSID = splitted[5].Trim(); // Get probed ESSID list if (splitted.Length > 6 && splitted[6] != "") { List list = new List(); for (int j = 6; j < splitted.Length; j++) { // There's always a whitespace character before list.Add(splitted[j].Substring(1)); } sta.ProbedESSIDsList = list.ToArray(); } else { sta.ProbedESSIDs = string.Empty; } // Add station to the list this.addStation(sta); } // Link them together this.LinkAPClients(); // Parsing was successful this.ParseSuccess = true; return this.ParseSuccess; } /// /// Returns the format of the file /// /// File content /// CSV File Format /// content is null /// content is empty private CSVFileFormat getFormat(string[] content) { // Checks if (content == null) { throw new ArgumentNullException("Cannot determine format without any content"); } if (content.Length == 1 && string.IsNullOrEmpty(content[0])) { throw new ArgumentException("Cannot determine format without any content"); } // First line is empty and the second line contains the header if (content.Length > 2 && string.IsNullOrEmpty(content[0])) { // Version 1.x if (content[1] == "BSSID, First time seen, Last time seen, channel, Speed, Privacy, Cipher, Authentication, Power, # beacons, # IV, LAN IP, ID-length, ESSID, Key") { return CSVFileFormat.v1X; } // Version 0.x if (content[1] == "BSSID, First time seen, Last time seen, Channel, Speed, Privacy, Power, # beacons, # data, LAN IP, ESSID") { return CSVFileFormat.v0X; } } return CSVFileFormat.Unknown; } } } aircrack-ng-1.6/lib/csharp/WirelessPanda/Readers/kismetCsvReader.cs000066400000000000000000000116341361312141100253350ustar00rootroot00000000000000// License: BSD/LGPL // Copyright (C) 2011-2018 Thomas d'Otreppe using System; namespace WirelessPanda.Readers { public class KismetCsvReader : Reader { /// /// Date format (Same format for Kismet CSV and NetXML) /// protected override string DATE_FORMAT { get { return "ddd MMM dd HH:mm:ss yyyy"; } } /// /// Date format (Same format for Kismet CSV and NetXML) /// protected override string ALT_DATE_FORMAT { get { return "ddd MMM d HH:mm:ss yyyy"; } } /// /// Reader type /// public override string ReaderType { get { return "Kismet CSV"; } } /// /// Constructor /// /// Filename (doesn't need to exist now but MUST when using Read() ) public KismetCsvReader(string filename) : base(filename) { } /// /// Read/Update the content of the file /// /// true if successful /// Airodump-ng CSV format unknown public override bool Read() { // Reset parsing status this.ParseSuccess = false; // Get the content of the file string[] content = this.getStrippedFileContent(); // Check if this is really a kismet CSV file if (content.Length == 0) { throw new FormatException("Empty file"); } this.ParseSuccess = (content[0] == "Network;NetType;ESSID;BSSID;Info;Channel;Cloaked;Encryption;Decrypted;MaxRate;MaxSeenRate;Beacon;LLC;Data;Crypt;Weak;Total;Carrier;Encoding;FirstTime;LastTime;BestQuality;BestSignal;BestNoise;GPSMinLat;GPSMinLon;GPSMinAlt;GPSMinSpd;GPSMaxLat;GPSMaxLon;GPSMaxAlt;GPSMaxSpd;GPSBestLat;GPSBestLon;GPSBestAlt;DataSize;IPType;IP;"); if (!this.ParseSuccess) { throw new FormatException("Not a Kismet CSV file"); } // Parse content for (int i = 1; i < content.Length && !string.IsNullOrEmpty(content[i]); i++) { string [] splitted = content[i].Split(';'); // Check if there are enough elements if (splitted.Length < 39) { continue; } AccessPoint ap = new AccessPoint(); // Skip first element which is the network number (if someone cares about it, email me) ap.NetworkType = splitted[1].Trim(); ap.ESSID = splitted[2].Trim(); ap.ESSIDLength = (byte)splitted[2].Length; ap.BSSID = splitted[3].Trim(); ap.Info = splitted[4].Trim(); ap.Channel = int.Parse(splitted[5]); ap.Cloaked = (splitted[6].Trim().ToLower() == "yes"); ap.Encryption = splitted[7].Trim(); ap.Decrypted = (splitted[8].Trim().ToLower() == "yes"); ap.MaxRate = double.Parse(splitted[9]); ap.MaxSeenRate = double.Parse(splitted[10]); ap.Beacon = ulong.Parse(splitted[11]); ap.LLC = ulong.Parse(splitted[12]); ap.DataFrames = ulong.Parse(splitted[13]); ap.Crypt = ulong.Parse(splitted[14]); ap.Weak = ulong.Parse(splitted[15]); ap.Total = ulong.Parse(splitted[16]); ap.Carrier = splitted[17].Trim(); ap.Encoding = splitted[18].Trim(); ap.FirstTimeSeen = this.parseDateTime(splitted[19]); ap.LastTimeSeen = this.parseDateTime(splitted[20]); ap.BestQuality = int.Parse(splitted[21]); ap.BestSignal = int.Parse(splitted[22]); ap.BestNoise = int.Parse(splitted[23]); ap.MinLocation = new Coordinates(splitted[24], splitted[25], splitted[26], splitted[27]); ap.MaxLocation = new Coordinates(splitted[28], splitted[29], splitted[30], splitted[31]); ap.BestLocation = new Coordinates(splitted[32], splitted[33], splitted[34], ""); ap.DataSize = ulong.Parse(splitted[35]); ap.IPType = int.Parse(splitted[36]); ap.IP = splitted[37].Replace(" ", ""); this.addAccessPoint(ap); } // No need to link stations and access points together since there are only access points. return true; } } } aircrack-ng-1.6/lib/csharp/WirelessPanda/Station.cs000066400000000000000000000103121361312141100222660ustar00rootroot00000000000000// License: BSD/LGPL // Copyright (C) 2011-2018 Thomas d'Otreppe using System; using System.Collections.Generic; using System.Text; namespace WirelessPanda { public class Station : WirelessDevice, IEquatable { private AccessPoint _ap = null; /// /// Access point /// public AccessPoint AP { get { return this._ap; } // Only allow to do it inside the lib internal set { this._ap = value; } } /// /// Station MAC /// public string StationMAC { get { return (string)this.getDictValue("Station MAC"); } set { if (value != null) { this.setDictValue("Station MAC", value.Trim()); } else { this.setDictValue("Station MAC", value); } } } /// /// # Packets /// public ulong NbPackets { get { return (ulong)this.getDictValue("# Packets"); } set { this.setDictValue("# Packets", value); } } /// /// Probed ESSIDs (comma separated) /// public string ProbedESSIDs { get { return (string)this.getDictValue("Probed ESSIDs"); } set { this.setDictValue("Probed ESSIDs", value); // Update probe ESSID list this._probedESSIDsList.Clear(); if (string.IsNullOrEmpty(value)) { foreach (string s in value.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) { if (string.IsNullOrEmpty(s.Trim())) { continue; } // Add ESSID this._probedESSIDsList.Add(s); } } } } private List _probedESSIDsList = new List(); /// /// Probed ESSIDs List /// public string[] ProbedESSIDsList { get { return _probedESSIDsList.ToArray().Clone() as string[]; } set { this._probedESSIDsList.Clear(); this.setDictValue("Probed ESSIDs", string.Empty); if (value != null && value.Length > 0) { this._probedESSIDsList.AddRange(value); // Generate the string list of SSID StringBuilder sb = new StringBuilder(string.Empty); foreach (string s in value) { sb.AppendFormat("{0}, ", s); } string res = sb.ToString(); if (res.Length > 0) { res = res.Substring(0, res.Length - 2); } // And put it in the Probed ESSIDs dictionary item this.setDictValue("Probed ESSIDs", res); } } } /// /// Implements IEquatable /// /// Other Station to compare to /// true if equals, false if not public bool Equals(Station other) { try { if (this.StationMAC == other.StationMAC) { return true; } } catch { } return false; } } } aircrack-ng-1.6/lib/csharp/WirelessPanda/WirelessDevice.cs000066400000000000000000000114141361312141100235660ustar00rootroot00000000000000// License: BSD/LGPL // Copyright (C) 2011-2018 Thomas d'Otreppe using System; using System.Collections; namespace WirelessPanda { public abstract class WirelessDevice { #region Dictionary stuff /// /// Keep track of the last position for the column /// private int _lastPosition = 0; /// /// Dictionary containing all values /// protected Hashtable _fieldsDictionary = new Hashtable(); /// /// Order of the columns /// protected Hashtable _fieldsOrder = new Hashtable(); /// /// Sets a value in the dictionary /// /// Key /// Value protected void setDictValue(string key, object value) { if (this._fieldsDictionary.ContainsKey(key)) { this._fieldsDictionary.Remove(key); } else { // Save the position for the column (useful when creating the dataset) this._fieldsOrder.Add(this._lastPosition++, key); } this._fieldsDictionary.Add(key, value); } /// /// Return a value in the dictionary /// /// Key /// Object value /// protected object getDictValue(string key) { if (this._fieldsDictionary.ContainsKey(key)) { return this._fieldsDictionary[key]; } throw new MissingFieldException("Value for <" + key + "> is not set or does not exist"); } /// /// Returns a copy of the dictionary /// internal Hashtable FieldsDictionary { get { return this._fieldsDictionary as Hashtable; } } /// /// Returns a copy of the column order /// internal Hashtable FieldsOrder { get { return this._fieldsOrder as Hashtable; } } #endregion #region Properties public string BSSID { get { return (string)this.getDictValue("BSSID"); } set { this.setDictValue("BSSID", value); if (value != null) { // Special case, not associated if (value.Trim() == "(not associated)") { this.setDictValue("BSSID", string.Empty); } else { this.setDictValue("BSSID", value.Trim()); } } } } public DateTime FirstTimeSeen { get { return (DateTime)this.getDictValue("First Time Seen"); } set { this.setDictValue("First Time Seen", value); } } public DateTime LastTimeSeen { get { return (DateTime)this.getDictValue("Last Time Seen"); } set { this.setDictValue("Last Time Seen", value); } } public int Channel { get { return (int)this.getDictValue("Channel"); } set { this.setDictValue("Channel", value); } } public ulong TotalFrames { get { return (ulong)this.getDictValue("Total Frames"); } set { this.setDictValue("Total Frames", value); } } public Coordinates Location { get { return (Coordinates)this.getDictValue("Location"); } set { this.setDictValue("Location", value); } } public int Power { get { return (int)this.getDictValue("Power"); } set { this.setDictValue("Power", value); } } #endregion } } aircrack-ng-1.6/lib/csharp/WirelessPanda/WirelessPanda.Mono.csproj000066400000000000000000000047661361312141100252300ustar00rootroot00000000000000 Debug AnyCPU 8.0.30703 2.0 {F3A06E01-20E6-4CF8-AD62-1034A0B4EAE3} Library Properties WirelessPanda WirelessPanda v4.0 512 true full false bin\Debug\ DEBUG;TRACE prompt 4 pdbonly true bin\Release\ TRACE prompt 4 aircrack-ng-1.6/lib/csharp/WirelessPanda/WirelessPanda.csproj000066400000000000000000000047511361312141100243130ustar00rootroot00000000000000 Debug AnyCPU 8.0.30703 2.0 {F3A06E01-20E6-4CF8-AD62-1034A0B4EAE3} Library Properties WirelessPanda WirelessPanda v4.0 512 true full false bin\Debug\ DEBUG;TRACE prompt 4 pdbonly true bin\Release\ TRACE prompt 4 aircrack-ng-1.6/lib/libac/000077500000000000000000000000001361312141100153525ustar00rootroot00000000000000aircrack-ng-1.6/lib/libac/adt/000077500000000000000000000000001361312141100161225ustar00rootroot00000000000000aircrack-ng-1.6/lib/libac/adt/avl_tree.c000066400000000000000000000325451361312141100201000ustar00rootroot00000000000000/** * collectd - src/utils_avltree.c * Copyright (C) 2006,2007 Florian octo Forster * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * * Authors: * Florian octo Forster **/ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include "aircrack-ng/defs.h" #include "aircrack-ng/adt/avl_tree.h" #define BALANCE(n) \ ((((n)->left == NULL) ? 0 : (n)->left->height) \ - (((n)->right == NULL) ? 0 : (n)->right->height)) /* * private data types */ struct c_avl_node_s { void * key; void * value; int height; struct c_avl_node_s * left; struct c_avl_node_s * right; struct c_avl_node_s * parent; }; typedef struct c_avl_node_s c_avl_node_t; struct c_avl_tree_s { c_avl_node_t * root; int (*compare)(const void *, const void *); int size; }; struct c_avl_iterator_s { c_avl_tree_t * tree; c_avl_node_t * node; }; /* * private functions */ #if 0 static void verify_tree (c_avl_node_t *n) { if (n == NULL) return; verify_tree (n->left); verify_tree (n->right); assert ((BALANCE (n) >= -1) && (BALANCE (n) <= 1)); assert ((n->parent == NULL) || (n->parent->right == n) || (n->parent->left == n)); } /* void verify_tree */ #else #define verify_tree(n) /**/ #endif static void free_node(c_avl_node_t * n) { if (n == NULL) return; if (n->left != NULL) free_node(n->left); if (n->right != NULL) free_node(n->right); free(n); } static int calc_height(c_avl_node_t * n) { int height_left; int height_right; if (n == NULL) return 0; height_left = (n->left == NULL) ? 0 : n->left->height; height_right = (n->right == NULL) ? 0 : n->right->height; return ((height_left > height_right) ? height_left : height_right) + 1; } /* int calc_height */ static c_avl_node_t * search(c_avl_tree_t * t, const void * key) { c_avl_node_t * n; int cmp; n = t->root; while (n != NULL) { cmp = t->compare(key, n->key); if (cmp == 0) return n; else if (cmp < 0) n = n->left; else n = n->right; } return NULL; } /* (x) (y) * / \ / \ * (y) /\ /\ (x) * / \ /_c\ ==> / a\ / \ * /\ /\ /____\/\ /\ * / a\ /_b\ /_b\ /_c\ * /____\ */ static c_avl_node_t * rotate_right(c_avl_tree_t * t, c_avl_node_t * x) { c_avl_node_t * p; c_avl_node_t * y; c_avl_node_t * b; assert(x != NULL); assert(x->left != NULL); p = x->parent; y = x->left; b = y->right; x->left = b; if (b != NULL) b->parent = x; x->parent = y; y->right = x; y->parent = p; assert((p == NULL) || (p->left == x) || (p->right == x)); if (p == NULL) t->root = y; else if (p->left == x) p->left = y; else p->right = y; x->height = calc_height(x); y->height = calc_height(y); return y; } /* void rotate_right */ /* * (x) (y) * / \ / \ * /\ (y) (x) /\ * /_a\ / \ ==> / \ / c\ * /\ /\ /\ /\/____\ * /_b\ / c\ /_a\ /_b\ * /____\ */ static c_avl_node_t * rotate_left(c_avl_tree_t * t, c_avl_node_t * x) { c_avl_node_t * p; c_avl_node_t * y; c_avl_node_t * b; assert(x != NULL); assert(x->right != NULL); p = x->parent; y = x->right; b = y->left; x->right = b; if (b != NULL) b->parent = x; x->parent = y; y->left = x; y->parent = p; assert((p == NULL) || (p->left == x) || (p->right == x)); if (p == NULL) t->root = y; else if (p->left == x) p->left = y; else p->right = y; x->height = calc_height(x); y->height = calc_height(y); return y; } /* void rotate_left */ static c_avl_node_t * rotate_left_right(c_avl_tree_t * t, c_avl_node_t * x) { rotate_left(t, x->left); return rotate_right(t, x); } /* void rotate_left_right */ static c_avl_node_t * rotate_right_left(c_avl_tree_t * t, c_avl_node_t * x) { rotate_right(t, x->right); return rotate_left(t, x); } /* void rotate_right_left */ static void rebalance(c_avl_tree_t * t, c_avl_node_t * n) { int b_top; int b_bottom; while (n != NULL) { b_top = BALANCE(n); assert((b_top >= -2) && (b_top <= 2)); if (b_top == -2) { assert(n->right != NULL); b_bottom = BALANCE(n->right); assert((b_bottom >= -1) && (b_bottom <= 1)); if (b_bottom == 1) n = rotate_right_left(t, n); else n = rotate_left(t, n); } else if (b_top == 2) { assert(n->left != NULL); b_bottom = BALANCE(n->left); assert((b_bottom >= -1) && (b_bottom <= 1)); if (b_bottom == -1) n = rotate_left_right(t, n); else n = rotate_right(t, n); } else { int height = calc_height(n); if (height == n->height) break; n->height = height; } assert(n->height == calc_height(n)); n = n->parent; } /* while (n != NULL) */ } /* void rebalance */ static c_avl_node_t * c_avl_node_next(c_avl_node_t * n) { c_avl_node_t * r; /* return node */ if (n == NULL) { return NULL; } /* If we can't descent any further, we have to backtrack to the first * parent that's bigger than we, i. e. who's _left_ child we are. */ if (n->right == NULL) { r = n->parent; while ((r != NULL) && (r->parent != NULL)) { if (r->left == n) break; n = r; r = n->parent; } /* n->right == NULL && r == NULL => t is root and has no next * r->left != n => r->right = n => r->parent == NULL */ if ((r == NULL) || (r->left != n)) { assert((r == NULL) || (r->parent == NULL)); return NULL; } else { assert(r->left == n); return r; } } else { r = n->right; while (r->left != NULL) r = r->left; } return r; } /* c_avl_node_t *c_avl_node_next */ static c_avl_node_t * c_avl_node_prev(c_avl_node_t * n) { c_avl_node_t * r; /* return node */ if (n == NULL) { return NULL; } /* If we can't descent any further, we have to backtrack to the first * parent that's smaller than we, i. e. who's _right_ child we are. */ if (n->left == NULL) { r = n->parent; while ((r != NULL) && (r->parent != NULL)) { if (r->right == n) break; n = r; r = n->parent; } /* n->left == NULL && r == NULL => t is root and has no next * r->right != n => r->left = n => r->parent == NULL */ if ((r == NULL) || (r->right != n)) { assert((r == NULL) || (r->parent == NULL)); return NULL; } else { assert(r->right == n); return r; } } else { r = n->left; while (r->right != NULL) r = r->right; } return r; } /* c_avl_node_t *c_avl_node_prev */ static int _remove(c_avl_tree_t * t, c_avl_node_t * n) { assert((t != NULL) && (n != NULL)); if ((n->left != NULL) && (n->right != NULL)) { c_avl_node_t * r; /* replacement node */ if (BALANCE(n) > 0) /* left subtree is higher */ { assert(n->left != NULL); //-V547 r = c_avl_node_prev(n); } else /* right subtree is higher */ { assert(n->right != NULL); //-V547 r = c_avl_node_next(n); } ALLEGE(r != NULL && ((r->left == NULL) || (r->right == NULL))); /* copy content */ n->key = r->key; n->value = r->value; n = r; } ALLEGE(n != NULL && ((n->left == NULL) || (n->right == NULL))); if ((n->left == NULL) && (n->right == NULL)) { /* Deleting a leave is easy */ if (n->parent == NULL) { assert(t->root == n); t->root = NULL; } else { assert((n->parent->left == n) || (n->parent->right == n)); if (n->parent->left == n) n->parent->left = NULL; else n->parent->right = NULL; rebalance(t, n->parent); } free_node(n); } else if (n->left == NULL) { assert(BALANCE(n) == -1); //-V547 assert((n->parent == NULL) || (n->parent->left == n) || (n->parent->right == n)); if (n->parent == NULL) { assert(t->root == n); t->root = n->right; } else if (n->parent->left == n) { n->parent->left = n->right; } else { n->parent->right = n->right; } ALLEGE(n->right != NULL); n->right->parent = n->parent; if (n->parent != NULL) rebalance(t, n->parent); n->right = NULL; free_node(n); } else if (n->right == NULL) { assert(BALANCE(n) == 1); //-V547 assert((n->parent == NULL) || (n->parent->left == n) || (n->parent->right == n)); if (n->parent == NULL) { assert(t->root == n); t->root = n->left; } else if (n->parent->left == n) { n->parent->left = n->left; } else { n->parent->right = n->left; } n->left->parent = n->parent; if (n->parent != NULL) rebalance(t, n->parent); n->left = NULL; free_node(n); } else { assert(0); } return 0; } /* void *_remove */ /* * public functions */ c_avl_tree_t * c_avl_create(int (*compare)(const void *, const void *)) { c_avl_tree_t * t; if (compare == NULL) return NULL; if ((t = malloc(sizeof(*t))) == NULL) return NULL; t->root = NULL; t->compare = compare; t->size = 0; return t; } void c_avl_destroy(c_avl_tree_t * t) { if (t == NULL) return; free_node(t->root); free(t); } int c_avl_insert(c_avl_tree_t * t, void * key, void * value) { c_avl_node_t * new; c_avl_node_t * nptr; int cmp; if ((new = malloc(sizeof(*new))) == NULL) return -1; new->key = key; new->value = value; new->height = 1; new->left = NULL; new->right = NULL; if (t->root == NULL) { new->parent = NULL; t->root = new; t->size = 1; return 0; } nptr = t->root; while (42) { cmp = t->compare(nptr->key, new->key); if (cmp == 0) { free_node(new); return 1; } else if (cmp < 0) { /* nptr < new */ if (nptr->right == NULL) { nptr->right = new; new->parent = nptr; rebalance(t, nptr); break; } else { nptr = nptr->right; } } else /* if (cmp > 0) */ { /* nptr > new */ if (nptr->left == NULL) { nptr->left = new; new->parent = nptr; rebalance(t, nptr); break; } else { nptr = nptr->left; } } } /* while (42) */ verify_tree(t->root); ++t->size; return 0; } /* int c_avl_insert */ int c_avl_remove(c_avl_tree_t * t, const void * key, void ** rkey, void ** rvalue) { c_avl_node_t * n; int status; assert(t != NULL); n = search(t, key); if (n == NULL) return -1; if (rkey != NULL) *rkey = n->key; if (rvalue != NULL) *rvalue = n->value; status = _remove(t, n); verify_tree(t->root); --t->size; return status; } /* void *c_avl_remove */ int c_avl_get(c_avl_tree_t * t, const void * key, void ** value) { c_avl_node_t * n; assert(t != NULL); n = search(t, key); if (n == NULL) return -1; if (value != NULL) *value = n->value; return 0; } int c_avl_pick(c_avl_tree_t * t, void ** key, void ** value) { c_avl_node_t * n; c_avl_node_t * p; assert(t != NULL); if ((key == NULL) || (value == NULL)) return -1; if (t->root == NULL) return -1; n = t->root; while ((n->left != NULL) || (n->right != NULL)) { if (n->left == NULL) { n = n->right; continue; } else if (n->right == NULL) { n = n->left; continue; } if (n->left->height > n->right->height) n = n->left; else n = n->right; } p = n->parent; if (p == NULL) t->root = NULL; else if (p->left == n) p->left = NULL; else p->right = NULL; *key = n->key; *value = n->value; free_node(n); --t->size; rebalance(t, p); return 0; } /* int c_avl_pick */ c_avl_iterator_t * c_avl_get_iterator(c_avl_tree_t * t) { c_avl_iterator_t * iter; if (t == NULL) return NULL; iter = calloc(1, sizeof(*iter)); if (iter == NULL) return NULL; iter->tree = t; return iter; } /* c_avl_iterator_t *c_avl_get_iterator */ int c_avl_iterator_next(c_avl_iterator_t * iter, void ** key, void ** value) { c_avl_node_t * n; if ((iter == NULL) || (key == NULL) || (value == NULL)) return -1; if (iter->node == NULL) { for (n = iter->tree->root; n != NULL; n = n->left) if (n->left == NULL) break; iter->node = n; } else { n = c_avl_node_next(iter->node); } if (n == NULL) return -1; iter->node = n; *key = n->key; *value = n->value; return 0; } /* int c_avl_iterator_next */ int c_avl_iterator_prev(c_avl_iterator_t * iter, void ** key, void ** value) { c_avl_node_t * n; if ((iter == NULL) || (key == NULL) || (value == NULL)) return -1; if (iter->node == NULL) { for (n = iter->tree->root; n != NULL; n = n->left) if (n->right == NULL) break; iter->node = n; } else { n = c_avl_node_prev(iter->node); } if (n == NULL) return -1; iter->node = n; *key = n->key; *value = n->value; return 0; } /* int c_avl_iterator_prev */ void c_avl_iterator_destroy(c_avl_iterator_t * iter) { free(iter); } int c_avl_size(c_avl_tree_t * t) { if (t == NULL) return 0; return t->size; } aircrack-ng-1.6/lib/libac/adt/circular_buffer.c000066400000000000000000000107631361312141100214320ustar00rootroot00000000000000/** * Copyright (C) 2018 Joseph Benden * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. **/ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include #include "aircrack-ng/defs.h" #include "aircrack-ng/adt/circular_buffer.h" #ifndef NDEBUG static inline bool is_power_of_two(size_t n) { REQUIRE(n > 0); while ((n % 2) == 0) { n /= 2; } if (n == 1) return true; return false; } #endif // The definition of our circular buffer is hidden from the API user. struct circular_buffer_t { uint8_t * buffer; /// Circular buffer's memory location. size_t read_pos; /// Current read position, as element index. size_t write_pos; /// Current write position, as element index. size_t max; /// Number of bytes allocated for whole ring buffer. size_t size; /// Number of bytes required for a single element. }; /* * A circular buffer uses the "Virtual Streams" approach, as described on * the Ryg blog: * * https://fgiesen.wordpress.com/2010/12/14/ring-buffers-and-queues/ */ #define CBUF_BUFFER_POS(cbuf, which) \ (cbuf->buffer + ((cbuf->which % (cbuf->max / cbuf->size)) * cbuf->size)) static inline void check_invariants(cbuf_handle_t cbuf) { // All writes to structure are always ahead of the reads, unless empty. INVARIANT(cbuf->write_pos >= cbuf->read_pos); // All writes are restricted to the inside of our buffer's region. INVARIANT(cbuf->write_pos - cbuf->read_pos <= (cbuf->max / cbuf->size)); } API_EXPORT cbuf_handle_t circular_buffer_init(uint8_t * buffer, size_t bufferSize, size_t elementSize) { REQUIRE(buffer && bufferSize && elementSize); REQUIRE(bufferSize % elementSize == 0); REQUIRE(is_power_of_two(bufferSize)); cbuf_handle_t cbuf = calloc(1, sizeof(circular_buffer_t)); ALLEGE(cbuf); cbuf->buffer = buffer; cbuf->max = bufferSize; cbuf->size = elementSize; circular_buffer_reset(cbuf); ENSURE(circular_buffer_is_empty(cbuf)); return cbuf; } API_EXPORT void circular_buffer_free(cbuf_handle_t cbuf) { REQUIRE(cbuf); cbuf->buffer = NULL; free(cbuf); } API_EXPORT void circular_buffer_reset(cbuf_handle_t cbuf) { REQUIRE(cbuf); cbuf->read_pos = 0; cbuf->write_pos = 0; } API_EXPORT bool circular_buffer_is_empty(cbuf_handle_t cbuf) { REQUIRE(cbuf); return cbuf->read_pos == cbuf->write_pos; } API_EXPORT bool circular_buffer_is_full(cbuf_handle_t cbuf) { REQUIRE(cbuf); return cbuf->write_pos == (cbuf->read_pos + (cbuf->max / cbuf->size)); } API_EXPORT size_t circular_buffer_capacity(cbuf_handle_t cbuf) { REQUIRE(cbuf); return cbuf->max / cbuf->size; } API_EXPORT size_t circular_buffer_size(cbuf_handle_t cbuf) { REQUIRE(cbuf); return cbuf->write_pos - cbuf->read_pos; } API_EXPORT void circular_buffer_put(cbuf_handle_t cbuf, void const * const data, size_t size) { REQUIRE(cbuf && data && size > 0); REQUIRE(size <= cbuf->size); memcpy(CBUF_BUFFER_POS(cbuf, write_pos), data, size); // cannot overlap if (size < cbuf->size) { // zero extra buffer bytes memset(CBUF_BUFFER_POS(cbuf, write_pos) + size, 0, cbuf->size - size); } ++cbuf->write_pos; check_invariants(cbuf); } API_EXPORT void circular_buffer_get(cbuf_handle_t cbuf, void * const * data, size_t size) { REQUIRE(cbuf && data && size > 0); REQUIRE(size <= cbuf->size); memcpy(*data, CBUF_BUFFER_POS(cbuf, read_pos), size); // cannot overlap ++cbuf->read_pos; check_invariants(cbuf); } aircrack-ng-1.6/lib/libac/adt/circular_queue.c000066400000000000000000000071271361312141100213050ustar00rootroot00000000000000#ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include #include #include "aircrack-ng/defs.h" #include "aircrack-ng/adt/circular_buffer.h" #include "aircrack-ng/adt/circular_queue.h" // The definition of our circular queue is hidden from the API user. struct circular_queue_t { cbuf_handle_t cbuf; /// Circular buffer. pthread_mutex_t lock; /// Lock protecting whole structure. pthread_cond_t full_cv; /// Signals upon no longer full. pthread_cond_t empty_cv; /// Signals upon no longer empty. }; API_EXPORT cqueue_handle_t circular_queue_init(uint8_t * buffer, size_t bufferSize, size_t elementSize) { REQUIRE(buffer && bufferSize && elementSize); REQUIRE(bufferSize % elementSize == 0); cqueue_handle_t cq = calloc(1, sizeof(circular_queue_t)); ALLEGE(cq); cq->cbuf = circular_buffer_init(buffer, bufferSize, elementSize); ALLEGE(cq->cbuf); ALLEGE(pthread_mutex_init(&(cq->lock), NULL) == 0); ALLEGE(pthread_cond_init(&(cq->empty_cv), NULL) == 0); ALLEGE(pthread_cond_init(&(cq->full_cv), NULL) == 0); return cq; } API_EXPORT void circular_queue_free(cqueue_handle_t cq) { REQUIRE(cq); circular_buffer_free(cq->cbuf); cq->cbuf = NULL; ALLEGE(pthread_cond_destroy(&(cq->empty_cv)) == 0); ALLEGE(pthread_cond_destroy(&(cq->full_cv)) == 0); ALLEGE(pthread_mutex_destroy(&(cq->lock)) == 0); free(cq); } API_EXPORT void circular_queue_reset(cqueue_handle_t cq) { REQUIRE(cq); ALLEGE(pthread_mutex_lock(&(cq->lock)) == 0); circular_buffer_reset(cq->cbuf); ALLEGE(pthread_mutex_unlock(&(cq->lock)) == 0); } static inline void do_push(cqueue_handle_t cq, void const * const data, size_t size) { REQUIRE(cq && data && size > 0); REQUIRE(!circular_buffer_is_full(cq->cbuf)); circular_buffer_put(cq->cbuf, data, size); ALLEGE(pthread_cond_signal(&(cq->empty_cv)) == 0); ALLEGE(pthread_mutex_unlock(&(cq->lock)) == 0); } API_EXPORT void circular_queue_push(cqueue_handle_t cq, void const * const data, size_t size) { REQUIRE(cq && data && size > 0); ALLEGE(pthread_mutex_lock(&(cq->lock)) == 0); while (circular_buffer_is_full(cq->cbuf)) { ALLEGE(pthread_cond_wait(&(cq->full_cv), &(cq->lock)) == 0); } do_push(cq, data, size); } API_EXPORT int circular_queue_try_push(cqueue_handle_t cq, void const * const data, size_t size) { REQUIRE(cq && data && size > 0); ALLEGE(pthread_mutex_lock(&(cq->lock)) == 0); if (circular_buffer_is_full(cq->cbuf)) { ALLEGE(pthread_mutex_unlock(&(cq->lock)) == 0); return -1; } do_push(cq, data, size); return 0; } API_EXPORT void circular_queue_pop(cqueue_handle_t cq, void * const * data, size_t size) { REQUIRE(cq && data && size > 0); ALLEGE(pthread_mutex_lock(&(cq->lock)) == 0); while (circular_buffer_is_empty(cq->cbuf)) { ALLEGE(pthread_cond_wait(&(cq->empty_cv), &(cq->lock)) == 0); } ALLEGE(!circular_buffer_is_empty(cq->cbuf)); circular_buffer_get(cq->cbuf, data, size); ALLEGE(pthread_cond_signal(&(cq->full_cv)) == 0); ALLEGE(pthread_mutex_unlock(&(cq->lock)) == 0); } API_EXPORT bool circular_queue_is_empty(cqueue_handle_t cq) { REQUIRE(cq); bool rc; ALLEGE(pthread_mutex_lock(&(cq->lock)) == 0); rc = circular_buffer_is_empty(cq->cbuf); ALLEGE(pthread_mutex_unlock(&(cq->lock)) == 0); return rc; } API_EXPORT bool circular_queue_is_full(cqueue_handle_t cq) { REQUIRE(cq); bool rc; ALLEGE(pthread_mutex_lock(&(cq->lock)) == 0); rc = circular_buffer_is_full(cq->cbuf); ALLEGE(pthread_mutex_unlock(&(cq->lock)) == 0); return rc; } aircrack-ng-1.6/lib/libac/cpu/000077500000000000000000000000001361312141100161415ustar00rootroot00000000000000aircrack-ng-1.6/lib/libac/cpu/cpuset_hwloc.c000066400000000000000000000074111361312141100210070ustar00rootroot00000000000000/* * Copyright (C) 2018 Joseph Benden * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * is provided AS IS, WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and * NON-INFRINGEMENT. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, * MA 02110-1301, USA. * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include "aircrack-ng/cpu/cpuset.h" struct ac_cpuset { size_t nbThreads; hwloc_topology_t topology; hwloc_cpuset_t * hwloc_cpusets; }; ac_cpuset_t * ac_cpuset_new(void) { return malloc(sizeof(struct ac_cpuset)); } void ac_cpuset_free(ac_cpuset_t * cpuset) { free(cpuset); } void ac_cpuset_init(ac_cpuset_t * cpuset) { assert(cpuset != NULL); cpuset->nbThreads = 0; cpuset->hwloc_cpusets = NULL; hwloc_topology_init(&cpuset->topology); hwloc_topology_load(cpuset->topology); } void ac_cpuset_destroy(ac_cpuset_t * cpuset) { assert(cpuset != NULL); if (cpuset->hwloc_cpusets != NULL) { free(cpuset->hwloc_cpusets); cpuset->hwloc_cpusets = NULL; } hwloc_topology_destroy(cpuset->topology); } void ac_cpuset_distribute(ac_cpuset_t * cpuset, size_t count) { assert(cpuset != NULL); cpuset->nbThreads = count; cpuset->hwloc_cpusets = calloc(count, sizeof(hwloc_cpuset_t)); if (!cpuset->hwloc_cpusets) return; hwloc_obj_t root = hwloc_get_root_obj(cpuset->topology); #if defined(HWLOC_API_VERSION) && HWLOC_API_VERSION > 0x00010800 hwloc_distrib(cpuset->topology, &root, 1u, cpuset->hwloc_cpusets, (unsigned int) count, INT_MAX, 0u); #else hwloc_distributev(cpuset->topology, &root, 1u, cpuset->hwloc_cpusets, (unsigned int) count, INT_MAX); #endif } #ifdef CYGWIN struct tid_to_handle { ptrdiff_t vtbl; uint32_t magic; HANDLE h; }; #endif void ac_cpuset_bind_thread_at(ac_cpuset_t * cpuset, pthread_t tid, size_t idx) { assert(cpuset != NULL); if (idx > cpuset->nbThreads) return; hwloc_bitmap_singlify(cpuset->hwloc_cpusets[idx]); if (hwloc_set_thread_cpubind(cpuset->topology, #ifdef CYGWIN // WARNING: This is a HACK into `class pthread` of Cygwin. *((HANDLE*)((char*)tid + offsetof(struct tid_to_handle, h))), #else tid, #endif cpuset->hwloc_cpusets[idx], HWLOC_CPUBIND_THREAD)) { char * str; int error = errno; hwloc_bitmap_asprintf(&str, cpuset->hwloc_cpusets[idx]); fprintf(stderr, "Couldn't bind thread to cpuset %s: %s\n", str, strerror(error)); free(str); } } aircrack-ng-1.6/lib/libac/cpu/cpuset_pthread.c000066400000000000000000000051601361312141100213210ustar00rootroot00000000000000/* * Copyright (C) 2018 Joseph Benden * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * is provided AS IS, WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and * NON-INFRINGEMENT. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, * MA 02110-1301, USA. * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif #include #include #include #include #include #include "aircrack-ng/cpu/cpuset.h" struct ac_cpuset { size_t nbThreads; }; ac_cpuset_t * ac_cpuset_new(void) { return malloc(sizeof(struct ac_cpuset)); } void ac_cpuset_free(ac_cpuset_t * cpuset) { free(cpuset); } void ac_cpuset_init(ac_cpuset_t * cpuset) { assert(cpuset != NULL); cpuset->nbThreads = 0; } void ac_cpuset_destroy(ac_cpuset_t * cpuset) { assert(cpuset != NULL); } void ac_cpuset_distribute(ac_cpuset_t * cpuset, size_t count) { assert(cpuset != NULL); cpuset->nbThreads = count; } void ac_cpuset_bind_thread_at(ac_cpuset_t * cpuset, pthread_t tid, size_t idx) { assert(cpuset != NULL); if (idx > cpuset->nbThreads) return; #if defined(HAVE_PTHREAD_AFFINITY_NP) && HAVE_PTHREAD_AFFINITY_NP // set affinity to a specific processor, for the specified thread. cpu_set_t set; CPU_ZERO(&set); CPU_SET(idx, &set); pthread_setaffinity_np(tid, sizeof(cpu_set_t), &set); #endif } aircrack-ng-1.6/lib/libac/cpu/simd_cpuid.c000066400000000000000000000417571361312141100204430ustar00rootroot00000000000000/* * CPU/SIMD identification routines by Len White * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #define _GNU_SOURCE #include #include #include #include #include #include #include #if defined(__i386__) || defined(__x86_64__) #define _X86 1 #include #elif defined(__arm__) || defined(__aarch64__) #ifdef HAS_AUXV #include #include #endif #endif /* __arm__ */ #ifdef __linux__ #include #include #include #endif #if defined(__FreeBSD__) || defined(__OpenBSD__) #include #include #endif #include #include "aircrack-ng/cpu/simd_cpuid.h" #include "aircrack-ng/support/common.h" #ifdef __linux__ #define CPUFREQ_CPU0C "/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq" #define CPUFREQ_CPU0M "/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq" #define CORETEMP_PATH "/sys/devices/platform/coretemp.0/" static int cpuid_readsysfs(const char * file); static int cpuid_findcpusensorpath(const char * path); #endif struct _cpuinfo cpuinfo = {0, NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0.0, NULL}; // // Until better support for other arch's is added an ifdef is needed // static unsigned long getRegister(const unsigned int val, const char from, const char to) { unsigned long mask = (1ul << (to + 1ul)) - 1ul; if (to == 31) return val >> from; return (val & mask) >> from; } static void sprintcat(char * dest, const char * src, size_t len) { if (strlen(dest) > 0) (void) strncat(dest, ",", len - strlen(dest) - 1); (void) strncat(dest, src, len - strlen(dest) - 1); } int is_dir(const char * dir) { struct stat sb; if (!stat(dir, &sb)) return S_ISDIR(sb.st_mode); return 0; } unsigned long GetCacheTotalLize(unsigned ebx, unsigned ecx) { unsigned long LnSz, SectorSz, WaySz, SetSz; LnSz = getRegister(ebx, 0, 11) + 1; SectorSz = getRegister(ebx, 12, 21) + 1; WaySz = getRegister(ebx, 22, 31) + 1; SetSz = getRegister(ecx, 0, 31) + 1; return (SetSz * WaySz * SectorSz * LnSz); } // // Return maximum SIMD size for the CPU. // AVX512F = 16 / 512 bit // AVX2 = 8 / 256 bit // SSE2-4.2 + AVX / NEON = 4 / 128 bit // MMX / CPU Fallback = 1 / 64 bit // int cpuid_simdsize(int viewmax) { #ifdef _X86 unsigned eax = 0, ebx = 0, ecx = 0, edx = 0; unsigned int max_level = __get_cpuid_max(0, NULL); if (max_level >= 7) { __cpuid_count(7, 0, eax, ebx, ecx, edx); if (ebx & (1 << 16)) { // AVX512F return 16; } else if (ebx & (1 << 5)) { // AVX2 return 8; } } __cpuid(1, eax, ebx, ecx, edx); if (edx & (1 << 26)) // SSE2 return 4; #elif (defined(__arm__) || defined(__aarch64__)) && defined(HAS_AUXV) long hwcaps = getauxval(AT_HWCAP); if (hwcaps & (1 << 12)) // NEON return 4; #if defined(__aarch64__) if (hwcaps & (1 << 1)) // ASIMD return 4; #endif #endif (void) viewmax; // MMX or CPU Fallback return 1; } #ifdef _X86 static char * cpuid_vendor(void) { unsigned eax = 0, ebx = 0, ecx = 0, edx = 0; __cpuid(0, eax, ebx, ecx, edx); if ((ebx == 0x756E6547) && (edx == 0x49656E69)) return "Intel"; else if ((ebx == 0x68747541) || (ebx == 0x69444D41)) return "AMD"; else if (ebx == 0x746E6543) return "Centaur (VIA)"; else if (ebx == 0x69727943) return "Cyrix"; else if ((ebx == 0x6E617254) || ((ebx == 0x756E6547) && (edx == 0x54656E69))) return "Transmeta"; else if (ebx == 0x646F6547) return "Geode by NSC (AMD)"; else if (ebx == 0x4778654E) return "NexGen"; else if (ebx == 0x65736952) return "Rise"; else if (ebx == 0x20536953) return "SiS"; else if (ebx == 0x20434D55) return "UMC"; else if (ebx == 0x20414956) return "VIA"; else if (ebx == 0x74726F56) return "Vortex86 SoC"; else if (ebx == 0x4B4D564B) return "KVM (Virtual Machine)"; else if (ebx == 0x7263694D) return "Microsoft Hyper-V or Virtual PC"; else if (ebx == 0x70726C20) return "Parallels (Virtual Machine)"; else if (ebx == 0x61774D56) return "VMware"; else if (ebx == 0x566E6558) return "Xen HVM (Virtual Machine)"; return "Unknown CPU"; } #endif static char * cpuid_featureflags(void) { char flags[64] = {0}; #ifdef _X86 unsigned eax = 0, ebx = 0, ecx = 0, edx = 0; unsigned int max_level = __get_cpuid_max(0, NULL); __cpuid(1, eax, ebx, ecx, edx); if (edx & (1 << 23)) sprintcat((char *) &flags, "MMX", sizeof(flags)); if (edx & (1 << 25)) sprintcat((char *) &flags, "SSE", sizeof(flags)); if (edx & (1 << 26)) sprintcat((char *) &flags, "SSE2", sizeof(flags)); if (ecx & (1 << 0)) sprintcat((char *) &flags, "SSE3", sizeof(flags)); if (ecx & (1 << 9)) sprintcat((char *) &flags, "SSSE3", sizeof(flags)); if (ecx & (1 << 19)) sprintcat((char *) &flags, "SSE4.1", sizeof(flags)); if (ecx & (1 << 20)) sprintcat((char *) &flags, "SSE4.2", sizeof(flags)); if (ecx & (1 << 25)) sprintcat((char *) &flags, "AES-NI", sizeof(flags)); if (edx & (1 << 28)) // Hyper-threading cpuinfo.htt = 1; if (ecx & (1 << 28)) // AVX sprintcat((char *) &flags, "AVX", sizeof(flags)); if (ecx & (1 << 31)) // Hypervisor cpuinfo.hv = 1; if (max_level >= 7) { __cpuid_count(7, 0, eax, ebx, ecx, edx); if (ebx & (1 << 5)) // AVX2 sprintcat((char *) &flags, "AVX2", sizeof(flags)); if (ebx & (1 << 16)) // AVX512F sprintcat((char *) &flags, "AVX512F", sizeof(flags)); } #elif (defined(__arm__) || defined(__aarch64__)) && defined(HAS_AUXV) long hwcaps = getauxval(AT_HWCAP); #if defined(__aarch64__) if (hwcaps & (1 << 1)) sprintcat((char *) &flags, "ASIMD", sizeof(flags)); #else if (hwcaps & (1 << 12)) sprintcat((char *) &flags, "NEON", sizeof(flags)); if (hwcaps & (1 << 1)) sprintcat((char *) &flags, "HALF", sizeof(flags)); if (hwcaps & (1 << 2)) sprintcat((char *) &flags, "THUMB", sizeof(flags)); if (hwcaps & (1 << 11)) sprintcat((char *) &flags, "THUMBEE", sizeof(flags)); if (hwcaps & (1 << 6)) sprintcat((char *) &flags, "VFP", sizeof(flags)); if ((hwcaps & (1 << 13)) || (hwcaps & (1 << 14))) sprintcat((char *) &flags, "VFPv3", sizeof(flags)); if (hwcaps & (1 << 16)) sprintcat((char *) &flags, "VFPv4", sizeof(flags)); if (hwcaps & (1 << 15)) sprintcat((char *) &flags, "TLS", sizeof(flags)); if (hwcaps & (1 << 10)) sprintcat((char *) &flags, "CRUNCH", sizeof(flags)); if (hwcaps & (1 << 9)) sprintcat((char *) &flags, "iwMMXt", sizeof(flags)); if ((hwcaps & (1 << 17)) || (hwcaps & (1 << 18))) sprintcat((char *) &flags, "IDIV", sizeof(flags)); #endif #endif return strdup(flags); } static float cpuid_getcoretemp(void) { #ifdef __FreeBSD__ int tempval = 0; size_t len = sizeof(tempval); if (sysctlbyname("dev.cpu.0.temperature", &tempval, &len, NULL, 0) == -1) return 0; cpuinfo.coretemp = (tempval - 2732) / 10.0f; #elif __linux__ if (cpuinfo.cputemppath != NULL) { cpuinfo.coretemp = (float) cpuid_readsysfs((const char *) cpuinfo.cputemppath) / 1000.0f; } #else return 0; #endif return cpuinfo.coretemp; } #ifdef __linux__ // // Locate the primary temp input on the coretemp sysfs // static int cpuid_findcpusensorpath(const char * path) { #define MAX_SENSOR_PATHS 16 DIR * dirp; struct dirent * dp; char tbuf[MAX_SENSOR_PATHS][32] = {{0}}; int cnt = 0, i = 0, sensorx = 0; char sensor[8] = {0}; dirp = opendir(path); if (dirp == NULL) return -1; snprintf(sensor, sizeof(sensor), "temp%d", sensorx); while (cnt < (MAX_SENSOR_PATHS - 1) && (dp = readdir(dirp)) != NULL) { if (!strncmp(dp->d_name, sensor, 5)) { (void) closedir(dirp); if (asprintf(&cpuinfo.cputemppath, "%stemp%d_input", CORETEMP_PATH, sensorx) == -1) { perror("asprintf"); } return sensorx; } else if (!strncmp(dp->d_name, "temp", 4)) { strncpy(tbuf[cnt], dp->d_name, 31); tbuf[cnt][31] = '\0'; // ensure NULL termination if (cnt < (MAX_SENSOR_PATHS - 1)) ++cnt; //-V547 } } (void) closedir(dirp); // Hopefully we found the ID on the first pass, but Linux is its infinite // wisdom // sometimes starts the sensors at 2-6+ for (sensorx = 1; sensorx < 8; sensorx++) for (i = 0; i < cnt; i++) { snprintf(sensor, sizeof(sensor), "temp%d", sensorx); if (!strncasecmp(tbuf[i], sensor, strlen(sensor))) { if (asprintf(&cpuinfo.cputemppath, "%stemp%d_input", CORETEMP_PATH, sensorx) == -1) { perror("asprintf"); } return sensorx; } } return -1; } static int cpuid_readsysfs(const char * file) { int fd, ival = 0; struct stat sf; char buf[16] = {0}; if (stat(file, &sf)) return -1; fd = open(file, O_RDONLY); if (fd == -1) return -1; if (read(fd, &buf, sizeof(buf))) { ival = atoi(buf); } close(fd); return ival; } // // Return CPU frequency from scaling governor when supported // static int cpuid_getfreq(int type) { int fd, ifreq = 0; struct stat sf; char freq[16] = {0}, *fptr; fptr = (type == 1 ? CPUFREQ_CPU0C : CPUFREQ_CPU0M); if (stat(fptr, &sf)) return 0; fd = open(fptr, O_RDONLY); if (fd == -1) return 0; if (read(fd, &freq, sizeof(freq))) ifreq = atoi(freq) / 1000; close(fd); return ifreq; } #endif static char * cpuid_modelinfo(void) { #ifdef _X86 unsigned eax = 0, ebx = 0, ecx = 0, edx = 0; int bi = 2, broff = 0; char * tmpmodel = calloc(1, (size_t)((sizeof(unsigned) * 4ul) * 5ul)); #elif __linux__ FILE * cfd; char *line = NULL, *token = NULL; size_t linecap = 0; ssize_t linelen; #elif __FreeBSD__ /* ARM support for FreeBSD */ int mib[] = {CTL_HW, HW_MODEL}; char modelbuf[64]; size_t len = sizeof(modelbuf); #endif char *pm = NULL, *model = NULL; #ifdef _X86 if (tmpmodel == NULL) { fprintf(stderr, "ERROR: calloc() failed to allocate memory for " "cpuid_modelinfo(): %s\n", strerror(errno)); return "Unknown"; } for (; bi < 5; bi++, broff += 16) { __cpuid(0x80000000 + bi, eax, ebx, ecx, edx); memcpy(tmpmodel + broff, &eax, sizeof(unsigned)); memcpy(tmpmodel + broff + 4, &ebx, sizeof(unsigned)); memcpy(tmpmodel + broff + 8, &ecx, sizeof(unsigned)); memcpy(tmpmodel + broff + 12, &edx, sizeof(unsigned)); } pm = tmpmodel; #elif __linux__ cfd = fopen("/proc/cpuinfo", "r"); if (cfd == NULL) { fprintf(stderr, "ERROR: Failed opening /proc/cpuinfo: %s\n", strerror(errno)); return "Unknown"; } while ((linelen = getline(&line, &linecap, cfd)) > 0) { if (!strncasecmp(line, "model", 5)) { token = strsep(&line, ":"); token = strsep(&line, ":"); token[strlen(token) - 1] = 0; (void) *token++; pm = token; break; } } free(line); line = NULL; fclose(cfd); if (pm == NULL) return NULL; #elif __FreeBSD__ if (sysctl(mib, 2, modelbuf, &len, NULL, 0)) snprintf(modelbuf, sizeof(modelbuf), "Unknown"); pm = modelbuf; #endif // Clean up the empty spaces in the model name on some intel's because they // let their engineers fall asleep on the space bar while (*pm == ' ') { pm++; } model = strdup(pm); #ifdef _X86 free(tmpmodel); tmpmodel = NULL; #endif if (model == NULL) { fprintf(stderr, "ERROR: strdup() failed to allocate memory for " "cpuid_modelinfo(): %s\n", strerror(errno)); return "Unknown"; } return model; } #ifdef _X86 static inline unsigned cpuid_x86_max_function_id(void) { unsigned eax = 0, ebx = 0, ecx = 0, edx = 0; __cpuid(0, eax, ebx, ecx, edx); return (eax); } static inline unsigned cpuid_x86_max_extended_function_id(void) { unsigned eax = 0, ebx = 0, ecx = 0, edx = 0; __cpuid(0x80000000UL, eax, ebx, ecx, edx); return (eax); } static unsigned int cpuid_x86_threads_per_core(void); static unsigned int cpuid_x86_threads_per_core(void) { unsigned eax = 0, ebx = 0, ecx = 0, edx = 0; unsigned int mfi = cpuid_x86_max_function_id(); unsigned int mefi = cpuid_x86_max_extended_function_id(); const char * vendor = cpuid_vendor(); if (mfi < 0x04U || (strcmp(vendor, "Intel") != 0 && strcmp(vendor, "AMD") != 0)) { return (1); } if (strcmp(vendor, "AMD") == 0 && mefi >= 0x8000001EU) { __cpuid(0x8000001EU, eax, ebx, ecx, edx); return (((ebx >> 8U) & 7U) + 1U); } if (mfi < 0x0BU) { __cpuid(1, eax, ebx, ecx, edx); if ((edx & (1U << 28U)) != 0) { // v will contain logical core count const unsigned v = (ebx >> 16) & 255; if (v > 1) { __cpuid(4, eax, ebx, ecx, edx); // physical cores const unsigned v2 = (eax >> 26U) + 1U; if (v2 > 0) { return v / v2; } } } return (1); } if (mfi < 0x1FU) { /* CPUID leaf 1FH is a preferred superset to leaf 0BH. Intel recommends first checking for the existence of Leaf 1FH before using leaf 0BH. */ __cpuid_count(0x0BU, 0, eax, ebx, ecx, edx); if ((ebx & 0xFFFFU) == 0) { return (1); } return (ebx & 0xFFFFU); } __cpuid_count(0x1FU, 0, eax, ebx, ecx, edx); if ((ebx & 0xFFFFU) == 0) { return (1); } return (ebx & 0xFFFFU); } static unsigned int cpuid_x86_logical_cores(void); static unsigned int cpuid_x86_logical_cores(void) { unsigned eax = 0, ebx = 0, ecx = 0, edx = 0; unsigned int mfi = cpuid_x86_max_function_id(); const char * vendor = cpuid_vendor(); if (strcmp(vendor, "Intel") == 0) { // Use this on old Intel processors if (mfi < 0x0BU) { if (mfi < 0x01U) { return (0); } __cpuid(1, eax, ebx, ecx, edx); return ((ebx >> 16U) & 0xFFU); } if (mfi < 0x1FU) { /* CPUID leaf 1FH is a preferred superset to leaf 0BH. Intel recommends first checking for the existence of Leaf 1FH before using leaf 0BH. */ __cpuid_count(0x0BU, 1, eax, ebx, ecx, edx); return (ebx & 0xFFFFU); } __cpuid_count(0x1FU, 1, eax, ebx, ecx, edx); return (ebx & 0xFFFFU); } else if (strcmp(vendor, "AMD") == 0) { __cpuid(1, eax, ebx, ecx, edx); return ((ebx >> 16U) & 0xFFU); } else { return (0); } } static unsigned int cpuid_x86_physical_cores(void); static unsigned int cpuid_x86_physical_cores(void) { unsigned eax = 0, ebx = 0, ecx = 0, edx = 0; unsigned int mfi = cpuid_x86_max_function_id(); unsigned int mefi = cpuid_x86_max_extended_function_id(); const char * vendor = cpuid_vendor(); if (strcmp(vendor, "Intel") == 0 && mfi >= 0x01U) { return (cpuid_x86_logical_cores() / cpuid_x86_threads_per_core()); } else if (strcmp(vendor, "AMD") == 0 && mefi >= 0x80000008UL) { __cpuid(0x80000008UL, eax, ebx, ecx, edx); return (((ecx & 0xFFU) + 1U) / cpuid_x86_threads_per_core()); } return (1); } #endif int cpuid_getinfo() { int cpu_count = get_nb_cpus(); float cpu_temp; #ifdef _X86 cpuinfo.maxlogic = cpuid_x86_logical_cores(); cpuinfo.cores = cpuid_x86_physical_cores(); printf("Vendor = %s\n", cpuid_vendor()); #else cpuinfo.maxlogic = cpu_count; #endif #ifdef __linux__ cpuid_findcpusensorpath(CORETEMP_PATH); cpuinfo.cpufreq_cur = cpuid_getfreq(1); cpuinfo.cpufreq_max = cpuid_getfreq(2); #endif cpuinfo.model = cpuid_modelinfo(); cpuinfo.flags = cpuid_featureflags(); if (cpuinfo.model != NULL) printf("Model = %s\n", cpuinfo.model); if (cpuinfo.flags != NULL) printf("Features = %s\n", cpuinfo.flags); if (cpuinfo.hv) printf("Hypervisor = Yes (Virtualization detected)\n"); if (cpuinfo.cpufreq_cur) printf("CPU frequency = %d MHz (Max: %d MHz)\n", cpuinfo.cpufreq_cur, cpuinfo.cpufreq_max); cpu_temp = cpuid_getcoretemp(); if (cpu_temp != 0.0) //-V550 printf("CPU temperature = %2.2f C\n", cpu_temp); #ifdef _X86 printf("Hyper-Threading = %s\n", cpuinfo.htt ? "Yes" : "No"); #endif printf("Logical CPUs = %d\n", cpuinfo.maxlogic); #ifdef _X86 printf("Threads per core= %d\n", cpuid_x86_threads_per_core()); #endif if (cpuinfo.cores > 0) { printf("CPU cores = %d", cpuinfo.cores); if (cpuinfo.maxlogic > 0 && cpuinfo.maxlogic != cpu_count) { if (cpu_count > cpuinfo.maxlogic) printf(" (%d total, %d sockets)", cpu_count, (cpu_count / cpuinfo.maxlogic)); else printf(" (%d total)", cpu_count); } puts(""); } cpuinfo.simdsize = cpuid_simdsize(1); printf("SIMD size = %d ", cpuinfo.simdsize); if (cpuinfo.simdsize == 1) printf("(64 bit)\n"); else if (cpuinfo.simdsize == 4) printf("(128 bit)\n"); else if (cpuinfo.simdsize == 8) printf("(256 bit)\n"); else if (cpuinfo.simdsize == 16) printf("(512 bit)\n"); else printf("(unknown)\n"); if (cpuinfo.flags != NULL) { free(cpuinfo.flags); cpuinfo.flags = NULL; } if (cpuinfo.model != NULL) { free(cpuinfo.model); cpuinfo.model = NULL; } if (cpuinfo.cputemppath != NULL) { free(cpuinfo.cputemppath); cpuinfo.cputemppath = NULL; } return 0; } aircrack-ng-1.6/lib/libac/cpu/trampoline_arm.c000066400000000000000000000026521361312141100213230ustar00rootroot00000000000000/* * Copyright (C) 2018 Joseph Benden * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #if defined(__arm__) || defined(__aarch64__) #ifdef HAS_AUXV #include #include #endif #else #error "The wrong CPU architecture file has been included." #endif #include "aircrack-ng/cpu/trampoline.h" void simd_init(void) {} void simd_destroy(void) {} int simd_get_supported_features(void) { int result = 0; #ifdef HAS_AUXV long hwcaps = getauxval(AT_HWCAP); #if defined(HWCAP_ASIMD) if (hwcaps & HWCAP_ASIMD) { result |= SIMD_SUPPORTS_ASIMD; } #endif #if defined(HWCAP_NEON) if (hwcaps & HWCAP_NEON) { result |= SIMD_SUPPORTS_NEON; } #endif #endif return (result); } aircrack-ng-1.6/lib/libac/cpu/trampoline_ppc.c000066400000000000000000000025371361312141100213300ustar00rootroot00000000000000/* * Copyright (C) 2018 Joseph Benden * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #if defined(__ppc__) || defined(__PPC__) #ifdef HAS_AUXV #include #include #endif #else #error "The wrong CPU architecture file has been included." #endif #include "aircrack-ng/cpu/trampoline.h" void simd_init(void) {} void simd_destroy(void) {} int simd_get_supported_features(void) { int result = 0; #ifdef HAS_AUXV long hwcaps = getauxval(AT_HWCAP2); #if defined(PPC_FEATURE2_ARCH_2_07) if (hwcaps & PPC_FEATURE2_ARCH_2_07) { result |= SIMD_SUPPORTS_POWER8; } #endif #endif return (result); } aircrack-ng-1.6/lib/libac/cpu/trampoline_stubs.c000066400000000000000000000017611361312141100217040ustar00rootroot00000000000000/* * Copyright (C) 2018 Joseph Benden * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include "aircrack-ng/cpu/trampoline.h" void simd_init(void) {} void simd_destroy(void) {} int simd_get_supported_features(void) { int result = 0; return (result); } aircrack-ng-1.6/lib/libac/cpu/trampoline_x86.c000066400000000000000000000033111361312141100211620ustar00rootroot00000000000000/* * Copyright (C) 2018 Joseph Benden * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #if defined(__i386__) || defined(__x86_64__) #define _X86 #include #else #error "The wrong CPU architecture file has been included." #endif #include "aircrack-ng/cpu/trampoline.h" void simd_init(void) {} void simd_destroy(void) {} int simd_get_supported_features(void) { int result = 0; unsigned eax = 0, ebx = 0, ecx = 0, edx = 0; unsigned int max_level = __get_cpuid_max(0, 0); __cpuid(0, eax, ebx, ecx, edx); if (eax >= 1) { __cpuid(1, eax, ebx, ecx, edx); } if (edx & (1 << 23)) //-V525 { result |= SIMD_SUPPORTS_MMX; } if (edx & (1 << 26)) { result |= SIMD_SUPPORTS_SSE2; } if (ecx & (1 << 28)) { result |= SIMD_SUPPORTS_AVX; } if (max_level >= 7) { __cpuid_count(7, 0, eax, ebx, ecx, edx); if (ebx & (1 << 16)) { result |= SIMD_SUPPORTS_AVX512F; } if (ebx & (1 << 5)) { result |= SIMD_SUPPORTS_AVX2; } } return (result); } aircrack-ng-1.6/lib/libac/support/000077500000000000000000000000001361312141100170665ustar00rootroot00000000000000aircrack-ng-1.6/lib/libac/support/common.c000066400000000000000000000335751361312141100205370ustar00rootroot00000000000000/* * Common functions for all aircrack-ng tools * * Copyright (C) 2006-2018 Thomas d'Otreppe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. * If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. * If you * do not wish to do so, delete this exception statement from your * version. * If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) \ || defined(__MidnightBSD__) #include #include #endif #if (defined(_WIN32) || defined(_WIN64)) || defined(__CYGWIN32__) #include #include #include #endif #include "aircrack-ng/defs.h" #include "aircrack-ng/osdep/osdep.h" #include "aircrack-ng/osdep/common.h" #include "aircrack-ng/third-party/ethernet.h" #define isHex(c) (hexToInt(c) != -1) #define HEX_BASE 16 /* * The following function comes from jumbo.c from JTR. * It has the following license: * * This file is Copyright (c) 2013-2014 magnum, Lukasz and JimF, * and is hereby released to the general public under the following terms: * Redistribution and use in source and binary forms, with or without * modifications, are permitted. */ #if defined(__CYGWIN32__) && !defined(__CYGWIN64__) int fseeko64(FILE * fp, int64_t offset, int whence) { fpos_t pos; if (whence == SEEK_CUR) { if (fgetpos(fp, &pos)) return (-1); pos += (fpos_t) offset; } else if (whence == SEEK_END) { /* If writing, we need to flush before getting file length. */ long long size; fflush(fp); size = 0; GetFileSizeEx((HANDLE) _get_osfhandle(fileno(fp)), (PLARGE_INTEGER) &size); pos = (fpos_t)(size + offset); } else if (whence == SEEK_SET) pos = (fpos_t) offset; else { errno = EINVAL; return (-1); } return fsetpos(fp, &pos); } int64_t ftello64(FILE * fp) { fpos_t pos; if (fgetpos(fp, &pos)) return -1LL; return (int64_t) pos; } #endif /* * Print the time and percentage in readable format */ void calctime(time_t t, float perc) { int days = 0, hours = 0, mins = 0, secs = 0, remain = 0, printed = 0; char buf[8]; days = t / 86400; remain = t % 86400; hours = remain / 3600; remain = remain % 3600; mins = remain / 60; secs = remain % 60; if (days) printed += printf("%d day%s, ", days, (days > 1 ? "s" : "")); if (hours) printed += printf("%d hour%s, ", hours, (hours > 1 ? "s" : "")); if (mins) printed += printf("%d minute%s, ", mins, (mins > 1 ? "s" : "")); snprintf(buf, sizeof(buf), "%3.2f%%", perc); printed += printf("%d second%s", secs, (secs != 1 ? "s" : "")); printf("%*s %s\n", (int) (47 - (printed + strlen(buf) % 5)), " ", buf); } int is_string_number(const char * str) { int i; if (str == NULL) { return 0; } if (*str != '-' && !(isdigit((int) (*str)))) { return 0; } for (i = 1; str[i] != 0; i++) { if (!isdigit((int) (str[i]))) { return 0; } } return 1; } int get_ram_size(void) { int ret = -1; #if defined(__FreeBSD__) || defined(__MidnightBSD__) int mib[] = {CTL_HW, HW_PHYSMEM}; size_t len; unsigned long physmem; len = sizeof(physmem); if (!sysctl(mib, 2, &physmem, &len, NULL, 0)) ret = (physmem / 1024); // Linux returns memory size in kB, so we want // to as well. #elif defined(_WIN32) || defined(_WIN64) MEMORYSTATUSEX statex; statex.dwLength = sizeof(statex); if (GlobalMemoryStatusEx(&statex)) { ret = (int) (statex.ullTotalPhys / 1024); } #else FILE * fp; char str[100 + 1]; int val = 0; if (!(fp = fopen("/proc/meminfo", "r"))) { perror("fopen fails on /proc/meminfo"); return ret; } memset(str, 0x00, sizeof(str)); while (ret == -1 && !feof(fp) && fscanf(fp, "%100s %d", str, &val) != 0) { if (!(strncmp(str, "MemTotal", 8))) { ret = val; } } fclose(fp); #endif return ret; } /* Return the version number */ char * getVersion(const char * progname, const unsigned int maj, const unsigned int min, const unsigned int submin, const char * rev, const unsigned int beta, const unsigned int rc) { if (progname == NULL || progname[0] == 0) { fprintf(stderr, "Invalid program name, cannot be NULL or empty\n"); exit(1); } if (rc != 0 && beta != 0) { fprintf(stderr, "RC and beta cannot be both used\n"); exit(1); } // Calculate and allocate buffer size_t len = 100 + strlen(progname); if (rev) { len += strlen(rev); } char * ret = (char *) calloc(1, len); if (ret == NULL) { perror("calloc()"); exit(1); } // Major, minor version snprintf(ret, len, "%s %u.%u", progname, maj, min); // Sub-minor if (submin > 0) { snprintf(ret + strlen(ret), len - strlen(ret), ".%u", submin); } // Release candidate ... if (rc > 0) { snprintf(ret + strlen(ret), len - strlen(ret), " rc%u", rc); } else if (beta > 0) { // ... Or beta snprintf(ret + strlen(ret), len - strlen(ret), " beta%u", beta); } // Add revision if it comes from subversion or git if (rev) { char * tmp = strdup(rev); ALLEGE(tmp != NULL); char * sep = strstr(tmp, "_"); if (sep) { ++sep; } else { sep = ""; } char * search = strstr(sep, "rev-"); if (search) { search[3] = ' '; } snprintf( ret + strlen(ret), len - strlen(ret), " %s", search ? search : sep); free(tmp); } // Shorten buffer if possible char * r_ret = realloc(ret, strlen(ret) + 1); return (r_ret) ? r_ret : ret; } // Return the number of cpu. If detection fails, it will return -1; int get_nb_cpus(void) { int number = -1; #if defined(_WIN32) || defined(_WIN64) SYSTEM_INFO sysinfo = {0}; GetSystemInfo(&sysinfo); number = sysinfo.dwNumberOfProcessors; #elif defined(__linux__) char *s, *pos; FILE * f; // Reading /proc/cpuinfo is more reliable on current CPUs, // so put it first and try the old method if this one fails f = fopen("/proc/cpuinfo", "r"); if (f != NULL) { s = (char *) calloc(1, 81); if (s != NULL) { // Get the latest value of "processor" element // and increment it by 1 and it that value // will be the number of CPU. number = -2; while (fgets(s, 80, f) != NULL) { pos = strstr(s, "processor"); if (pos == s) { pos = strchr(s, ':'); if (pos != NULL) number = atoi(pos + 1); } } ++number; free(s); } fclose(f); } #elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) \ || defined(__MidnightBSD__) // Not sure about defined(__DragonFly__) || defined(__NetBSD__) || // defined(__OpenBSD__) || defined(__APPLE__) int mib[] = {CTL_HW, HW_NCPU}; size_t len; unsigned long nbcpu; len = sizeof(nbcpu); if (!sysctl(mib, 2, &nbcpu, &len, NULL, 0)) { number = (int) nbcpu; } #endif #ifdef _SC_NPROCESSORS_ONLN // Try the usual method if _SC_NPROCESSORS_ONLN exist if (number == -1) { number = sysconf(_SC_NPROCESSORS_ONLN); /* Fails on some archs */ if (number < 1) { number = -1; } } #endif return number; } // compares two MACs int maccmp(unsigned char * mac1, unsigned char * mac2) { int i = 0; if (mac1 == NULL || mac2 == NULL) return -1; for (i = 0; i < 6; i++) { if (toupper(mac1[i]) != toupper(mac2[i])) return -1; } return 0; } /* Return -1 if it's not an hex value and return its value when it's a hex value */ int hexCharToInt(unsigned char c) { static int table_created = 0; static int table[256]; int i; if (table_created == 0) { /* * It may seem a bit long to calculate the table * but character position depend on the charset used * Example: EBCDIC * but it's only done once and then conversion will be really fast */ for (i = 0; i < 256; i++) { switch ((unsigned char) i) { case '0': table[i] = 0; break; case '1': table[i] = 1; break; case '2': table[i] = 2; break; case '3': table[i] = 3; break; case '4': table[i] = 4; break; case '5': table[i] = 5; break; case '6': table[i] = 6; break; case '7': table[i] = 7; break; case '8': table[i] = 8; break; case '9': table[i] = 9; break; case 'A': case 'a': table[i] = 10; break; case 'B': case 'b': table[i] = 11; break; case 'C': case 'c': table[i] = 12; break; case 'D': case 'd': table[i] = 13; break; case 'E': case 'e': table[i] = 14; break; case 'F': case 'f': table[i] = 15; break; default: table[i] = -1; } } table_created = 1; } return table[c]; } // in: input string // in_length: length of the string // out: output string (needs to be already allocated). // out_length: length of the array // returns amount of bytes saved to 'out' or -1 if an error happened int hexStringToArray(char * in, int in_length, unsigned char * out, int out_length) { int i, out_pos; int chars[2]; char * input = in; unsigned char * output = out; if (in_length < 2 || out_length < (in_length / 3) + 1 || input == NULL || output == NULL) return -1; out_pos = 0; for (i = 0; i < in_length - 1; ++i) { if (input[i] == '-' || input[i] == ':' || input[i] == '_' || input[i] == ' ' || input[i] == '.') { continue; } // Check output array is big enough if (out_pos >= out_length) { return -1; } chars[0] = hexCharToInt(input[i]); // If first char is invalid (or '\0'), don't bother continuing (and you // really shouldn't). if (chars[0] < 0 || chars[0] > 15) return -1; chars[1] = hexCharToInt(input[++i]); // It should always be a multiple of 2 hex characters with or without // separator if (chars[1] < 0 || chars[1] > 15) return -1; output[out_pos++] = ((chars[0] << 4) + chars[1]) & 0xFF; } return out_pos; } // Return the mac address bytes (or null if it's not a mac address) int getmac(const char * macAddress, const int strict, unsigned char * mac) { char byte[3]; int i, nbElem; unsigned n; if (macAddress == NULL) return 1; /* Minimum length */ if ((int) strlen(macAddress) < 12) return 1; memset(mac, 0, 6); byte[2] = 0; i = nbElem = 0; while (macAddress[i] != 0) { if (macAddress[i] == '\n' || macAddress[i] == '\r') break; byte[0] = macAddress[i]; byte[1] = macAddress[i + 1]; if (sscanf(byte, "%x", &n) != 1 && strlen(byte) == 2) return 1; if (hexCharToInt(byte[1]) < 0) return 1; mac[nbElem] = n; i += 2; nbElem++; if (macAddress[i] == ':' || macAddress[i] == '-' || macAddress[i] == '_') i++; } if ((strict && nbElem != 6) || (!strict && nbElem > 6)) return 1; return 0; } // Read a line of characters inputted by the user int readLine(char line[], int maxlength) { int c; int i = -1; do { // Read char c = getchar(); if (c == EOF) c = '\0'; line[++i] = (char) c; if (line[i] == '\n') break; if (line[i] == '\r') break; if (line[i] == '\0') break; } while (i + 1 < maxlength); // Stop at 'Enter' key pressed or EOF or max number of char read // Return current size return i; } int hexToInt(char s[], int len) { int i = 0; int convert = -1; int value = 0; // Remove leading 0 (and also the second char that can be x or X) while (i < len) { if (s[i] != '0' || (i == 1 && toupper((int) s[i]) != 'X')) break; ++i; } // Convert to hex while (i < len) { convert = hexCharToInt((unsigned char) s[i]); // If conversion failed, return -1 if (convert == -1) return -1; value = (value * HEX_BASE) + convert; ++i; } return value; } char * get_current_working_directory(void) { char * ret = NULL; char * wd_realloc = NULL; size_t wd_size = 0; do { wd_size += PATH_MAX; wd_realloc = (char *) realloc(ret, wd_size); if (wd_realloc == NULL) { if (ret) free(ret); return (NULL); } ret = wd_realloc; wd_realloc = getcwd(ret, wd_size); if (wd_realloc == NULL && errno != ERANGE) { free(ret); return (NULL); } } while (wd_realloc == NULL && errno == ERANGE); return (ret); } int string_has_suffix(const char * str, const char * suf) { assert(str && suf); const char * a = str + strlen(str); const char * b = suf + strlen(suf); while (a != str && b != suf) { if (*--a != *--b) break; } return b == suf && *a == *b; } int is_background(void) { pid_t grp = tcgetpgrp(STDIN_FILENO); if (grp == -1) { // Piped return 0; } if (grp == getpgrp()) { // Foreground return 0; } // Background return 1; } int station_compare(const void * a, const void * b) { REQUIRE(a != NULL); REQUIRE(b != NULL); return (memcmp(a, b, ETHER_ADDR_LEN)); } aircrack-ng-1.6/lib/libac/support/communications.c000066400000000000000000001074021361312141100222660ustar00rootroot00000000000000/* * Copyright (C) 2006-2018 Thomas d'Otreppe * Copyright (C) 2006-2009 Martin Beck * Copyright (C) 2018-2019 Joseph Benden * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. * If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. * If you * do not wish to do so, delete this exception statement from your * version. * If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include "aircrack-ng/defs.h" #include "aircrack-ng/support/communications.h" #include "aircrack-ng/crypto/crypto.h" #include "aircrack-ng/support/pcap_local.h" #include "aircrack-ng/tui/console.h" #include "aircrack-ng/utf8/verifyssid.h" #include "aircrack-ng/osdep/byteorder.h" #include "aircrack-ng/osdep/packed.h" #include "aircrack-ng/third-party/ethernet.h" #include "aircrack-ng/third-party/ieee80211.h" extern struct communication_options opt; extern struct devices dev; struct wif *_wi_in = NULL, *_wi_out = NULL; uint8_t h80211[4096] __attribute__((aligned(16))); uint8_t tmpbuf[4096] __attribute__((aligned(16))); static char strbuf[512] __attribute__((aligned(16))); int read_packet(struct wif * wi, void * buf, uint32_t count, struct rx_info * ri) { REQUIRE(buf != NULL && count > 0); int rc; rc = wi_read(wi, NULL, NULL, buf, count, ri); if (rc == -1) { switch (errno) { case EAGAIN: return (0); default: perror("wi_read()"); return (-1); } } return (rc); } int wait_for_beacon(struct wif * wi, uint8_t * bssid, uint8_t * capa, char * essid) { int chan = 0, tagtype = 0; size_t taglen = 0, pos = 0, len = 0; uint8_t pkt_sniff[4096]; struct timeval tv, tv2; char essid2[33]; gettimeofday(&tv, NULL); while (1) { len = 0; while (len < 22) { len = (size_t) read_packet(wi, pkt_sniff, sizeof(pkt_sniff), NULL); gettimeofday(&tv2, NULL); if (((tv2.tv_sec - tv.tv_sec) * 1000000) + (tv2.tv_usec - tv.tv_usec) > 10000 * 1000) // wait 10sec for beacon frame { return (-1); } if (len <= 0) usleep(1); } if (!memcmp(pkt_sniff, "\x80", 1)) { pos = 0; taglen = 22; // initial value to get the fixed tags parsing started taglen += 12; // skip fixed tags in frames do { pos += taglen + 2; tagtype = pkt_sniff[pos]; taglen = pkt_sniff[pos + 1]; } while (tagtype != 3 && pos < len - 2); if (tagtype != 3) continue; if (taglen != 1) continue; if (pos + 2 + taglen > len) continue; chan = pkt_sniff[pos + 2]; if (essid) { pos = 0; taglen = 22; // initial value to get the fixed tags parsing started taglen += 12; // skip fixed tags in frames do { pos += taglen + 2; tagtype = pkt_sniff[pos]; taglen = pkt_sniff[pos + 1]; } while (tagtype != 0 && pos < len - 2); if (tagtype != 0) continue; if (taglen <= 1) { if (bssid != NULL && memcmp(bssid, pkt_sniff + 10, ETHER_ADDR_LEN) == 0) break; else continue; } if (pos + 2 + taglen > len) continue; if (taglen > 32) taglen = 32; if ((pkt_sniff + pos + 2)[0] < 32 && bssid != NULL && memcmp(bssid, pkt_sniff + 10, ETHER_ADDR_LEN) == 0) { break; } /* if bssid is given, copy essid */ if (bssid != NULL && memcmp(bssid, pkt_sniff + 10, ETHER_ADDR_LEN) == 0 && strlen(essid) == 0) { memset(essid, 0, 33); memcpy(essid, pkt_sniff + pos + 2, taglen); break; } /* if essid is given, copy bssid AND essid, so we can handle * case insensitive arguments */ if (bssid != NULL && memcmp(bssid, NULL_MAC, ETHER_ADDR_LEN) == 0 && strncasecmp(essid, (char *) pkt_sniff + pos + 2, taglen) == 0 && strlen(essid) == (unsigned) taglen) { memset(essid, 0, 33); memcpy(essid, pkt_sniff + pos + 2, taglen); memcpy(bssid, pkt_sniff + 10, ETHER_ADDR_LEN); printf("Found BSSID \"%02X:%02X:%02X:%02X:%02X:%02X\" to " "given ESSID \"%s\".\n", bssid[0], bssid[1], bssid[2], bssid[3], bssid[4], bssid[5], essid); break; } /* if essid and bssid are given, check both */ if (bssid != NULL && memcmp(bssid, pkt_sniff + 10, ETHER_ADDR_LEN) == 0 && strlen(essid) > 0) { memset(essid2, 0, 33); memcpy(essid2, pkt_sniff + pos + 2, taglen); if (strncasecmp(essid, essid2, taglen) == 0 && strlen(essid) == (unsigned) taglen) break; else { printf("For the given BSSID " "\"%02X:%02X:%02X:%02X:%02X:%02X\", there is an " "ESSID mismatch!\n", bssid[0], bssid[1], bssid[2], bssid[3], bssid[4], bssid[5]); printf( "Found ESSID \"%s\" vs. specified ESSID \"%s\"\n", essid2, essid); printf("Using the given one, double check it to be " "sure its correct!\n"); break; } } } } } if (capa) memcpy(capa, pkt_sniff + 34, 2); return (chan); } /** if bssid != NULL its looking for a beacon frame */ int attack_check(uint8_t * bssid, char * essid, uint8_t * capa, struct wif * wi, int ignore_negative_one) { int ap_chan = 0, iface_chan = 0; iface_chan = wi_get_channel(wi); if (iface_chan == -1 && !ignore_negative_one) { PCT; printf("Couldn't determine current channel for %s, you should either " "force the operation with --ignore-negative-one or apply a " "kernel patch\n", wi_get_ifname(wi)); return (-1); } if (bssid != NULL) { ap_chan = wait_for_beacon(wi, bssid, capa, essid); if (ap_chan < 0) { PCT; printf("No such BSSID available.\n"); return (-1); } if ((ap_chan != iface_chan) && (iface_chan != -1 || !ignore_negative_one)) { PCT; printf("%s is on channel %d, but the AP uses channel %d\n", wi_get_ifname(wi), iface_chan, ap_chan); return (-1); } } return (0); } int getnet(struct wif * wi, uint8_t * capa, int filter, int force, uint8_t * f_bssid, uint8_t * r_bssid, uint8_t * r_essid, int ignore_negative_one, int nodetect) { uint8_t * bssid; if (nodetect) return (0); if (filter) bssid = f_bssid; else bssid = r_bssid; if (memcmp(bssid, NULL_MAC, ETHER_ADDR_LEN) != 0) { PCT; printf("Waiting for beacon frame (BSSID: " "%02X:%02X:%02X:%02X:%02X:%02X) on channel %d\n", bssid[0], bssid[1], bssid[2], bssid[3], bssid[4], bssid[5], wi_get_channel(wi)); } else if (strlen((const char *) r_essid) > 0) { PCT; printf("Waiting for beacon frame (ESSID: %s) on channel %d\n", r_essid, wi_get_channel(wi)); } else if (force) { PCT; if (filter) { printf("Please specify at least a BSSID (-b) or an ESSID (-e)\n"); } else { printf("Please specify at least a BSSID (-a) or an ESSID (-e)\n"); } return (1); } else return (0); if (attack_check(bssid, (char *) r_essid, capa, wi, ignore_negative_one) != 0) { if (memcmp(bssid, NULL_MAC, ETHER_ADDR_LEN) != 0) { if (verifyssid(r_essid) == 0) { printf("Please specify an ESSID (-e).\n"); } } else { if (strlen((const char *) r_essid) > 0) { printf("Please specify a BSSID (-a).\n"); } } return (1); } return (0); } int filter_packet(unsigned char * h80211, int caplen) { REQUIRE(h80211 != NULL); int z, mi_b, mi_s, mi_d, ext = 0; if (caplen <= 0) return (1); z = ((h80211[1] & IEEE80211_FC1_DIR_MASK) != IEEE80211_FC1_DIR_DSTODS) ? 24 : 30; if ((h80211[0] & IEEE80211_FC0_SUBTYPE_BEACON) == IEEE80211_FC0_SUBTYPE_BEACON) { /* 802.11e QoS */ z += 2; } if ((h80211[0] & IEEE80211_FC0_TYPE_MASK) == IEEE80211_FC0_TYPE_DATA) // if data packet ext = z - 24; // how many bytes longer than default ieee80211 header /* check length */ if (caplen - ext < opt.f_minlen || caplen - ext > opt.f_maxlen) return (1); /* check the frame control bytes */ if ((h80211[0] & IEEE80211_FC0_TYPE_MASK) != (opt.f_type << 2) && opt.f_type >= 0) return (1); if ((h80211[0] & IEEE80211_FC0_SUBTYPE_CF_ACK_CF_ACK) != ((opt.f_subtype << 4) & 0x70) && // ignore the leading bit (QoS) opt.f_subtype >= 0) return (1); if ((h80211[1] & IEEE80211_FC1_DIR_TODS) != (opt.f_tods) && opt.f_tods >= 0) return (1); if ((h80211[1] & IEEE80211_FC1_DIR_FROMDS) != (opt.f_fromds << 1) && opt.f_fromds >= 0) return (1); if ((h80211[1] & IEEE80211_FC1_PROTECTED) != (opt.f_iswep << 6) && opt.f_iswep >= 0) return (1); /* check the extended IV (TKIP) flag */ if (opt.f_type == 2 && opt.f_iswep == 1 && (h80211[z + 3] & 0x20) != 0) return (1); /* MAC address checking */ switch (h80211[1] & IEEE80211_FC1_DIR_MASK) { case IEEE80211_FC1_DIR_NODS: mi_b = 16; mi_s = 10; mi_d = 4; break; case IEEE80211_FC1_DIR_TODS: mi_b = 4; mi_s = 10; mi_d = 16; break; case IEEE80211_FC1_DIR_FROMDS: mi_b = 10; mi_s = 16; mi_d = 4; break; case IEEE80211_FC1_DIR_DSTODS: mi_b = 10; mi_d = 16; mi_s = 24; break; default: abort(); } if (memcmp(opt.f_bssid, NULL_MAC, ETHER_ADDR_LEN) != 0) if (memcmp(h80211 + mi_b, opt.f_bssid, ETHER_ADDR_LEN) != 0) return (1); if (memcmp(opt.f_bssid, opt.f_smac, ETHER_ADDR_LEN) == 0) { if (memcmp(opt.f_smac, NULL_MAC, ETHER_ADDR_LEN) != 0) if (memcmp(h80211 + mi_s, opt.f_smac, ETHER_ADDR_LEN - 1) != 0) return (1); } else { if (memcmp(opt.f_smac, NULL_MAC, ETHER_ADDR_LEN) != 0) if (memcmp(h80211 + mi_s, opt.f_smac, ETHER_ADDR_LEN) != 0) return (1); } if (memcmp(opt.f_bssid, opt.f_dmac, ETHER_ADDR_LEN) == 0) { if (memcmp(opt.f_dmac, NULL_MAC, ETHER_ADDR_LEN) != 0) if (memcmp(h80211 + mi_d, opt.f_dmac, ETHER_ADDR_LEN - 1) != 0) return (1); } else { if (memcmp(opt.f_dmac, NULL_MAC, ETHER_ADDR_LEN) != 0) if (memcmp(h80211 + mi_d, opt.f_dmac, ETHER_ADDR_LEN) != 0) return (1); } /* this one looks good */ return (0); } int capture_ask_packet(int * caplen, int just_grab) { REQUIRE(caplen != NULL); time_t tr; struct timeval tv; struct tm * lt; fd_set rfds; long nb_pkt_read; int i, j, n, mi_b = 0, mi_s = 0, mi_d = 0, mi_t = 0, mi_r = 0, is_wds = 0, key_index_offset; int ret, z; FILE * f_cap_out; struct pcap_file_header pfh_out; struct pcap_pkthdr pkh; if (opt.f_minlen < 0) opt.f_minlen = 40; if (opt.f_maxlen < 0) opt.f_maxlen = 1500; if (opt.f_type < 0) opt.f_type = 2; if (opt.f_subtype < 0) opt.f_subtype = 0; if (opt.f_iswep < 0) opt.f_iswep = 1; tr = time(NULL); nb_pkt_read = 0; signal(SIGINT, SIG_DFL); while (1) { if (time(NULL) - tr > 0) { tr = time(NULL); printf("\rRead %ld packets...\r", nb_pkt_read); fflush(stdout); } if (opt.s_file == NULL) { FD_ZERO(&rfds); FD_SET(dev.fd_in, &rfds); tv.tv_sec = 1; tv.tv_usec = 0; if (select(dev.fd_in + 1, &rfds, NULL, NULL, &tv) < 0) { if (errno == EINTR) continue; perror("select failed"); return (EXIT_FAILURE); } if (!FD_ISSET(dev.fd_in, &rfds)) continue; gettimeofday(&tv, NULL); *caplen = read_packet(_wi_in, h80211, sizeof(h80211), NULL); if (*caplen < 0) return (EXIT_FAILURE); if (*caplen == 0) continue; } else { /* there are no hidden backdoors in this source code */ n = sizeof(pkh); if (fread(&pkh, n, 1, dev.f_cap_in) != 1) { printf("\r"); erase_line(0); printf("End of file.\n"); return (EXIT_FAILURE); } if (dev.pfh_in.magic == TCPDUMP_CIGAM) { SWAP32(pkh.caplen); SWAP32(pkh.len); } tv.tv_sec = pkh.tv_sec; tv.tv_usec = pkh.tv_usec; n = *caplen = pkh.caplen; if (n <= 0 || n > (int) sizeof(h80211) || n > (int) sizeof(tmpbuf)) { printf("\r"); erase_line(0); printf("Invalid packet length %d.\n", n); return (EXIT_FAILURE); } if (fread(h80211, n, 1, dev.f_cap_in) != 1) { printf("\r"); erase_line(0); printf("End of file.\n"); return (EXIT_FAILURE); } if (dev.pfh_in.linktype == LINKTYPE_PRISM_HEADER) { /* remove the prism header */ if (h80211[7] == 0x40) n = 64; else n = *(int *) (h80211 + 4); //-V1032 if (n < 8 || n >= (int) *caplen) continue; memcpy(tmpbuf, h80211, *caplen); *caplen -= n; memcpy(h80211, tmpbuf + n, *caplen); } if (dev.pfh_in.linktype == LINKTYPE_RADIOTAP_HDR) { /* remove the radiotap header */ n = *(unsigned short *) (h80211 + 2); //-V1032 if (n <= 0 || n >= (int) *caplen) continue; memcpy(tmpbuf, h80211, *caplen); *caplen -= n; memcpy(h80211, tmpbuf + n, *caplen); } if (dev.pfh_in.linktype == LINKTYPE_PPI_HDR) { /* remove the PPI header */ n = le16_to_cpu(*(unsigned short *) (h80211 + 2)); //-V1032 if (n <= 0 || n >= (int) *caplen) continue; /* for a while Kismet logged broken PPI headers */ if (n == 24 && le16_to_cpu(*(unsigned short *) (h80211 + 8)) == 2) n = 32; if (n <= 0 || n >= (int) *caplen) continue; //-V560 memcpy(tmpbuf, h80211, *caplen); *caplen -= n; memcpy(h80211, tmpbuf + n, *caplen); } } nb_pkt_read++; if (filter_packet(h80211, *caplen) != 0) continue; if (opt.fast) break; z = ((h80211[1] & IEEE80211_FC1_DIR_MASK) != IEEE80211_FC1_DIR_DSTODS) ? 24 : 30; if ((h80211[0] & IEEE80211_FC0_SUBTYPE_QOS) == IEEE80211_FC0_SUBTYPE_QOS) /* QoS */ z += 2; switch (h80211[1] & IEEE80211_FC1_DIR_MASK) { case IEEE80211_FC1_DIR_NODS: mi_b = 16; mi_s = 10; mi_d = 4; is_wds = 0; break; case IEEE80211_FC1_DIR_TODS: mi_b = 4; mi_s = 10; mi_d = 16; is_wds = 0; break; case IEEE80211_FC1_DIR_FROMDS: mi_b = 10; mi_s = 16; mi_d = 4; is_wds = 0; break; case IEEE80211_FC1_DIR_DSTODS: mi_t = 10; mi_r = 4; mi_d = 16; mi_s = 24; is_wds = 1; break; // WDS packet default: abort(); } printf("\n\n Size: %d, FromDS: %d, ToDS: %d", *caplen, (h80211[1] & IEEE80211_FC1_DIR_FROMDS) >> 1, (h80211[1] & IEEE80211_FC1_DIR_TODS)); if ((h80211[0] & IEEE80211_FC0_TYPE_MASK) == IEEE80211_FC0_TYPE_DATA && (h80211[1] & IEEE80211_FC1_WEP) != 0) { // if (is_wds) key_index_offset = 33; // WDS packets // have an additional MAC, so the key index is at byte // 33 // else key_index_offset = 27; key_index_offset = z + 3; if ((h80211[key_index_offset] & 0x20) == 0) printf(" (WEP)"); else printf(" (WPA)"); } printf("\n\n"); if (is_wds) { printf(" Transmitter = %02X:%02X:%02X:%02X:%02X:%02X\n", h80211[mi_t], h80211[mi_t + 1], h80211[mi_t + 2], h80211[mi_t + 3], h80211[mi_t + 4], h80211[mi_t + 5]); printf(" Receiver = %02X:%02X:%02X:%02X:%02X:%02X\n", h80211[mi_r], h80211[mi_r + 1], h80211[mi_r + 2], h80211[mi_r + 3], h80211[mi_r + 4], h80211[mi_r + 5]); } else { printf(" BSSID = %02X:%02X:%02X:%02X:%02X:%02X\n", h80211[mi_b], h80211[mi_b + 1], h80211[mi_b + 2], h80211[mi_b + 3], h80211[mi_b + 4], h80211[mi_b + 5]); } printf(" Dest. MAC = %02X:%02X:%02X:%02X:%02X:%02X\n", h80211[mi_d], h80211[mi_d + 1], h80211[mi_d + 2], h80211[mi_d + 3], h80211[mi_d + 4], h80211[mi_d + 5]); printf(" Source MAC = %02X:%02X:%02X:%02X:%02X:%02X\n", h80211[mi_s], h80211[mi_s + 1], h80211[mi_s + 2], h80211[mi_s + 3], h80211[mi_s + 4], h80211[mi_s + 5]); /* print a hex dump of the packet */ for (i = 0; i < *caplen; i++) { if ((i & 15) == 0) { if (i == 224) { printf("\n --- CUT ---"); break; } printf("\n 0x%04x: ", i); } printf("%02x", h80211[i]); //-V781 if ((i & 1) != 0) printf(" "); if (i == *caplen - 1 && ((i + 1) & 15) != 0) { for (j = ((i + 1) & 15); j < 16; j++) { printf(" "); if ((j & 1) != 0) printf(" "); } printf(" "); for (j = 16 - ((i + 1) & 15); j < 16; j++) printf("%c", (h80211[i - 15 + j] < 32 || h80211[i - 15 + j] > 126) ? '.' : h80211[i - 15 + j]); } if (i > 0 && ((i + 1) & 15) == 0) { printf(" "); for (j = 0; j < 16; j++) printf("%c", (h80211[i - 15 + j] < 32 || h80211[i - 15 + j] > 127) ? '.' : h80211[i - 15 + j]); } } printf("\n\nUse this packet ? "); fflush(stdout); ret = 0; while (!ret) ret = scanf("%1s", tmpbuf); //-V576 printf("\n"); if (tmpbuf[0] == 'y' || tmpbuf[0] == 'Y') break; } if (!just_grab) { pfh_out.magic = TCPDUMP_MAGIC; pfh_out.version_major = PCAP_VERSION_MAJOR; pfh_out.version_minor = PCAP_VERSION_MINOR; pfh_out.thiszone = 0; pfh_out.sigfigs = 0; pfh_out.snaplen = 65535; pfh_out.linktype = LINKTYPE_IEEE802_11; lt = localtime((const time_t *) &tv.tv_sec); memset(strbuf, 0, sizeof(strbuf)); snprintf(strbuf, sizeof(strbuf) - 1, "replay_src-%02d%02d-%02d%02d%02d.cap", lt->tm_mon + 1, lt->tm_mday, lt->tm_hour, lt->tm_min, lt->tm_sec); printf("Saving chosen packet in %s\n", strbuf); if ((f_cap_out = fopen(strbuf, "wb+")) == NULL) { perror("fopen failed"); return (EXIT_FAILURE); } n = sizeof(struct pcap_file_header); if (fwrite(&pfh_out, n, 1, f_cap_out) != 1) { fclose(f_cap_out); perror("fwrite failed\n"); return (EXIT_FAILURE); } pkh.tv_sec = tv.tv_sec; pkh.tv_usec = tv.tv_usec; pkh.caplen = *caplen; pkh.len = *caplen; n = sizeof(pkh); if (fwrite(&pkh, n, 1, f_cap_out) != 1) { fclose(f_cap_out); perror("fwrite failed"); return (EXIT_FAILURE); } n = pkh.caplen; if (fwrite(h80211, n, 1, f_cap_out) != 1) { fclose(f_cap_out); perror("fwrite failed"); return (EXIT_FAILURE); } fclose(f_cap_out); } return (EXIT_SUCCESS); } #define AIRODUMP_NG_CSV_EXT "csv" #define KISMET_CSV_EXT "kismet.csv" #define KISMET_NETXML_EXT "kismet.netxml" #define AIRODUMP_NG_GPS_EXT "gps" #define AIRODUMP_NG_CAP_EXT "cap" #define AIRODUMP_NG_LOG_CSV_EXT "log.csv" static const char * f_ext[] = {AIRODUMP_NG_CSV_EXT, AIRODUMP_NG_GPS_EXT, AIRODUMP_NG_CAP_EXT, IVS2_EXTENSION, KISMET_CSV_EXT, KISMET_NETXML_EXT, AIRODUMP_NG_LOG_CSV_EXT}; /* setup the output files */ int dump_initialize_multi_format(char * prefix, int ivs_only) { REQUIRE(prefix != NULL); REQUIRE(strlen(prefix) > 0); const size_t ADDED_LENGTH = 17; size_t i; size_t ofn_len; FILE * f; char * ofn = NULL; /* If you only want to see what happening, send all data to /dev/null */ /* Create a buffer of the length of the prefix + '-' + 2 numbers + '.' + longest extension ("kismet.netxml") + terminating 0. */ ofn_len = strlen(prefix) + ADDED_LENGTH + 1; ofn = (char *) calloc(1, ofn_len); ALLEGE(ofn != NULL); opt.f_index = 1; /* Make sure no file with the same name & all possible file extensions. */ do { for (i = 0; i < ArrayCount(f_ext); i++) { memset(ofn, 0, ofn_len); snprintf(ofn, ofn_len, "%s-%02d.%s", prefix, opt.f_index, f_ext[i]); if ((f = fopen(ofn, "rb+")) != NULL) { fclose(f); opt.f_index++; break; } } } /* If we did all extensions then no file with that name or extension exist so we can use that number */ while (i < ArrayCount(f_ext)); opt.prefix = (char *) calloc(1, strlen(prefix) + 1); ALLEGE(opt.prefix != NULL); memcpy(opt.prefix, prefix, strlen(prefix) + 1); /* create the output CSV file */ if (opt.output_format_csv) { memset(ofn, 0, ofn_len); snprintf(ofn, ofn_len, "%s-%02d.%s", prefix, opt.f_index, AIRODUMP_NG_CSV_EXT); if ((opt.f_txt = fopen(ofn, "wb+")) == NULL) { perror("fopen failed"); fprintf(stderr, "Could not create \"%s\".\n", ofn); free(ofn); return (1); } } /* create the output for a rolling log CSV file */ if (opt.output_format_log_csv) { memset(ofn, 0, ofn_len); snprintf(ofn, ofn_len, "%s-%02d.%s", prefix, opt.f_index, AIRODUMP_NG_LOG_CSV_EXT); if ((opt.f_logcsv = fopen(ofn, "wb+")) == NULL) { perror("fopen failed"); fprintf(stderr, "Could not create \"%s\".\n", ofn); free(ofn); return (1); } fprintf(opt.f_logcsv, "LocalTime, GPSTime, ESSID, BSSID, Power, " "Security, Latitude, Longitude, Latitude Error, " "Longitude Error, Type\r\n"); } /* create the output Kismet CSV file */ if (opt.output_format_kismet_csv) { memset(ofn, 0, ofn_len); snprintf( ofn, ofn_len, "%s-%02d.%s", prefix, opt.f_index, KISMET_CSV_EXT); if ((opt.f_kis = fopen(ofn, "wb+")) == NULL) { perror("fopen failed"); fprintf(stderr, "Could not create \"%s\".\n", ofn); free(ofn); return (1); } } /* create the output GPS file */ if (opt.usegpsd) { memset(ofn, 0, ofn_len); snprintf(ofn, ofn_len, "%s-%02d.%s", prefix, opt.f_index, AIRODUMP_NG_GPS_EXT); if ((opt.f_gps = fopen(ofn, "wb+")) == NULL) { perror("fopen failed"); fprintf(stderr, "Could not create \"%s\".\n", ofn); free(ofn); return (1); } } /* Create the output kismet.netxml file */ if (opt.output_format_kismet_netxml) { memset(ofn, 0, ofn_len); snprintf( ofn, ofn_len, "%s-%02d.%s", prefix, opt.f_index, KISMET_NETXML_EXT); if ((opt.f_kis_xml = fopen(ofn, "wb+")) == NULL) { perror("fopen failed"); fprintf(stderr, "Could not create \"%s\".\n", ofn); free(ofn); return (1); } } /* create the output packet capture file */ if (opt.output_format_pcap) { struct pcap_file_header pfh; memset(ofn, 0, ofn_len); snprintf(ofn, ofn_len, "%s-%02d.%s", prefix, opt.f_index, AIRODUMP_NG_CAP_EXT); if ((opt.f_cap = fopen(ofn, "wb+")) == NULL) { perror("fopen failed"); fprintf(stderr, "Could not create \"%s\".\n", ofn); free(ofn); return (1); } opt.f_cap_name = (char *) calloc(1, strlen(ofn) + 1); ALLEGE(opt.f_cap_name != NULL); memcpy(opt.f_cap_name, ofn, strlen(ofn) + 1); pfh.magic = TCPDUMP_MAGIC; pfh.version_major = PCAP_VERSION_MAJOR; pfh.version_minor = PCAP_VERSION_MINOR; pfh.thiszone = 0; pfh.sigfigs = 0; pfh.snaplen = 65535; pfh.linktype = LINKTYPE_IEEE802_11; if (fwrite(&pfh, 1, sizeof(pfh), opt.f_cap) != (size_t) sizeof(pfh)) { perror("fwrite(pcap file header) failed"); free(ofn); return (1); } if (!opt.quiet) { PCT; printf("Created capture file \"%s\".\n", ofn); } free(ofn); } else if (ivs_only) { struct ivs2_filehdr fivs2; fivs2.version = IVS2_VERSION; memset(ofn, 0, ofn_len); snprintf( ofn, ofn_len, "%s-%02d.%s", prefix, opt.f_index, IVS2_EXTENSION); if ((opt.f_ivs = fopen(ofn, "wb+")) == NULL) { perror("fopen failed"); fprintf(stderr, "Could not create \"%s\".\n", ofn); free(ofn); return (1); } free(ofn); if (fwrite(IVS2_MAGIC, 1, 4, opt.f_ivs) != (size_t) 4) { perror("fwrite(IVs file MAGIC) failed"); return (1); } if (fwrite(&fivs2, 1, sizeof(struct ivs2_filehdr), opt.f_ivs) != (size_t) sizeof(struct ivs2_filehdr)) { perror("fwrite(IVs file header) failed"); return (1); } } else { free(ofn); } return (0); } int dump_initialize(char * prefix) { opt.output_format_pcap = 1; return dump_initialize_multi_format(prefix, 0); } int check_shared_key(const uint8_t * h80211, size_t caplen) { int m_bmac = 16; int m_smac = 10; int m_dmac = 4; size_t n; size_t textlen; int maybe_broken; char ofn[1024]; uint8_t text[4096]; uint8_t prga[4096 + 4]; unsigned int long crc = 0xFFFFFFFF; if (!(h80211 != NULL && caplen > 0 && caplen < (int) sizeof(opt.sharedkey[0]))) { return (1); } if (time(NULL) - opt.sk_start > 5) { /* timeout(5sec) - remove all packets, restart timer */ memset(opt.sharedkey, '\x00', sizeof(opt.sharedkey)); opt.sk_start = time(NULL); } /* is auth packet */ if ((h80211[1] & IEEE80211_FC1_PROTECTED) != IEEE80211_FC1_PROTECTED) { /* not encrypted */ if ((h80211[24] + (h80211[25] << 8)) == 1) { /* Shared-Key Authentication */ if ((h80211[26] + (h80211[27] << 8)) == 2) { /* sequence == 2 */ memcpy(opt.sharedkey[0], h80211, caplen); opt.sk_len = caplen - 24; } if ((h80211[26] + (h80211[27] << 8)) == 4) { /* sequence == 4 */ memcpy(opt.sharedkey[2], h80211, caplen); } } else return (1); } else { /* encrypted */ memcpy(opt.sharedkey[1], h80211, caplen); opt.sk_len2 = caplen - 24 - 4; } /* check if the 3 packets form a proper authentication */ if ((memcmp(opt.sharedkey[0] + m_bmac, NULL_MAC, ETHER_ADDR_LEN) == 0) || (memcmp(opt.sharedkey[1] + m_bmac, NULL_MAC, ETHER_ADDR_LEN) == 0) || (memcmp(opt.sharedkey[2] + m_bmac, NULL_MAC, ETHER_ADDR_LEN) == 0)) /* some bssids == zero */ { return (1); } if ((memcmp(opt.sharedkey[0] + m_bmac, opt.sharedkey[1] + m_bmac, ETHER_ADDR_LEN) != 0) || (memcmp(opt.sharedkey[0] + m_bmac, opt.sharedkey[2] + m_bmac, ETHER_ADDR_LEN) != 0)) /* all bssids aren't equal */ { return (1); } if ((memcmp(opt.sharedkey[0] + m_smac, opt.sharedkey[2] + m_smac, ETHER_ADDR_LEN) != 0) || (memcmp(opt.sharedkey[0] + m_smac, opt.sharedkey[1] + m_dmac, ETHER_ADDR_LEN) != 0)) /* SA in 2&4 != DA in 3 */ { return (1); } if ((memcmp(opt.sharedkey[0] + m_dmac, opt.sharedkey[2] + m_dmac, ETHER_ADDR_LEN) != 0) || (memcmp(opt.sharedkey[0] + m_dmac, opt.sharedkey[1] + m_smac, ETHER_ADDR_LEN) != 0)) /* DA in 2&4 != SA in 3 */ { return (1); } textlen = opt.sk_len; maybe_broken = 0; /* this check is probably either broken or not very reliable, since there are known cases when it is hit with valid data. rather than doing a hard exit here, we now set a flag so the .xor file is only written if not already existing, in order to make sure we don't overwrite a good .xor file with a potentially broken one; but on the other hand if none exist already, we do want it being written. */ if (textlen + 4 != opt.sk_len2) { if (!opt.quiet) { PCT; printf("Broken SKA: %02X:%02X:%02X:%02X:%02X:%02X (expected: %zu, " "got %zu bytes)\n", *(opt.sharedkey[0] + m_dmac), *(opt.sharedkey[0] + m_dmac + 1), *(opt.sharedkey[0] + m_dmac + 2), *(opt.sharedkey[0] + m_dmac + 3), *(opt.sharedkey[0] + m_dmac + 4), *(opt.sharedkey[0] + m_dmac + 5), textlen + 4, opt.sk_len2); } maybe_broken = 1; } if (textlen > sizeof(text) - 4) return (1); memcpy(text, opt.sharedkey[0] + 24, textlen); /* increment sequence number from 2 to 3 */ text[2] = (uint8_t)(text[2] + 1); for (n = 0; n < textlen; n++) crc = crc_tbl[(crc ^ text[n]) & 0xFF] ^ (crc >> 8); crc = ~crc; /* append crc32 over body */ text[textlen] = (uint8_t)((crc) &0xFF); text[textlen + 1] = (uint8_t)((crc >> 8) & 0xFF); text[textlen + 2] = (uint8_t)((crc >> 16) & 0xFF); text[textlen + 3] = (uint8_t)((crc >> 24) & 0xFF); /* cleartext XOR cipher */ for (n = 0u; n < (textlen + 4u); n++) { prga[4 + n] = (uint8_t)((text[n] ^ opt.sharedkey[1][28 + n]) & 0xFF); } /* write IV+index */ prga[0] = (uint8_t)(opt.sharedkey[1][24] & 0xFF); prga[1] = (uint8_t)(opt.sharedkey[1][25] & 0xFF); prga[2] = (uint8_t)(opt.sharedkey[1][26] & 0xFF); prga[3] = (uint8_t)(opt.sharedkey[1][27] & 0xFF); if (opt.f_xor != NULL) { fclose(opt.f_xor); opt.f_xor = NULL; } snprintf(ofn, sizeof(ofn) - 1, "%s-%02d-%02X-%02X-%02X-%02X-%02X-%02X.%s", opt.prefix, opt.f_index, *(opt.sharedkey[0] + m_bmac), *(opt.sharedkey[0] + m_bmac + 1), *(opt.sharedkey[0] + m_bmac + 2), *(opt.sharedkey[0] + m_bmac + 3), *(opt.sharedkey[0] + m_bmac + 4), *(opt.sharedkey[0] + m_bmac + 5), "xor"); if (maybe_broken && (opt.f_xor = fopen(ofn, "r"))) { /* do not overwrite existing .xor file with maybe broken one */ fclose(opt.f_xor); opt.f_xor = NULL; return (1); } opt.f_xor = fopen(ofn, "w"); if (opt.f_xor == NULL) return (1); for (n = 0; n < textlen + 8; n++) fputc((prga[n] & 0xFF), opt.f_xor); fclose(opt.f_xor); opt.f_xor = NULL; if (!opt.quiet) { PCT; printf("Got %zu bytes keystream: %02X:%02X:%02X:%02X:%02X:%02X\n", textlen + 4, *(opt.sharedkey[0] + m_dmac), *(opt.sharedkey[0] + m_dmac + 1), *(opt.sharedkey[0] + m_dmac + 2), *(opt.sharedkey[0] + m_dmac + 3), *(opt.sharedkey[0] + m_dmac + 4), *(opt.sharedkey[0] + m_dmac + 5)); } memset(opt.sharedkey, '\x00', sizeof(opt.sharedkey)); return (0); } int encrypt_data(uint8_t * data, size_t length) { uint8_t cipher[4096]; uint8_t K[128]; if (data == NULL) return (1); if (length < 1 || length > 2044) return (1); if (opt.prga == NULL && opt.crypt != CRYPT_WEP) { printf("Please specify a WEP key (-w).\n"); return (1); } if (opt.prgalen - 4 < length && opt.crypt != CRYPT_WEP) { printf( "Please specify a longer PRGA file (-y) with at least %zu bytes.\n", (length + 4)); return (1); } /* encrypt data */ if (opt.crypt == CRYPT_WEP) { K[0] = rand_u8(); K[1] = rand_u8(); K[2] = rand_u8(); memcpy(K + 3, opt.wepkey, opt.weplen); encrypt_wep(data, (int) length, K, (int) opt.weplen + 3); memcpy(cipher, data, length); memcpy(data + 4, cipher, length); memcpy(data, K, 3); //-V512 data[3] = 0x00; } return (0); } int create_wep_packet(uint8_t * packet, size_t * length, size_t hdrlen) { if (packet == NULL) return (1); if (length == NULL) return (1); if (hdrlen >= INT_MAX) return (1); if (*length >= INT_MAX) return (1); if (*length - hdrlen >= INT_MAX) return (1); /* write crc32 value behind data */ if (add_crc32(packet + hdrlen, (int) (*length - hdrlen)) != 0) return (1); /* encrypt data+crc32 and keep a 4byte hole */ if (encrypt_data(packet + hdrlen, *length - hdrlen + 4) != 0) return (1); /* set WEP bit */ packet[1] = (uint8_t)(packet[1] | 0x40); *length += 8; /* now you got yourself a shiny, brand new encrypted wep packet ;) */ return (0); } int set_clear_arp(uint8_t * buf, uint8_t * smac, uint8_t * dmac) // set first 22 bytes { if (buf == NULL) return (-1); memcpy(buf, S_LLC_SNAP_ARP, 8); buf[8] = 0x00; buf[9] = 0x01; // ethernet buf[10] = 0x08; // IP buf[11] = 0x00; buf[12] = 0x06; // hardware size buf[13] = 0x04; // protocol size buf[14] = 0x00; if (memcmp(dmac, BROADCAST, ETHER_ADDR_LEN) == 0) buf[15] = 0x01; // request else buf[15] = 0x02; // reply memcpy(buf + 16, smac, ETHER_ADDR_LEN); return (0); } int set_final_arp(uint8_t * buf, uint8_t * mymac) { if (buf == NULL) return (-1); // shifted by 10bytes to set source IP as target IP :) buf[0] = 0x08; //-V525 // IP buf[1] = 0x00; buf[2] = 0x06; // hardware size buf[3] = 0x04; // protocol size buf[4] = 0x00; buf[5] = 0x01; // request memcpy(buf + 6, mymac, ETHER_ADDR_LEN); // sender mac buf[12] = 0xA9; // sender IP 169.254.87.197 buf[13] = 0xFE; buf[14] = 0x57; buf[15] = 0xC5; // end sender IP return (0); } int set_clear_ip(uint8_t * buf, size_t ip_len) // set first 9 bytes { if (buf == NULL) return (-1); memcpy(buf, S_LLC_SNAP_IP, 8); buf[8] = 0x45; buf[10] = (uint8_t)((ip_len >> 8) & 0xFF); buf[11] = (uint8_t)(ip_len & 0xFF); return (0); } int set_final_ip(uint8_t * buf, uint8_t * mymac) { if (buf == NULL) return (-1); // shifted by 10bytes to set source IP as target IP :) buf[0] = 0x06; // hardware size buf[1] = 0x04; // protocol size buf[2] = 0x00; buf[3] = 0x01; // request memcpy(buf + 4, mymac, ETHER_ADDR_LEN); // sender mac buf[10] = 0xA9; // sender IP from 169.254.XXX.XXX buf[11] = 0xFE; buf[12] = 0x57; buf[13] = 0xC5; // end sender IP return (0); } int msleep(int msec) { struct timeval tv, tv2; float f, ticks; int n; ssize_t rc; if (msec == 0) msec = 1; ticks = 0; while (1) { /* wait for the next timer interrupt, or sleep */ if (dev.fd_rtc >= 0) { if ((rc = read(dev.fd_rtc, &n, sizeof(n))) < 0) { perror("read(/dev/rtc) failed"); } else if (rc == 0) { perror("EOF encountered on /dev/rtc"); } else { ticks++; } } else { /* we can't trust usleep, since it depends on the HZ */ gettimeofday(&tv, NULL); usleep(1024); gettimeofday(&tv2, NULL); f = 1000000 * (float) (tv2.tv_sec - tv.tv_sec) + (float) (tv2.tv_usec - tv.tv_usec); ticks += f / 1024; } if ((ticks / 1024 * 1000) < msec) continue; /* threshold reached */ break; } return (0); } int read_prga(unsigned char ** dest, char * file) { FILE * f; ssize_t size; if (file == NULL) return (EXIT_FAILURE); if (*dest == NULL) { *dest = (unsigned char *) malloc(1501); ALLEGE(*dest != NULL); } if (memcmp(file + (strlen(file) - 4), ".xor", 4) != 0) { printf("Is this really a PRGA file: %s?\n", file); } f = fopen(file, "r"); if (f == NULL) { printf("Error opening %s\n", file); return (EXIT_FAILURE); } fseek(f, 0, SEEK_END); size = ftell(f); if (size == -1) { fclose(f); fprintf(stderr, "ftell failed\n"); return (EXIT_FAILURE); } rewind(f); if (size > 1500) size = 1500; if (fread((*dest), (size_t) size, 1, f) != 1) { fclose(f); fprintf(stderr, "fread failed\n"); return (EXIT_FAILURE); } if ((*dest)[3] > 0x03) { printf("Are you really sure that this is a valid key-stream? Because " "the index is out of range (0-3): %02X\n", (*dest)[3]); } opt.prgalen = (size_t) size; fclose(f); return (EXIT_SUCCESS); } int set_bitrate(struct wif * wi, int rate) { size_t j; int i; int newrate; if (wi_set_rate(wi, rate)) return (1); // Workaround for buggy drivers (rt73) that do not accept 5.5M, but 5M // instead if (rate == 5500000 && wi_get_rate(wi) != 5500000) { if (wi_set_rate(wi, 5000000)) return (1); } newrate = wi_get_rate(wi); for (j = 0; j < ArrayCount(bitrates); j++) { if (bitrates[j] == rate) break; } if (j == ArrayCount(bitrates)) i = -1; else i = (int) j; if (newrate != rate) { if (i != -1) { if (i > 0) { if (bitrates[i - 1] >= newrate) { printf( "Couldn't set rate to %.1fMBit. (%.1fMBit instead)\n", (rate / 1000000.0), (wi_get_rate(wi) / 1000000.0)); return (1); } } if (i < (int) ArrayCount(bitrates) - 1) { if (bitrates[i + 1] <= newrate) { printf( "Couldn't set rate to %.1fMBit. (%.1fMBit instead)\n", (rate / 1000000.0), (wi_get_rate(wi) / 1000000.0)); return (1); } } return (0); } printf("Couldn't set rate to %.1fMBit. (%.1fMBit instead)\n", (rate / 1000000.0), (wi_get_rate(wi) / 1000000.0)); return (1); } return (0); } aircrack-ng-1.6/lib/libac/support/crypto_engine_loader.c000066400000000000000000000401221361312141100234240ustar00rootroot00000000000000/* * Copyright (C) 2018 Joseph Benden * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * is provided AS IS, WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and * NON-INFRINGEMENT. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, * MA 02110-1301, USA. * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #define _GNU_SOURCE #include #include #include #include #include #ifndef STATIC_BUILD #include #endif #include "aircrack-ng/ce-wpa/crypto_engine.h" #include "aircrack-ng/support/crypto_engine_loader.h" #include "aircrack-ng/support/common.h" #include "aircrack-ng/cpu/trampoline.h" #ifndef STATIC_BUILD static void * module = NULL; #endif #ifdef STATIC_BUILD int (*dso_ac_crypto_engine_init)(ac_crypto_engine_t * engine) = &ac_crypto_engine_init; void (*dso_ac_crypto_engine_destroy)(ac_crypto_engine_t * engine) = &ac_crypto_engine_destroy; void (*dso_ac_crypto_engine_set_essid)(ac_crypto_engine_t * engine, const uint8_t * essid) = &ac_crypto_engine_set_essid; int (*dso_ac_crypto_engine_thread_init)(ac_crypto_engine_t * engine, int threadid) = &ac_crypto_engine_thread_init; void (*dso_ac_crypto_engine_thread_destroy)(ac_crypto_engine_t * engine, int threadid) = &ac_crypto_engine_thread_destroy; int (*dso_ac_crypto_engine_simd_width)(void) = &ac_crypto_engine_simd_width; int (*dso_ac_crypto_engine_wpa_crack)( ac_crypto_engine_t * engine, const wpapsk_password key[MAX_KEYS_PER_CRYPT_SUPPORTED], const uint8_t eapol[256], uint32_t eapol_size, uint8_t mic[MAX_KEYS_PER_CRYPT_SUPPORTED][20], uint8_t keyver, const uint8_t cmpmic[20], int nparallel, int threadid) = &ac_crypto_engine_wpa_crack; void (*dso_ac_crypto_engine_calc_pke)(ac_crypto_engine_t * engine, const uint8_t bssid[6], const uint8_t stmac[6], const uint8_t anonce[32], const uint8_t snonce[32], int threadid) = &ac_crypto_engine_calc_pke; int (*dso_ac_crypto_engine_wpa_pmkid_crack)( ac_crypto_engine_t * engine, const wpapsk_password key[MAX_KEYS_PER_CRYPT_SUPPORTED], const uint8_t pmkid[32], int nparallel, int threadid) = &ac_crypto_engine_wpa_pmkid_crack; void (*dso_ac_crypto_engine_set_pmkid_salt)(ac_crypto_engine_t * engine, const uint8_t bssid[6], const uint8_t stmac[6], int threadid) = &ac_crypto_engine_set_pmkid_salt; int (*dso_ac_crypto_engine_supported_features)(void) = &ac_crypto_engine_supported_features; uint8_t * (*dso_ac_crypto_engine_get_pmk)(ac_crypto_engine_t * engine, int threadid, int index) = &ac_crypto_engine_get_pmk; uint8_t * (*dso_ac_crypto_engine_get_ptk)(ac_crypto_engine_t * engine, int threadid, int index) = &ac_crypto_engine_get_ptk; void (*dso_ac_crypto_engine_calc_one_pmk)(const uint8_t * key, const uint8_t * essid, uint32_t essid_length, uint8_t pmk[40]) = &ac_crypto_engine_calc_one_pmk; void (*dso_ac_crypto_engine_calc_pmk)( ac_crypto_engine_t * engine, const wpapsk_password key[MAX_KEYS_PER_CRYPT_SUPPORTED], int nparallel, int threadid) = &ac_crypto_engine_calc_pmk; void (*dso_ac_crypto_engine_calc_mic)(ac_crypto_engine_t * engine, const uint8_t eapol[256], const uint32_t eapol_size, uint8_t mic[MAX_KEYS_PER_CRYPT_SUPPORTED] [20], const uint8_t keyver, const int vectorIdx, const int threadid) = &ac_crypto_engine_calc_mic; #else int (*dso_ac_crypto_engine_init)(ac_crypto_engine_t * engine) = NULL; void (*dso_ac_crypto_engine_destroy)(ac_crypto_engine_t * engine) = NULL; void (*dso_ac_crypto_engine_set_essid)(ac_crypto_engine_t * engine, const uint8_t * essid) = NULL; int (*dso_ac_crypto_engine_thread_init)(ac_crypto_engine_t * engine, int threadid) = NULL; void (*dso_ac_crypto_engine_thread_destroy)(ac_crypto_engine_t * engine, int threadid) = NULL; int (*dso_ac_crypto_engine_simd_width)(void) = NULL; int (*dso_ac_crypto_engine_wpa_crack)( ac_crypto_engine_t * engine, const wpapsk_password key[MAX_KEYS_PER_CRYPT_SUPPORTED], const uint8_t eapol[256], uint32_t eapol_size, uint8_t mic[MAX_KEYS_PER_CRYPT_SUPPORTED][20], uint8_t keyver, const uint8_t cmpmic[20], int nparallel, int threadid) = NULL; void (*dso_ac_crypto_engine_calc_pke)(ac_crypto_engine_t * engine, const uint8_t bssid[6], const uint8_t stmac[6], const uint8_t anonce[32], const uint8_t snonce[32], int threadid) = NULL; int (*dso_ac_crypto_engine_wpa_pmkid_crack)( ac_crypto_engine_t * engine, const wpapsk_password key[MAX_KEYS_PER_CRYPT_SUPPORTED], const uint8_t pmkid[32], int nparallel, int threadid) = NULL; void (*dso_ac_crypto_engine_set_pmkid_salt)(ac_crypto_engine_t * engine, const uint8_t bssid[6], const uint8_t stmac[6], int threadid) = NULL; int (*dso_ac_crypto_engine_supported_features)(void) = NULL; uint8_t * (*dso_ac_crypto_engine_get_pmk)(ac_crypto_engine_t * engine, int threadid, int index) = NULL; uint8_t * (*dso_ac_crypto_engine_get_ptk)(ac_crypto_engine_t * engine, int threadid, int index) = NULL; void (*dso_ac_crypto_engine_calc_one_pmk)(const uint8_t * key, const uint8_t * essid, uint32_t essid_length, uint8_t pmk[40]) = NULL; void (*dso_ac_crypto_engine_calc_pmk)( ac_crypto_engine_t * engine, const wpapsk_password key[MAX_KEYS_PER_CRYPT_SUPPORTED], int nparallel, int threadid) = NULL; void (*dso_ac_crypto_engine_calc_mic)(ac_crypto_engine_t * engine, const uint8_t eapol[256], const uint32_t eapol_size, uint8_t mic[MAX_KEYS_PER_CRYPT_SUPPORTED] [20], const uint8_t keyver, const int vectorIdx, const int threadid) = NULL; #endif #if defined(CYGWIN) /* This is merely a hack until code refactoring can occur. A new module is needed for handling file and path operations, because this here is only a step towards correctly getting the executable path for all operating systems. It was required for Cygwin to determine the location of the Crypto Engine DLLs which are in the same folder as the executable. */ #include #include #include #include #include #include #include static char * get_executable_directory(void) { HMODULE hModule = GetModuleHandle(NULL); CHAR path[MAX_PATH]; GetModuleFileNameA(hModule, path, MAX_PATH); PathRemoveFileSpecA(path); cygwin_conv_path_t flags = CCP_WIN_A_TO_POSIX; char * winpath = (char *) cygwin_create_path(flags, path); return winpath; } #endif EXPORT int ac_crypto_engine_loader_get_available(void) { int simd_flags = SIMD_SUPPORTS_NONE; char library_path[8192]; #if defined(WIN32_PORTABLE) char * working_directory = get_executable_directory(); #else // are we inside of the build path? char * working_directory = get_current_working_directory(); #endif if (strncmp(working_directory, ABS_TOP_BUILDDIR, strlen(ABS_TOP_BUILDDIR)) == 0 || strncmp(working_directory, ABS_TOP_SRCDIR, strlen(ABS_TOP_SRCDIR)) == 0) { // use development paths snprintf(library_path, sizeof(library_path) - 1, "%s%s", LIBAIRCRACK_CE_WPA_PATH, LT_OBJDIR); } else { #if defined(WIN32_PORTABLE) // use the current directory snprintf(library_path, sizeof(library_path) - 1, working_directory); #else // use installation paths snprintf(library_path, sizeof(library_path) - 1, "%s", LIBDIR); #endif } free(working_directory); // enumerate all DSOs in folder, opening, searching symbols, and testing // them. DIR * dsos = opendir(library_path); if (!dsos) goto out; struct dirent * entry = NULL; while ((entry = readdir(dsos)) != NULL) { #if defined(__APPLE__) if (string_has_suffix((char *) entry->d_name, ".dylib")) #elif defined(WIN32) || defined(_WIN32) || defined(CYGWIN) if (string_has_suffix((char *) entry->d_name, ".dll")) #else if (string_has_suffix((char *) entry->d_name, ".so")) #endif { char * search = strstr(entry->d_name, "aircrack-ce-wpa-"); if (search) { search += 16; int flag; if ((flag = ac_crypto_engine_loader_string_to_flag(search)) != -1) simd_flags |= flag; } } } closedir(dsos); out: return simd_flags; } EXPORT char * ac_crypto_engine_loader_best_library_for(int simd_features) { char buffer[8192] = {"aircrack-ce-wpa"}; char library_path[8192]; char module_filename[8192]; size_t buffer_remaining = 8192 - strlen(buffer) - 1; if (simd_features & SIMD_SUPPORTS_AVX512F) { strncat(buffer, "-x86-avx512", buffer_remaining); } else if (simd_features & SIMD_SUPPORTS_AVX2) { strncat(buffer, "-x86-avx2", buffer_remaining); } else if (simd_features & SIMD_SUPPORTS_AVX) { strncat(buffer, "-x86-avx", buffer_remaining); } else if (simd_features & SIMD_SUPPORTS_SSE2) { strncat(buffer, "-x86-sse2", buffer_remaining); } else if (simd_features & SIMD_SUPPORTS_ASIMD) { strncat(buffer, "-arm-neon", buffer_remaining); } else if (simd_features & SIMD_SUPPORTS_NEON) { strncat(buffer, "-arm-neon", buffer_remaining); } else if (simd_features & SIMD_SUPPORTS_POWER8) { strncat(buffer, "-ppc-power8", buffer_remaining); } else if (simd_features & SIMD_SUPPORTS_ALTIVEC) { strncat(buffer, "-ppc-altivec", buffer_remaining); } char * working_directory = get_current_working_directory(); // or the binary's path? if (strncmp( working_directory, ABS_TOP_BUILDDIR, sizeof(ABS_TOP_BUILDDIR) - 1) == 0 || strncmp( working_directory, ABS_TOP_SRCDIR, sizeof(ABS_TOP_SRCDIR) - 1) == 0) { // use development paths snprintf(library_path, sizeof(library_path) - 1, "%s%s", LIBAIRCRACK_CE_WPA_PATH, LT_OBJDIR); } else { // use installation paths snprintf(library_path, sizeof(library_path) - 1, "%s", LIBDIR); } free(working_directory); snprintf(module_filename, sizeof(module_filename) - 1, #if defined(WIN32_PORTABLE) "%s%s%s", #else "%s/%s%s%s", library_path, #endif #if defined(WIN32) || defined(_WIN32) || defined(CYGWIN) #if defined(MSYS2) "msys-", #else "cyg", #endif #else "lib", #endif buffer, #if defined(WIN32) || defined(_WIN32) || defined(CYGWIN) LT_CYGWIN_VER #elif defined(__APPLE__) ".dylib" #else ".so" #endif ) < 0 ? abort() : (void) 0; return strdup(module_filename); } EXPORT int ac_crypto_engine_loader_string_to_flag(const char * const str) { int simd_features = -1; if (strncmp(str, "avx512", 6) == 0 || strncmp(str, "x86-avx512", 10) == 0) simd_features = SIMD_SUPPORTS_AVX512F; else if (strncmp(str, "avx2", 4) == 0 || strncmp(str, "x86-avx2", 8) == 0) simd_features = SIMD_SUPPORTS_AVX2; else if (strncmp(str, "avx", 3) == 0 || strncmp(str, "x86-avx", 7) == 0) simd_features = SIMD_SUPPORTS_AVX; else if (strncmp(str, "sse2", 4) == 0 || strncmp(str, "x86-sse2", 8) == 0) simd_features = SIMD_SUPPORTS_SSE2; else if (strncmp(str, "neon", 4) == 0 || strncmp(str, "arm-neon", 8) == 0) simd_features = SIMD_SUPPORTS_NEON; else if (strncmp(str, "asimd", 5) == 0 || strncmp(str, "arm-asimd", 9) == 0) simd_features = SIMD_SUPPORTS_ASIMD; else if (strncmp(str, "altivec", 7) == 0 || strncmp(str, "ppc-altivec", 11) == 0) simd_features = SIMD_SUPPORTS_ALTIVEC; else if (strncmp(str, "power8", 6) == 0 || strncmp(str, "ppc-power8", 10) == 0) simd_features = SIMD_SUPPORTS_POWER8; else if (strncmp(str, "generic", 7) == 0) simd_features = SIMD_SUPPORTS_NONE; return simd_features; } EXPORT char * ac_crypto_engine_loader_flags_to_string(int flags) { char buffer[8192] = {0}; if (flags & SIMD_SUPPORTS_AVX512F) strncat(buffer, "avx512 ", 8); if (flags & SIMD_SUPPORTS_AVX2) strncat(buffer, "avx2 ", 6); if (flags & SIMD_SUPPORTS_AVX) strncat(buffer, "avx ", 5); if (flags & SIMD_SUPPORTS_SSE2) strncat(buffer, "sse2 ", 6); if (flags & SIMD_SUPPORTS_NEON) strncat(buffer, "neon ", 6); if (flags & SIMD_SUPPORTS_ASIMD) strncat(buffer, "asimd ", 7); if (flags & SIMD_SUPPORTS_ALTIVEC) strncat(buffer, "altivec ", 9); if (flags & SIMD_SUPPORTS_POWER8) strncat(buffer, "power8 ", 8); strncat(buffer, "generic", 8); return strdup(buffer); } EXPORT int ac_crypto_engine_loader_load(int flags) { #ifndef STATIC_BUILD if (flags == -1) flags = ac_crypto_engine_loader_get_available(); char * module_filename = ac_crypto_engine_loader_best_library_for(flags); module = dlopen(module_filename, RTLD_LAZY); if (!module) { const char * msg = dlerror(); fprintf(stderr, "Could not open '%s': %s\n", module_filename, msg ? msg : ""); free(module_filename); return 1; } // resolve symbols needed struct _dso_symbols { char const * sym; void * addr; } dso_symbols[] = { {"ac_crypto_engine_init", (void *) &dso_ac_crypto_engine_init}, {"ac_crypto_engine_destroy", (void *) &dso_ac_crypto_engine_destroy}, {"ac_crypto_engine_thread_init", (void *) &dso_ac_crypto_engine_thread_init}, {"ac_crypto_engine_thread_destroy", (void *) &dso_ac_crypto_engine_thread_destroy}, {"ac_crypto_engine_set_essid", (void *) &dso_ac_crypto_engine_set_essid}, {"ac_crypto_engine_simd_width", (void *) &dso_ac_crypto_engine_simd_width}, {"ac_crypto_engine_wpa_crack", (void *) &dso_ac_crypto_engine_wpa_crack}, {"ac_crypto_engine_wpa_pmkid_crack", (void *) &dso_ac_crypto_engine_wpa_pmkid_crack}, {"ac_crypto_engine_calc_pke", (void *) &dso_ac_crypto_engine_calc_pke}, {"ac_crypto_engine_set_pmkid_salt", (void *) &dso_ac_crypto_engine_set_pmkid_salt}, {"ac_crypto_engine_supported_features", (void *) &dso_ac_crypto_engine_supported_features}, {"ac_crypto_engine_get_pmk", (void *) &dso_ac_crypto_engine_get_pmk}, {"ac_crypto_engine_get_ptk", (void *) &dso_ac_crypto_engine_get_ptk}, {"ac_crypto_engine_calc_one_pmk", (void *) &dso_ac_crypto_engine_calc_one_pmk}, {"ac_crypto_engine_calc_pmk", (void *) &dso_ac_crypto_engine_calc_pmk}, {"ac_crypto_engine_calc_mic", (void *) &dso_ac_crypto_engine_calc_mic}, {NULL, NULL}}; struct _dso_symbols * cur = &dso_symbols[0]; for (; cur->addr != NULL; ++cur) { if (!(*((void **) cur->addr) = dlsym(module, cur->sym))) { fprintf(stderr, "Could not find symbol %s in %s.\n", cur->sym, module_filename); dlclose(module); free(module_filename); return 1; } } free(module_filename); #endif return 0; } EXPORT void ac_crypto_engine_loader_unload(void) { #ifndef STATIC_BUILD dlclose(module); module = NULL; dso_ac_crypto_engine_init = NULL; dso_ac_crypto_engine_destroy = NULL; dso_ac_crypto_engine_thread_init = NULL; dso_ac_crypto_engine_thread_destroy = NULL; dso_ac_crypto_engine_set_essid = NULL; dso_ac_crypto_engine_simd_width = NULL; dso_ac_crypto_engine_wpa_crack = NULL; dso_ac_crypto_engine_calc_pke = NULL; dso_ac_crypto_engine_supported_features = NULL; #endif } aircrack-ng-1.6/lib/libac/support/fragments.c000066400000000000000000000202241361312141100212200ustar00rootroot00000000000000/* * Copyright (C) 2006-2018 Thomas d'Otreppe * Copyright (C) 2006-2009 Martin Beck * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. * If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. * If you * do not wish to do so, delete this exception statement from your * version. * If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include "aircrack-ng/defs.h" #include "aircrack-ng/support/common.h" #include "aircrack-ng/support/fragments.h" #include "aircrack-ng/crypto/crypto.h" extern pFrag_t rFragment; int addFrag(unsigned char * packet, unsigned char * smac, int len, int crypt, unsigned char * wepkey, int weplen) { pFrag_t cur = rFragment; int seq, frag, wep, z, i; unsigned char frame[4096]; unsigned char K[128]; if (packet == NULL) return (-1); if (smac == NULL) return (-1); if (len <= 32 || len > 2000) return (-1); if (rFragment == NULL) return (-1); memset(frame, 0, sizeof(frame)); memcpy(frame, packet, (size_t) len); z = ((frame[1] & 3) != 3) ? 24 : 30; frag = frame[22] & 0x0F; seq = (frame[22] >> 4) | (frame[23] << 4); wep = (frame[1] & 0x40) >> 6; ALLEGE(frag >= 0 && frag <= 15); //-V560 if (wep && crypt != CRYPT_WEP) return (-1); if (wep) { // decrypt it memcpy(K, frame + z, 3); memcpy(K + 3, wepkey, (size_t) weplen); if (decrypt_wep(frame + z + 4, len - z - 4, K, 3 + weplen) == 0 && (len - z - 4 > 8)) { printf("error decrypting... len: %d\n", len - z - 4); return (-1); } /* WEP data packet was successfully decrypted, * * remove the WEP IV & ICV and write the data */ len -= 8; memcpy(frame + z, frame + z + 4, (size_t) len - z); frame[1] &= 0xBF; } while (cur->next != NULL) { cur = cur->next; if ((memcmp(smac, cur->source, 6) == 0) && (seq == cur->sequence) && (wep == cur->wep)) { // entry already exists, update if (cur->fragment[frag] != NULL) return (0); if ((frame[1] & 0x04) == 0) { cur->fragnum = (char) frag; // no higher frag number possible } cur->fragment[frag] = (unsigned char *) malloc((size_t) len - z); ALLEGE(cur->fragment[frag] != NULL); memcpy(cur->fragment[frag], frame + z, (size_t) len - z); cur->fragmentlen[frag] = (short) (len - z); gettimeofday(&cur->access, NULL); return (0); } } // new entry, first fragment received // alloc mem cur->next = (pFrag_t) malloc(sizeof(struct Fragment_list)); ALLEGE(cur->next != NULL); cur = cur->next; for (i = 0; i < 16; i++) { cur->fragment[i] = NULL; cur->fragmentlen[i] = 0; } if ((frame[1] & 0x04) == 0) { cur->fragnum = (char) frag; // no higher frag number possible } else { cur->fragnum = 0; } // remove retry & more fragments flag frame[1] &= 0xF3; // set frag number to 0 frame[22] &= 0xF0; memcpy(cur->source, smac, 6); cur->sequence = (uint16_t) seq; cur->header = (unsigned char *) malloc((size_t) z); ALLEGE(cur->header != NULL); memcpy(cur->header, frame, (size_t) z); cur->headerlen = (int16_t) z; cur->fragment[frag] = (unsigned char *) malloc((size_t) len - z); ALLEGE(cur->fragment[frag] != NULL); memcpy(cur->fragment[frag], frame + z, len - z); cur->fragmentlen[frag] = (int16_t)(len - z); cur->wep = (int8_t) wep; gettimeofday(&cur->access, NULL); cur->next = NULL; return (0); } int timeoutFrag(void) { pFrag_t old, cur = rFragment; struct timeval tv; int64_t timediff; int i; if (rFragment == NULL) return (-1); gettimeofday(&tv, NULL); while (cur->next != NULL) { old = cur->next; timediff = (tv.tv_sec - old->access.tv_sec) * 1000000UL + (tv.tv_usec - old->access.tv_usec); if (timediff > FRAG_TIMEOUT) { // remove captured fragments if (old->header != NULL) free(old->header); for (i = 0; i < 16; i++) if (old->fragment[i] != NULL) free(old->fragment[i]); cur->next = old->next; free(old); } cur = cur->next; } return (0); } int delFrag(unsigned char * smac, int sequence) { pFrag_t old, cur = rFragment; int i; if (rFragment == NULL) return (-1); if (smac == NULL) return (-1); if (sequence < 0) return (-1); while (cur->next != NULL) { old = cur->next; if (memcmp(smac, old->source, 6) == 0 && old->sequence == sequence) { // remove captured fragments if (old->header != NULL) free(old->header); for (i = 0; i < 16; i++) if (old->fragment[i] != NULL) free(old->fragment[i]); cur->next = old->next; free(old); return (0); } cur = cur->next; } return (0); } unsigned char * getCompleteFrag(unsigned char * smac, int sequence, size_t * packetlen, int crypt, unsigned char * wepkey, int weplen) { pFrag_t old, cur = rFragment; int i, len = 0; unsigned char * packet = NULL; unsigned char K[128]; if (rFragment == NULL) return (NULL); if (smac == NULL) return (NULL); while (cur->next != NULL) { old = cur->next; if (memcmp(smac, old->source, 6) == 0 && old->sequence == sequence) { // check if all frags available if (old->fragnum == 0) return (NULL); for (i = 0; i <= old->fragnum; i++) { if (old->fragment[i] == NULL) return (NULL); len += old->fragmentlen[i]; } if (len > 2000) return (NULL); if (old->wep) { if (crypt == CRYPT_WEP) { packet = (unsigned char *) malloc( (size_t) len + old->headerlen + 8); ALLEGE(packet != NULL); K[0] = rand_u8(); K[1] = rand_u8(); K[2] = rand_u8(); K[3] = (uint8_t)(0x00); memcpy(packet, old->header, (size_t) old->headerlen); len = old->headerlen; memcpy(packet + len, K, 4); //-V512 len += 4; for (i = 0; i <= old->fragnum; i++) { memcpy(packet + len, old->fragment[i], (size_t) old->fragmentlen[i]); len += old->fragmentlen[i]; } /* write crc32 value behind data */ if (add_crc32(packet + old->headerlen + 4, len - old->headerlen - 4) != 0) return (NULL); len += 4; // icv memcpy(K + 3, wepkey, (size_t) weplen); encrypt_wep(packet + old->headerlen + 4, len - old->headerlen - 4, K, weplen + 3); packet[1] = (uint8_t)(packet[1] | 0x40); // delete captured fragments delFrag(smac, sequence); *packetlen = (size_t) len; return (packet); } else return (NULL); } else { packet = (unsigned char *) malloc((size_t) len + old->headerlen); ALLEGE(packet != NULL); memcpy(packet, old->header, (size_t) old->headerlen); len = old->headerlen; for (i = 0; i <= old->fragnum; i++) { memcpy(packet + len, old->fragment[i], (size_t) old->fragmentlen[i]); len += old->fragmentlen[i]; } // delete captured fragments delFrag(smac, sequence); *packetlen = (size_t) len; return (packet); } } cur = cur->next; } return (packet); } aircrack-ng-1.6/lib/libac/support/mcs_index_rates.c000066400000000000000000000141131361312141100224010ustar00rootroot00000000000000/* * Functions and macros to obtain 802.11n or ac rates based on MCS index * * Copyright (C) 2018 Thomas d'Otreppe * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * is provided AS IS, WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and * NON-INFRINGEMENT. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, * MA 02110-1301, USA. * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include "aircrack-ng/support/mcs_index_rates.h" // http://mcsindex.com/ // 20/40/80/160MHz -> (0, 1, 2, 3) // 0: long GI, 1: short GI // amount of spatial streams (minus 1) // MCS index const float MCS_index_rates[4][2][8][10] = { // 20MHz {// Long GI {// Spatial streams {6.5, 13.0, 19.5, 26, 39, 52, 58.5, 65, 78, 0}, {13, 26, 39, 52, 78, 104, 117, 130, 156, 0}, {19.5, 39, 58.5, 78, 117, 156, 175.5, 195, 234, 260}, {26, 52, 78, 104, 156, 208, 134, 260, 312, 0}}, // Short GI {{7.2, 14.4, 21.7, 28.9, 43.3, 57.8, 65, 72.2, 86.7, 0}, {14.4, 28.9, 43.3, 57.8, 86.7, 115.6, 130.3, 144.4, 173.3, 0}, {21.7, 43.3, 65, 86.7, 130, 173.3, 195, 216.7, 260, 288.9}, {28.9, 57.8, 56.7, 115.6, 173.3, 231.1, 260, 288.9, 346.7, 0}}}, // 40MHz {// Long GI {{13.5, 27, 40.5, 54, 81, 108, 121.5, 135, 162, 180}, {27, 54, 81, 108, 162, 216, 243, 270, 324, 360}, {40.5, 81, 121.5, 162, 243, 324, 364.5, 405, 486, 540}, {54, 108, 162, 216, 324, 432, 486, 540, 648, 720}}, // Short GI {{15, 30, 45, 60, 90, 120, 135, 150, 180, 200}, {30, 60, 90, 120, 180, 240, 270, 300, 360, 400}, {45, 90, 135, 180, 270, 360, 405, 450, 540, 600}, {60, 120, 180, 240, 360, 480, 540, 600, 720, 800}}}, // 80MHz {// Long GI {{29.3, 58.5, 87.8, 117, 175.5, 234, 263.3, 292.5, 351, 390}, {58.5, 117, 175.5, 234, 351, 468, 526.5, 585, 702, 780}, {87.8, 175.5, 263.3, 351, 526.5, 702, 0, 877.5, 1053, 1170}, {117, 234, 351, 468, 702, 936, 1053, 1170, 1404, 1560}, {146.3, 292.5, 438.8, 585, 877.5, 1170, 1316.3, 1462.5, 1755, 1950}, {175.5, 351, 526.5, 702, 1053, 1404, 1579.5, 1755, 2106, 0}, {204.8, 409.5, 614.3, 819, 1228.5, 1638, 0, 2047.5, 2457, 2730}, {234, 468, 702, 936, 1404, 1872, 2106, 2340, 2808, 3120}}, // Short GI {{32.5, 65, 97.5, 130, 195, 260, 292.5, 325, 390, 433.3}, {65, 130, 195, 260, 390, 520, 585, 650, 780, 866.7}, {97.5, 195, 292.5, 390, 585, 780, 0, 975, 1170, 1300}, {130, 260, 390, 520, 780, 1040, 1170, 1300, 1560, 1733.3}, {162.5, 325, 487.5, 650, 975, 1300, 1462.5, 1625, 1950, 2166.7}, {195, 390, 585, 780, 1170, 1560, 1755, 1950, 2340, 0}, {227.5, 455, 682.5, 910, 1365, 1820, 0, 2275, 2730, 3033.3}, {260, 520, 780, 1040, 1560, 2080, 2340, 2600, 3120, 3466.7}}}, // 160MHz {// Long GI {{58.5, 117, 175.5, 234, 351, 468, 526.5, 585, 702, 780}, {117, 234, 351, 468, 702, 936, 1053, 1170, 1404, 1560}, {175.5, 351, 526.5, 702, 1053, 1404, 1579.5, 1755, 2106, 0}, {234, 468, 702, 936, 1404, 1872, 2106, 2340, 2808, 3120}, {292.5, 585, 877.5, 1170, 1755, 2340, 2632.5, 2925, 3510, 3900}, {351, 702, 1053, 1404, 2106, 2808, 3159, 3510, 4212, 4680}, {409.5, 819, 1228.5, 1638, 2457, 3276, 3685.5, 4095, 4914, 5460}, {468, 936, 1404, 1872, 2808, 3744, 4212, 4680, 5616, 6240}}, // Short GI {{65, 130, 195, 260, 390, 520, 585, 650, 780, 866.7}, {130, 260, 390, 520, 780, 1040, 1170, 1300, 1560, 1733.3}, {195, 390, 585, 780, 1170, 1560, 1755, 1950, 2340, 0}, {260, 520, 780, 1040, 1560, 2080, 2340, 2600, 3120, 3466.7}, {325, 650, 975, 1300, 1950, 2600, 2925, 3250, 3900, 4333.3}, {390, 780, 1170, 1560, 2340, 3120, 3510, 3900, 4680, 5200}, {455, 910, 1365, 1820, 2730, 3640, 4095, 4550, 5460, 6066.7}, {520, 1040, 1560, 2080, 3120, 4160, 4680, 5200, 6240, 6933.3}}}}; float get_80211n_rate(const int width, const int is_short_GI, const int mcs_index) { // Check MCS Index if (mcs_index < 0 || mcs_index > 31) { return -1.0; } uint8_t amount_ss = mcs_index / 8; uint8_t mcs_idx = mcs_index % 8; // Rate index uint8_t width_idx = 0; switch (width) { case 20: width_idx = 0; break; case 40: width_idx = 1; break; default: return -1.0; } // Short GI? uint8_t sgi = !!is_short_GI; return MCS_index_rates[width_idx][sgi][amount_ss][mcs_idx]; } float get_80211ac_rate(const int width, const int is_short_GI, const int mcs_idx, const int amount_ss) { // Check MCS Index if (mcs_idx < 0 || mcs_idx > 9) { return -1.0; } // Rate index uint8_t width_idx = 0; switch (width) { case 20: width_idx = 0; break; case 40: width_idx = 1; break; case 80: width_idx = 2; break; case 160: width_idx = 3; break; default: return -1.0; } // Check amount of spatial streams if (amount_ss < 1 || amount_ss > 8) { return -1.0; } // Short GI? uint8_t sgi = !!is_short_GI; return MCS_index_rates[width_idx][sgi][amount_ss - 1][mcs_idx]; } aircrack-ng-1.6/lib/libac/tui/000077500000000000000000000000001361312141100161535ustar00rootroot00000000000000aircrack-ng-1.6/lib/libac/tui/console.c000066400000000000000000000115561361312141100177710ustar00rootroot00000000000000/* * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * is provided AS IS, WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and * NON-INFRINGEMENT. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, * MA 02110-1301, USA. * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #if !defined(TIOCGWINSZ) && !defined(linux) #include #endif #include #include #include "aircrack-ng/tui/console.h" #define channel stdout void textcolor(int attr, int fg, int bg) { char command[64]; /* Command is the control command to the terminal */ snprintf( command, sizeof(command), "%c[%d;%d;%dm", 0x1B, attr, fg + 30, bg + 40); fprintf(channel, "%s", command); fflush(channel); } void textcolor_fg(int fg) { char command[64]; /* Command is the control command to the terminal */ snprintf(command, sizeof(command), "\033[%dm", fg + 30); fprintf(channel, "%s", command); fflush(channel); } void textcolor_bg(int bg) { char command[64]; /* Command is the control command to the terminal */ snprintf(command, sizeof(command), "\033[%dm", bg + 40); fprintf(channel, "%s", command); fflush(channel); } void textstyle(int attr) { char command[13]; /* Command is the control command to the terminal */ snprintf(command, sizeof(command), "\033[%im", attr); fprintf(channel, "%s", command); fflush(channel); } void reset_term() { struct termios oldt, newt; tcgetattr(STDIN_FILENO, &oldt); newt = oldt; newt.c_lflag |= (ICANON | ECHO); tcsetattr(STDIN_FILENO, TCSANOW, &newt); } void moveto(int x, int y) { char command[64]; // clamp the X coordinate. if (x < 0) { x = 0; } // clamp the Y coordinate. if (y < 0) { y = 0; } // send ANSI sequence to move the cursor. snprintf(command, sizeof(command), "%c[%d;%dH", 0x1B, y, x); fprintf(channel, "%s", command); fflush(channel); } void move(int which, int n) { char command[13]; static const char movement[] = {'A', 'B', 'C', 'D'}; assert(which >= 0 && which < 4); snprintf(command, sizeof(command), "%c[%d%c", 0x1B, n, movement[which]); fprintf(channel, "%s", command); fflush(channel); } void erase_display(int n) { char command[13]; snprintf(command, sizeof(command), "%c[%dJ", 0x1B, n); fprintf(channel, "%s", command); fflush(channel); } void erase_line(int n) { char command[13]; snprintf(command, sizeof(command), "%c[%dK", 0x1B, n); fprintf(channel, "%s", command); fflush(channel); } void textcolor_normal(void) { char command[13]; snprintf(command, sizeof(command), "%c[22m", 0x1B); fprintf(channel, "%s", command); fflush(channel); } void hide_cursor(void) { char command[13]; snprintf(command, sizeof(command), "%c[?25l", 0x1B); fprintf(channel, "%s", command); fflush(channel); } void show_cursor(void) { char command[13]; snprintf(command, sizeof(command), "%c[?25h", 0x1B); fprintf(channel, "%s", command); fflush(channel); } int mygetch(void) { struct termios oldt, newt; int ch = EOF; tcgetattr(STDIN_FILENO, &oldt); newt = oldt; newt.c_lflag &= ~(ICANON | ECHO); newt.c_cc[VMIN] = 0; /* require no keypress */ newt.c_cc[VTIME] = 2; /* 20 ms delay */ tcsetattr(STDIN_FILENO, TCSANOW, &newt); char c; if (read(STDIN_FILENO, &c, sizeof(char)) > 0) ch = (int) c; tcsetattr(STDIN_FILENO, TCSANOW, &oldt); return ch; } void console_utf8_enable(void) { setlocale(LC_CTYPE, ""); char * codepage = nl_langinfo(CODESET); if (codepage != NULL && strcmp(codepage, "UTF-8") != 0) { fprintf(stderr, "Warning: Detected you are using a non-UNICODE " "terminal character encoding.\n"); sleep(1); } }aircrack-ng-1.6/lib/libac/utf8/000077500000000000000000000000001361312141100162405ustar00rootroot00000000000000aircrack-ng-1.6/lib/libac/utf8/verifyssid.c000066400000000000000000000045401361312141100205760ustar00rootroot00000000000000/* * VerifySSID function (UTF-8 supported) * * Copyright (C) 2018 ZhaoChunsheng * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. * If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. * If you * do not wish to do so, delete this exception statement from your * version. * If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include "aircrack-ng/utf8/verifyssid.h" int verifyssid(const unsigned char * s) { int i; unsigned char c; if (!s || strlen((const char *) s) > 32) { // 32 characters return 0; } for (i = 0; (c = s[i++]);) { if ((c & 0x80) == 0) { // ascii flag if (c < 0x20 || c == 0x7f) { return 0; } } else if ((c & 0xe0) == 0xc0) { // utf8 flag if ((s[i++] & 0xc0) != 0x80) { return 0; } } else if ((c & 0xf0) == 0xe0) { // utf8 flag if ((s[i++] & 0xc0) != 0x80 || (s[i++] & 0xc0) != 0x80) { return 0; } } else if ((c & 0xf8) == 0xf0) { // utf8 flag if ((s[i++] & 0xc0) != 0x80 || (s[i++] & 0xc0) != 0x80 || (s[i++] & 0xc0) != 0x80) { return 0; } } else { return 0; } } return 1; } aircrack-ng-1.6/lib/osdep/000077500000000000000000000000001361312141100154125ustar00rootroot00000000000000aircrack-ng-1.6/lib/osdep/Makefile.inc000066400000000000000000000075221361312141100176300ustar00rootroot00000000000000# Aircrack-ng # # Copyright (C) 2018 Joseph Benden # # Autotool support was written by: Joseph Benden # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA # # In addition, as a special exception, the copyright holders give # permission to link the code of portions of this program with the # OpenSSL library under certain conditions as described in each # individual source file, and distribute linked combinations # including the two. # # You must obey the GNU General Public License in all respects # for all of the code used other than OpenSSL. # # If you modify file(s) with this exception, you may extend this # exception to your dnl version of the file(s), but you are not obligated # to do so. # # If you dnl do not wish to do so, delete this exception statement from your # version. # # If you delete this exception statement from all source files in the # program, then also delete it here. SRCS_COMMON = %D%/network.c %D%/file.c SRCS = %D%/osdep.c $(SRCS_COMMON) SRCS_APCAP = %D%/airpcap.c SRCS_OBSD = $(SRCS) %D%/openbsd.c %D%/openbsd_tap.c %D%/common.c SRCS_NBSD = $(SRCS) %D%/netbsd.c %D%/netbsd_tap.c %D%/common.c SRCS_FBSD = $(SRCS) %D%/freebsd.c %D%/freebsd_tap.c %D%/common.c SRCS_LINUX = $(SRCS) %D%/linux.c %D%/linux_tap.c %D%/common.c SRCS_DUMMY = $(SRCS) %D%/dummy.c %D%/dummy_tap.c %D%/common.c SRCS_CYGWIN = $(SRCS) %D%/cygwin.c %D%/cygwin_tap.c %D%/common.c SRCS_DARWIN = $(SRCS) %D%/darwin.c %D%/darwin_tap.c %D%/common.c if AIRPCAP SRCS_CYGWIN += $(SRCS_APCAP) endif if CYGWIN if AIRPCAP libaircrack_osdep_la_SOURCES = $(SRCS_CYGWIN) libaircrack_osdep_la_CFLAGS = $(AIRPCAP_CFLAGS) libaircrack_osdep_la_LIBADD = $(AIRPCAP_LIBS) $(LIBRADIOTAP_LIBS) -lsetupapi -liphlpapi else libaircrack_osdep_la_SOURCES = $(SRCS_CYGWIN) endif endif if DARWIN libaircrack_osdep_la_SOURCES = $(SRCS_DARWIN) endif if DUMMY libaircrack_osdep_la_SOURCES = $(SRCS_DUMMY) endif if FREEBSD libaircrack_osdep_la_SOURCES = $(SRCS_FBSD) endif if LINUX libaircrack_osdep_la_SOURCES = $(SRCS_LINUX) libaircrack_osdep_la_CFLAGS = $(LIBNL_CFLAGS) libaircrack_osdep_la_LIBADD = $(LIBNL_LIBS) $(LIBRADIOTAP_LIBS) endif if NETBSD libaircrack_osdep_la_SOURCES = $(SRCS_NBSD) endif if OPENBSD libaircrack_osdep_la_SOURCES = $(SRCS_OBSD) endif if !AIRPCAP libaircrack_osdep_la_LIBADD = $(LIBRADIOTAP_LIBS) if CYGWIN libaircrack_osdep_la_LIBADD += -lsetupapi -liphlpapi endif endif lib_LTLIBRARIES += libaircrack-osdep.la libaircrack_osdep_la_LDFLAGS = -release $(LT_VER) -no-undefined libaircrack_osdep_la_CPPFLAGS = -I$(top_srcdir)/include/aircrack-ng/osdep $(AM_CPPFLAGS) EXTRA_DIST += %D%/openbsd.c \ %D%/darwin.c \ %D%/common.c \ %D%/darwin_tap.c \ %D%/cygwin.c \ %D%/linux.c \ %D%/file.c \ %D%/linux_tap.c \ %D%/airpcap.c \ %D%/netbsd.c \ %D%/freebsd_tap.c \ %D%/freebsd.c \ %D%/osdep.c \ %D%/dummy_tap.c \ %D%/openbsd_tap.c \ %D%/dummy.c \ %D%/netbsd_tap.c \ %D%/network.c \ %D%/cygwin_tap.c aircrack-ng-1.6/lib/osdep/aircrack_ng_airpcap.h000066400000000000000000000006441361312141100215310ustar00rootroot00000000000000// Function to be used by cygwin void airpcap_close(void); int airpcap_get_mac(void * mac); int airpcap_set_mac(void * mac); int airpcap_sniff(void * buf, int len, struct rx_info * ri); int airpcap_inject(void * buf, int len, struct tx_info * ti); int airpcap_init(char * param); int airpcap_set_chan(int chan); int isAirpcapDevice(const char * iface); // int printErrorCloseAndReturn(const char * err, int retValue); aircrack-ng-1.6/lib/osdep/airpcap.c000066400000000000000000000226661361312141100172110ustar00rootroot00000000000000/* * Copyright (c) 2007-2018 Thomas d'Otreppe * * Airpcap stuff * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #ifdef HAVE_AIRPCAP #include #include #include #include #include #include #include "osdep.h" //------------------ PPI --------------------- #define PPH_PH_VERSION ((u_int8_t) 0x00) #define PPI_FIELD_TYPE_802_11_COMMON ((u_int16_t) 0x02) typedef struct _PPI_PACKET_HEADER { u_int8_t PphVersion; u_int8_t PphFlags; u_int16_t PphLength; u_int32_t PphDlt; } PPI_PACKET_HEADER, *PPPI_PACKET_HEADER; typedef struct _PPI_FIELD_HEADER { u_int16_t PfhType; u_int16_t PfhLength; } PPI_FIELD_HEADER, *PPPI_FIELD_HEADER; typedef struct _PPI_FIELD_802_11_COMMON { u_int64_t TsfTimer; u_int16_t Flags; u_int16_t Rate; u_int16_t ChannelFrequency; u_int16_t ChannelFlags; u_int8_t FhssHopset; u_int8_t FhssPattern; int8_t DbmAntSignal; int8_t DbmAntNoise; } PPI_FIELD_802_11_COMMON, *PPPI_FIELD_802_11_COMMON; #define DEVICE_PREFIX "\\\\.\\" #define DEVICE_COMMON_PART "airpcap" PAirpcapHandle airpcap_handle; /** * Check if the device is an Airpcap device * @param iface Interface name * @return 1 if it is an Airpcap device, 0 if not */ int isAirpcapDevice(const char * iface) { char * pos; int len; pos = strstr(iface, DEVICE_COMMON_PART); // Check if it contains "airpcap" if (!pos) return 0; if (pos != iface) { // Check if it begins with '\\.\' if (strstr(iface, AIRPCAP_DEVICE_NAME_PREFIX) != iface) return 0; } len = strlen(iface); // Checking that it contains 2 figures at the end. // No need to check for length, it was already done by the first check if (!(isdigit((int) iface[len - 1])) || !(isdigit((int) iface[len - 2]))) return 0; return 1; } /** * Parse information from a PPI packet (will be used later). * @param p packet * @param caplen Length of the packet * @param hdrlen Length of the header * @param power pointer that will contains the power of the packet * @return 0 if successful decoding, 1 if it failed to decode */ int ppi_decode(const u_char * p, int caplen, int * hdrlen, int * power) { PPPI_PACKET_HEADER pPpiPacketHeader; PPPI_FIELD_HEADER pFieldHeader; ULONG position = 0; // Sanity checks if (caplen < (int) sizeof(*pPpiPacketHeader)) { // Packet smaller than the PPI fixed header return (1); } pPpiPacketHeader = (PPPI_PACKET_HEADER) p; *hdrlen = pPpiPacketHeader->PphLength; if (caplen < *hdrlen) { // Packet smaller than the PPI fixed header return (1); } position = sizeof(*pPpiPacketHeader); if (pPpiPacketHeader->PphVersion != PPH_PH_VERSION) { fprintf(stderr, "Unknown PPI packet header version (%u)\n", pPpiPacketHeader->PphVersion); return (1); } do { // now we suppose to have an 802.11-Common header if (*hdrlen < (int) (sizeof(*pFieldHeader) + position)) { break; } pFieldHeader = (PPPI_FIELD_HEADER)(p + position); position += sizeof(*pFieldHeader); switch (pFieldHeader->PfhType) { case PPI_FIELD_TYPE_802_11_COMMON: if (pFieldHeader->PfhLength != sizeof(PPI_FIELD_802_11_COMMON) || caplen - position < sizeof(PPI_FIELD_802_11_COMMON)) { // the header is bogus, just skip it fprintf(stderr, "Bogus 802.11-Common Field. Skipping it.\n"); } else { PPPI_FIELD_802_11_COMMON pField = (PPPI_FIELD_802_11_COMMON)(p + position); if (pField->DbmAntSignal != -128) { *power = (int) pField->DbmAntSignal; } else { *power = 0; } } break; default: // we do not know this field. Just print type and length and // skip break; } position += pFieldHeader->PfhLength; } while (TRUE); return (0); } /** * Set MAC Address of the device * @param mac MAC Address * @return 0 (successful) */ int airpcap_set_mac(void * mac) { if (mac) { } return 0; } /** * Close device */ void airpcap_close(void) { // By default, when plugged in, the adapter is set in monitor mode; // Application may assume it's already in monitor mode and forget to set it // So, do not remove monitor mode. if (airpcap_handle != NULL) { AirpcapClose(airpcap_handle); airpcap_handle = NULL; } } /** * Get MAC Address of the device (not yet implemented) * @param mac It will contain the mac address * @return 0 (successful) */ int airpcap_get_mac(void * mac) { // Don't use the function from Airpcap if (mac) { } return 0; } /** * Capture one packet * @param buf Buffer for the packet * @param len Length of the buffer * @param ri Receive information * @return -1 if failure or the number of bytes received */ int airpcap_sniff(void * buf, int len, struct rx_info * ri) { // Use PPI headers to obtain the different information for ri // Use AirpcapConvertFrequencyToChannel() to get channel // Add an option to give frequency instead of channel UINT BytesReceived = 0; if (ri) { } // Wait for the next packet // Maybe add an event packets to read // WaitForSingleObject(ReadEvent, INFINITE); // Read a packet if (AirpcapRead(airpcap_handle, buf, len, &BytesReceived)) return (int) BytesReceived; return -1; } /** * Inject one packet * @param buf Buffer for the packet * @param len Length of the buffer * @param ti Transmit information * @return -1 if failure or the number of bytes sent */ int airpcap_inject(void * buf, int len, struct tx_info * ti) { if (ti) { } if (AirpcapWrite(airpcap_handle, buf, len) != 1) return -1; return len; } /** * Print the error message * @param err Contains the error message and a %s in order to show the Airpcap * error * @param retValue Value returned by the function * @return retValue */ int printErrorCloseAndReturn(const char * err, int retValue) { if (err && airpcap_handle) { if (strlen(err)) { if (airpcap_handle) fprintf(stderr, err, AirpcapGetLastError(airpcap_handle)); else fprintf(stderr, "%s", err); } } airpcap_close(); return retValue; } /** * Initialize the device * @param param Parameters for the initialization * @return 0 if successful, -1 in case of failure */ int airpcap_init(char * param) { // Later: if several interfaces are given, aggregate them. char * iface; char errbuf[AIRPCAP_ERRBUF_SIZE]; iface = (char *) calloc(1, strlen(param) + 100); if (param) { // if it's empty, use the default adapter if (strlen(param) > 0) { if (strstr(param, DEVICE_PREFIX) == NULL) { // Not found, add it strcpy(iface, DEVICE_PREFIX); strcat(iface, param); } else { // Already contains the adapter header strcpy(iface, param); } } } airpcap_handle = AirpcapOpen(iface, errbuf); if (airpcap_handle == NULL) { fprintf(stderr, "This adapter doesn't have wireless extensions. Quitting\n"); // pcap_close( winpcap_adapter ); return (-1); } /* Tell the adapter that the packets we'll send and receive don't include * the FCS */ if (!AirpcapSetFcsPresence(airpcap_handle, FALSE)) return printErrorCloseAndReturn("Error setting FCS presence: %s\n", -1); /* Set the link layer to bare 802.11 */ if (!AirpcapSetLinkType(airpcap_handle, AIRPCAP_LT_802_11)) return printErrorCloseAndReturn("Error setting the link type: %s\n", -1); /* Accept correct frames only */ if (!AirpcapSetFcsValidation(airpcap_handle, AIRPCAP_VT_ACCEPT_CORRECT_FRAMES)) return printErrorCloseAndReturn("Error setting FCS validation: %s\n", -1); /* Set a low mintocopy for better responsiveness */ if (!AirpcapSetMinToCopy(airpcap_handle, 1)) return printErrorCloseAndReturn("Error setting MinToCopy: %s\n", -1); return 0; } /** * Set device channel * @param chan Channel * @return 0 if successful, -1 if it failed */ int airpcap_set_chan(int chan) { // Make sure a valid channel is given if (chan <= 0) return -1; if (!AirpcapSetDeviceChannel(airpcap_handle, chan)) { printf("Error setting the channel to %d: %s\n", chan, AirpcapGetLastError(airpcap_handle)); return -1; } return 0; } #endif aircrack-ng-1.6/lib/osdep/common.c000066400000000000000000000060551361312141100170540ustar00rootroot00000000000000/* * Copyright (c) 2008-2018, Thomas d'Otreppe * * Common OSdep stuff * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include "common.h" /** * Return the frequency in Mhz from a channel number */ EXPORT int getFrequencyFromChannel(int channel) { static int frequencies[] = { -1, // No channel 0 2412, 2417, 2422, 2427, 2432, 2437, 2442, 2447, 2452, 2457, 2462, 2467, 2472, 2484, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // Nothing from channel 15 to 34 (exclusive) 5170, 5175, 5180, 5185, 5190, 5195, 5200, 5205, 5210, 5215, 5220, 5225, 5230, 5235, 5240, 5245, 5250, 5255, 5260, 5265, 5270, 5275, 5280, 5285, 5290, 5295, 5300, 5305, 5310, 5315, 5320, 5325, 5330, 5335, 5340, 5345, 5350, 5355, 5360, 5365, 5370, 5375, 5380, 5385, 5390, 5395, 5400, 5405, 5410, 5415, 5420, 5425, 5430, 5435, 5440, 5445, 5450, 5455, 5460, 5465, 5470, 5475, 5480, 5485, 5490, 5495, 5500, 5505, 5510, 5515, 5520, 5525, 5530, 5535, 5540, 5545, 5550, 5555, 5560, 5565, 5570, 5575, 5580, 5585, 5590, 5595, 5600, 5605, 5610, 5615, 5620, 5625, 5630, 5635, 5640, 5645, 5650, 5655, 5660, 5665, 5670, 5675, 5680, 5685, 5690, 5695, 5700, 5705, 5710, 5715, 5720, 5725, 5730, 5735, 5740, 5745, 5750, 5755, 5760, 5765, 5770, 5775, 5780, 5785, 5790, 5795, 5800, 5805, 5810, 5815, 5820, 5825, 5830, 5835, 5840, 5845, 5850, 5855, 5860, 5865, 5870, 5875, 5880, 5885, 5890, 5895, 5900, 5905, 5910, 5915, 5920, 5925, 5930, 5935, 5940, 5945, 5950, 5955, 5960, 5965, 5970, 5975, 5980, 5985, 5990, 5995, 6000, 6005, 6010, 6015, 6020, 6025, 6030, 6035, 6040, 6045, 6050, 6055, 6060, 6065, 6070, 6075, 6080, 6085, 6090, 6095, 6100}; return (channel > 0 && channel <= HIGHEST_CHANNEL) ? frequencies[channel] : (channel >= LOWEST_CHANNEL && channel <= -4) ? 5000 - (channel * 5) : -1; } /** * Return the channel from the frequency (in Mhz) */ EXPORT int getChannelFromFrequency(int frequency) { if (frequency >= 2412 && frequency <= 2472) return (frequency - 2407) / 5; else if (frequency == 2484) return 14; else if (frequency >= 4920 && frequency <= 6100) return (frequency - 5000) / 5; else return -1; } aircrack-ng-1.6/lib/osdep/crctable_osdep.h000066400000000000000000000064541361312141100205450ustar00rootroot00000000000000#ifndef _CRCTABLE_OSDEP_H #define _CRCTABLE_OSDEP_H const unsigned long int crc_tbl_osdep[256] = {0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5, 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F, 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433, 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01, 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD, 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7, 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79, 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45, 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D}; #endif /* crctable_osdep.h */ aircrack-ng-1.6/lib/osdep/cygwin.c000066400000000000000000000272711361312141100170670ustar00rootroot00000000000000/* * Copyright (c) 2007, 2008, Andrea Bittau * * OS dependent API for cygwin. It relies on an external * DLL to do the actual wifi stuff * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include #include #include #include "osdep.h" #include "network.h" #include "cygwin.h" #ifdef HAVE_AIRPCAP #include "aircrack_ng_airpcap.h" #endif #define xstr(s) str(s) #define str(s) #s #define DLL_EXTENSION ".dll" struct priv_cygwin { pthread_t pc_reader; volatile int pc_running; int pc_pipe[2]; /* reader -> parent */ int pc_channel; int pc_frequency; struct wif * pc_wi; int pc_did_init; int isAirpcap; int useDll; int (*pc_init)(char * param); int (*pc_set_chan)(int chan); int (*pc_set_freq)(int freq); int (*pc_inject)(void * buf, int len, struct tx_info * ti); int (*pc_sniff)(void * buf, int len, struct rx_info * ri); int (*pc_get_mac)(void * mac); int (*pc_set_mac)(void * mac); void (*pc_close)(void); }; /** * strstr() function case insensitive * @param String C string to be scanned * @param Pattern C string containing the sequence of characters to match * @return Pointer to the first occurrence of Pattern in String, or a null * pointer if there Pattern is not part of String. */ char * stristr(const char * String, const char * Pattern) { char *pptr, *sptr, *start; unsigned slen, plen; for (start = (char *) String, pptr = (char *) Pattern, slen = strlen(String), plen = strlen(Pattern); /* while string length not shorter than pattern length */ slen >= plen; start++, slen--) { /* find start of pattern in string */ while (toupper((int) *start) != toupper((int) *Pattern)) { start++; slen--; /* if pattern longer than string */ if (slen < plen) return (NULL); } sptr = start; pptr = (char *) Pattern; while (toupper((int) *sptr) == toupper((int) *pptr)) { sptr++; pptr++; /* if end of pattern then pattern was found */ if ('\0' == *pptr) return (start); } } return (NULL); } /** * Get the different functions for to interact with the device: * - setting monitor mode * - changing channel * - capturing data * - injecting packets * @param iface The interface name */ static int do_cygwin_open(struct wif * wi, char * iface) { struct priv_cygwin * priv = wi_priv(wi); void * lib; char * file; char * parm; int rc = -1; if (!iface) return -1; if (strlen(iface) == 0) return -1; priv->useDll = 0; if (stristr(iface, DLL_EXTENSION)) priv->useDll = 1; if (priv->useDll) { file = strdup(iface); if (!file) return -1; parm = strchr(file, '|'); if (parm) *parm++ = 0; /* load lib */ lib = dlopen(file, RTLD_LAZY); if (!lib) goto errdll; priv->pc_init = dlsym(lib, xstr(CYGWIN_DLL_INIT)); priv->pc_set_chan = dlsym(lib, xstr(CYGWIN_DLL_SET_CHAN)); priv->pc_set_freq = dlsym(lib, xstr(CYGWIN_DLL_SET_FREQ)); priv->pc_get_mac = dlsym(lib, xstr(CYGWIN_DLL_GET_MAC)); priv->pc_set_mac = dlsym(lib, xstr(CYGWIN_DLL_SET_MAC)); priv->pc_close = dlsym(lib, xstr(CYGWIN_DLL_CLOSE)); priv->pc_inject = dlsym(lib, xstr(CYGWIN_DLL_INJECT)); priv->pc_sniff = dlsym(lib, xstr(CYGWIN_DLL_SNIFF)); if (!(priv->pc_init && priv->pc_set_chan && priv->pc_get_mac && priv->pc_inject && priv->pc_sniff && priv->pc_close)) goto errdll; /* init lib */ if ((rc = priv->pc_init(parm))) goto errdll; priv->pc_did_init = 1; rc = 0; errdll: free(file); } else { #ifdef HAVE_AIRPCAP // Check if it's an Airpcap device priv->isAirpcap = isAirpcapDevice(iface); if (priv->isAirpcap) { // Get functions priv->pc_init = airpcap_init; priv->pc_set_chan = airpcap_set_chan; priv->pc_get_mac = airpcap_get_mac; priv->pc_set_mac = airpcap_set_mac; priv->pc_close = airpcap_close; priv->pc_inject = airpcap_inject; priv->pc_sniff = airpcap_sniff; rc = 0; } #endif } if (rc == 0) { // Don't forget to initialize if (!priv->useDll) { rc = priv->pc_init(iface); if (rc == 0) priv->pc_did_init = 1; else fprintf(stderr, "Error initializing <%s>\n", iface); } } else { // Show an error message if the adapter is not supported fprintf(stderr, "Adapter <%s> not supported\n", iface); } return rc; } /** * Change channel * @param chan Channel * @return 0 if successful, -1 if it failed */ static int cygwin_set_channel(struct wif * wi, int chan) { struct priv_cygwin * priv = wi_priv(wi); if (priv->pc_set_chan(chan) == -1) return -1; priv->pc_channel = chan; return 0; } /** * Change frequency * @param freq Frequency * @return 0 if successful, -1 if it failed */ static int cygwin_set_freq(struct wif * wi, int freq) { struct priv_cygwin * priv = wi_priv(wi); if (!priv->pc_set_freq || priv->pc_set_freq(freq) == -1) return -1; priv->pc_frequency = freq; return 0; } /** * Capture a packet * @param buf Buffer for the packet (has to be already allocated) * @param len Length of the buffer * @param ri Receive information structure * @return -1 in case of failure or the number of bytes received */ static int cygwin_read_packet(struct priv_cygwin * priv, void * buf, int len, struct rx_info * ri) { int rd; memset(ri, 0, sizeof(*ri)); rd = priv->pc_sniff(buf, len, ri); if (rd == -1) return -1; if (!ri->ri_channel) ri->ri_channel = wi_get_channel(priv->pc_wi); return rd; } /** * Send a packet * @param h80211 The packet itself * @param len Length of the packet * @param ti Transmit information * @return -1 if failure or the number of bytes sent */ static int cygwin_write(struct wif * wi, struct timespec * ts, int dlt, unsigned char * h80211, int len, struct tx_info * ti) { struct priv_cygwin * priv = wi_priv(wi); int rc; (void) ts; (void) dlt; if ((rc = priv->pc_inject(h80211, len, ti)) == -1) return -1; return rc; } /** * Get device channel * @return channel */ static int cygwin_get_channel(struct wif * wi) { struct priv_cygwin * pc = wi_priv(wi); return pc->pc_channel; } static int cygwin_get_freq(struct wif * wi) { struct priv_cygwin * pc = wi_priv(wi); return pc->pc_frequency; } int cygwin_read_reader(int fd, int plen, void * dst, int len) { /* packet */ if (len > plen) len = plen; if (net_read_exact(fd, dst, len) == -1) return -1; plen -= len; /* consume packet */ while (plen) { char lame[1024]; int rd = sizeof(lame); if (rd > plen) rd = plen; if (net_read_exact(fd, lame, rd) == -1) return -1; plen -= rd; assert(plen >= 0); } return len; } static int cygwin_read(struct wif * wi, struct timespec * ts, int * dlt, unsigned char * h80211, int len, struct rx_info * ri) { struct priv_cygwin * pc = wi_priv(wi); struct rx_info tmp; int plen; (void) ts; (void) dlt; if (pc->pc_running == -1) return -1; if (!ri) ri = &tmp; /* length */ if (net_read_exact(pc->pc_pipe[0], &plen, sizeof(plen)) == -1) return -1; /* ri */ if (net_read_exact(pc->pc_pipe[0], ri, sizeof(*ri)) == -1) return -1; plen -= sizeof(*ri); assert(plen > 0); return cygwin_read_reader(pc->pc_pipe[0], plen, h80211, len); } /** * Free allocated data */ static void do_free(struct wif * wi) { struct priv_cygwin * pc = wi_priv(wi); int tries = 3; /* wait for reader */ if (pc->pc_running == 1) { pc->pc_running = 0; while ((pc->pc_running != -1) && tries--) sleep(1); } if (pc->pc_pipe[0]) { close(pc->pc_pipe[0]); close(pc->pc_pipe[1]); } if (pc->pc_did_init) pc->pc_close(); assert(wi->wi_priv); free(wi->wi_priv); wi->wi_priv = 0; free(wi); } /** * Close the device and free data */ static void cygwin_close(struct wif * wi) { do_free(wi); } /** * Get the file descriptor for the device */ static int cygwin_fd(struct wif * wi) { struct priv_cygwin * pc = wi_priv(wi); if (pc->pc_running == -1) return -1; return pc->pc_pipe[0]; } /** * Get MAC Address of the device * @param mac It will contain the mac address * @return 0 if successful */ static int cygwin_get_mac(struct wif * wi, unsigned char * mac) { struct priv_cygwin * pc = wi_priv(wi); return pc->pc_get_mac(mac); } /** * Set MAC Address of the device * @param mac MAC Address * @return 0 if successful */ static int cygwin_set_mac(struct wif * wi, unsigned char * mac) { struct priv_cygwin * pc = wi_priv(wi); return pc->pc_set_mac(mac); } static int cygwin_get_monitor(struct wif * wi) { if (wi) { } /* XXX unused */ return 0; } static int cygwin_get_rate(struct wif * wi) { if (wi) { } /* XXX unused */ return 1000000; } /** * Set (injection) rate of the device * @param rate Rate to be used * @return 0 (successful) */ static int cygwin_set_rate(struct wif * wi, int rate) { if (wi || rate) { } /* XXX unused */ return 0; } static void * cygwin_reader(void * arg) { struct priv_cygwin * priv = arg; unsigned char buf[2048]; int len; struct rx_info ri; while (priv->pc_running) { /* read one packet */ /* a potential problem: the cygwin_read_packet will never return * if there no packet sniffered, so the thread cannot be closed * correctly. */ len = cygwin_read_packet(priv, buf, sizeof(buf), &ri); if (len == -1) break; /* len */ len += sizeof(ri); if (write(priv->pc_pipe[1], &len, sizeof(len)) != sizeof(len)) break; len -= sizeof(ri); /* ri */ if (write(priv->pc_pipe[1], &ri, sizeof(ri)) != sizeof(ri)) break; /* packet */ if (write(priv->pc_pipe[1], buf, len) != len) break; } priv->pc_running = -1; return NULL; } static struct wif * cygwin_open(char * iface) { struct wif * wi; struct priv_cygwin * priv; /* setup wi struct */ wi = wi_alloc(sizeof(*priv)); if (!wi) return NULL; wi->wi_read = cygwin_read; wi->wi_write = cygwin_write; wi->wi_set_channel = cygwin_set_channel; wi->wi_get_channel = cygwin_get_channel; wi->wi_set_freq = cygwin_set_freq; wi->wi_get_freq = cygwin_get_freq; wi->wi_close = cygwin_close; wi->wi_fd = cygwin_fd; wi->wi_get_mac = cygwin_get_mac; wi->wi_set_mac = cygwin_set_mac; wi->wi_get_rate = cygwin_get_rate; wi->wi_set_rate = cygwin_set_rate; wi->wi_get_monitor = cygwin_get_monitor; /* setup iface */ if (do_cygwin_open(wi, iface) == -1) goto err; /* setup private state */ priv = wi_priv(wi); priv->pc_wi = wi; /* setup reader */ if (pipe(priv->pc_pipe) == -1) goto err; priv->pc_running = 2; if (pthread_create(&priv->pc_reader, NULL, cygwin_reader, priv)) goto err; priv->pc_running = 1; return wi; err: do_free(wi); return NULL; } struct wif * wi_open_osdep(char * iface) { return cygwin_open(iface); } /** * Return remaining battery time in seconds. * @return Battery time in seconds or 0 if no battery (or connected to power) */ EXPORT int get_battery_state(void) { SYSTEM_POWER_STATUS powerStatus; int batteryTime = 0; if (GetSystemPowerStatus(&powerStatus) == TRUE) { if (powerStatus.ACLineStatus == 0) batteryTime = (int) powerStatus.BatteryLifeTime; } return batteryTime; } aircrack-ng-1.6/lib/osdep/cygwin.h000066400000000000000000000036411361312141100170670ustar00rootroot00000000000000/* * Copyright (c) 2007, 2008, Andrea Bittau * * OS dependent API for cygwin. It relies on an external * DLL to do the actual wifi stuff * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ // DLL function that have to be exported #define CYGWIN_DLL_INIT cygwin_init #define CYGWIN_DLL_SET_CHAN cygwin_set_chan #define CYGWIN_DLL_SET_FREQ cygwin_set_freq #define CYGWIN_DLL_INJECT cygwin_inject #define CYGWIN_DLL_SNIFF cygwin_sniff #define CYGWIN_DLL_GET_MAC cygwin_get_mac #define CYGWIN_DLL_SET_MAC cygwin_set_mac #define CYGWIN_DLL_CLOSE cygwin_close /* * Prototypes: * int CYGWIN_DLL_INIT (char *param); * int CYGWIN_DLL_SET_CHAN (int chan); * int CYGWIN_DLL_INJECT (void *buf, int len, struct tx_info *ti); * int CYGWIN_DLL_SNIFF (void *buf, int len, struct rx_info *ri); * int CYGWIN_DLL_GET_MAC (unsigned char *mac); * int CYGWIN_DLL_SET_MAC (unsigned char *mac); * void CYGWIN_DLL_CLOSE (void); * * Notes: * - sniff can block and inject can be called by another thread. * - return -1 for error. * */ /* XXX the interface is broken. init() should return a void* that is passed to * each call. This way multiple instances can be open by a single process. * -sorbo * */ aircrack-ng-1.6/lib/osdep/cygwin_tap.c000066400000000000000000000313741361312141100177320ustar00rootroot00000000000000/* * Copyright (c) 2007, 2008, Andrea Bittau * * OS dependent API for cygwin. TAP routines * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include "osdep.h" #include #include #include #include #include #include #include #include "network.h" #include "tap-win32/common.h" extern DWORD WINAPI GetAdaptersInfo(PIP_ADAPTER_INFO pAdapterInfo, PULONG pOutBufLen); extern DWORD WINAPI AddIPAddress(IPAddr Address, IPMask IpMask, DWORD IfIndex, PULONG NTEContext, PULONG NTEInstance); extern DWORD WINAPI DeleteIPAddress(ULONG NTEContext); extern int cygwin_read_reader(int fd, int plen, void * dst, int len); static void * ti_reader(void * arg); struct tip_cygwin { char tc_name[MAX_IFACE_NAME]; HANDLE tc_h; pthread_t tc_reader; volatile int tc_running; int tc_pipe[2]; /* reader -> parent */ pthread_mutex_t tc_mtx; HKEY tc_key; char tc_guid[256]; }; /** * Stop the reader thread (if it is running) * @return 0 if stopped or -1 if it failed to stop it */ static int stop_reader(struct tip_cygwin * priv) { if (priv->tc_running == 1) { int tries = 3; priv->tc_running = 0; while ((priv->tc_running != -1) && tries--) sleep(1); if (tries <= 0) return -1; } return 0; } /** * Start reader thread * @return -1 if failed to start thread or 0 if it is successful */ static int start_reader(struct tip_cygwin * priv) { priv->tc_running = 2; if (pthread_create(&priv->tc_reader, NULL, ti_reader, priv)) return -1; priv->tc_running = 1; return 0; } /** * Change status (enable/disable) of the device */ static int ti_media_status(struct tip_cygwin * priv, int on) { ULONG s = on; DWORD len; if (!DeviceIoControl(priv->tc_h, TAP_IOCTL_SET_MEDIA_STATUS, &s, sizeof(s), &s, sizeof(s), &len, NULL)) return -1; return 0; } /** * Try opening device */ static int ti_try_open(struct tip_cygwin * priv, char * guid) { int any = priv->tc_guid[0] == 0; char device[256]; HANDLE h; if (!any && strcmp(priv->tc_guid, guid) != 0) return 0; /* open the device */ snprintf( device, sizeof(device), "%s%s%s", USERMODEDEVICEDIR, guid, TAPSUFFIX); h = CreateFile(device, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_SYSTEM | FILE_FLAG_OVERLAPPED, 0); if (h == INVALID_HANDLE_VALUE) { if (any) return 0; else return -1; } priv->tc_h = h; /* XXX check tap version */ /* bring iface up */ if (ti_media_status(priv, 1) == -1) return -1; /* XXX grab printable name */ snprintf(priv->tc_name, sizeof(priv->tc_name) - 1, "%s", guid); if (any) snprintf(priv->tc_guid, sizeof(priv->tc_guid), "%s", guid); return 1; } /** * Read registry value * @param key Registry key * @return 0 if successful, -1 if it failed */ static int ti_read_reg(struct tip_cygwin * priv, char * key, char * res, int len) { DWORD dt, l = len; if (RegQueryValueEx(priv->tc_key, key, NULL, &dt, (unsigned char *) res, &l) != ERROR_SUCCESS) return -1; if (dt != REG_SZ) return -1; if ((int) l > len) return -1; return 0; } static int ti_get_devs_component(struct tip_cygwin * priv, char * name) { char key[256]; int rc = 0; snprintf(key, sizeof(key) - 1, "%s\\%s", ADAPTER_KEY, name); if (RegOpenKeyEx( HKEY_LOCAL_MACHINE, key, 0, KEY_READ | KEY_WRITE, &priv->tc_key) != ERROR_SUCCESS) return -1; if (ti_read_reg(priv, "ComponentId", key, sizeof(key)) == -1) goto out; /* make sure component id matches */ if (strcmp(key, TAP_COMPONENT_ID) != 0) goto out; /* get guid */ if (ti_read_reg(priv, "NetCfgInstanceId", key, sizeof(key)) == -1) goto out; rc = ti_try_open(priv, key); out: if (rc != 1) { RegCloseKey(priv->tc_key); priv->tc_key = 0; } return rc; } static int ti_do_open_cygwin(struct tip_cygwin * priv) { int rc = -1; HKEY ak47; int i; char name[256]; DWORD len; /* open network driver key */ if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, ADAPTER_KEY, 0, KEY_READ, &ak47) != ERROR_SUCCESS) return -1; /* find tap */ for (i = 0;; i++) { len = sizeof(name); if (RegEnumKeyEx(ak47, i, name, &len, NULL, NULL, NULL, NULL) != ERROR_SUCCESS) break; rc = ti_get_devs_component(priv, name); if (rc) break; rc = -1; } RegCloseKey(ak47); if (rc == 1) rc = 0; return rc; } static void ti_do_free(struct tif * ti) { struct tip_cygwin * priv = ti_priv(ti); /* stop reader */ stop_reader(priv); if (priv->tc_pipe[0]) { close(priv->tc_pipe[0]); close(priv->tc_pipe[1]); } /* close card */ if (priv->tc_h) { ti_media_status(priv, 0); CloseHandle(priv->tc_h); } if (priv->tc_key) RegCloseKey(priv->tc_key); free(priv); free(ti); } static void ti_close_cygwin(struct tif * ti) { ti_do_free(ti); } static char * ti_name_cygwin(struct tif * ti) { struct tip_cygwin * priv = ti_priv(ti); return priv->tc_name; } /* XXX */ static int ti_is_us(struct tip_cygwin * priv, HDEVINFO * hdi, SP_DEVINFO_DATA * did) { char buf[256]; DWORD len = sizeof(buf), dt; if (priv) { } /* XXX unused */ if (!SetupDiGetDeviceRegistryProperty( *hdi, did, SPDRP_DEVICEDESC, &dt, (unsigned char *) buf, len, &len)) return 0; if (dt != REG_SZ) return 0; return strstr(buf, "TAP-Win32") != NULL; } static int ti_reset_state(HDEVINFO * hdi, SP_DEVINFO_DATA * did, DWORD state) { SP_PROPCHANGE_PARAMS parm; parm.ClassInstallHeader.cbSize = sizeof(parm.ClassInstallHeader); parm.ClassInstallHeader.InstallFunction = DIF_PROPERTYCHANGE; parm.Scope = DICS_FLAG_GLOBAL; parm.StateChange = state; if (!SetupDiSetClassInstallParams( *hdi, did, (SP_CLASSINSTALL_HEADER *) &parm, sizeof(parm))) return -1; if (!SetupDiCallClassInstaller(DIF_PROPERTYCHANGE, *hdi, did)) return -1; return 0; } /** * Reset the device * @return 0 if successful, -1 if it failed */ static int ti_do_reset(HDEVINFO * hdi, SP_DEVINFO_DATA * did) { int rc; rc = ti_reset_state(hdi, did, DICS_DISABLE); if (rc) return rc; return ti_reset_state(hdi, did, DICS_ENABLE); } static int ti_restart(struct tip_cygwin * priv) { /* kill handle to if */ if (priv->tc_h) CloseHandle(priv->tc_h); /* stop reader */ if (stop_reader(priv)) return -1; /* reopen dev */ if (ti_do_open_cygwin(priv)) return -1; return start_reader(priv); } static int ti_reset(struct tip_cygwin * priv) { HDEVINFO hdi; SP_DEVINFO_DATA did; int i; int rc = -1; hdi = SetupDiGetClassDevs(&GUID_DEVCLASS_NET, NULL, NULL, DIGCF_PRESENT); if (hdi == INVALID_HANDLE_VALUE) return -1; /* find device */ for (i = 0;; i++) { did.cbSize = sizeof(did); if (!SetupDiEnumDeviceInfo(hdi, i, &did)) break; if (!ti_is_us(priv, &hdi, &did)) continue; rc = ti_do_reset(&hdi, &did); if (rc) break; rc = ti_restart(priv); break; } SetupDiDestroyDeviceInfoList(hdi); return rc; } static int ti_set_mtu_cygwin(struct tif * ti, int mtu) { struct tip_cygwin * priv = ti_priv(ti); char m[16]; char mold[sizeof(m)]; char * key = "MTU"; /* check if reg remains unchanged to avoid reset */ snprintf(m, sizeof(m) - 1, "%d", mtu); if (ti_read_reg(priv, key, mold, sizeof(mold)) != -1) { if (strcmp(m, mold) == 0) return 0; } /* change */ if (RegSetValueEx( priv->tc_key, key, 0, REG_SZ, (unsigned char *) m, strlen(m) + 1) != ERROR_SUCCESS) return -1; if (ti_reset(priv) == -1) return -1; return 0; } /** * Set device MAC address * @param mac New MAC address * @return -1 if it failed, 0 on success */ static int ti_set_mac_cygwin(struct tif * ti, unsigned char * mac) { struct tip_cygwin * priv = ti_priv(ti); char str[2 * 6 + 1]; char strold[sizeof(str)]; int i; char * key = "MAC"; /* convert */ str[0] = 0; for (i = 0; i < 6; i++) { char tmp[3]; if (sprintf(tmp, "%.2X", *mac++) != 2) return -1; strcat(str, tmp); } /* check if changed */ if (ti_read_reg(priv, key, strold, sizeof(strold)) != -1) { if (strcmp(str, strold) == 0) return 0; } /* own */ if (RegSetValueEx(priv->tc_key, key, 0, REG_SZ, (unsigned char *) str, strlen(str) + 1) != ERROR_SUCCESS) return -1; if (ti_reset(priv) == -1) return -1; return 0; } /** * Set device IP address * @param ip New IP address * @return -1 if it failed, 0 on success */ static int ti_set_ip_cygwin(struct tif * ti, struct in_addr * ip) { struct tip_cygwin * priv = ti_priv(ti); ULONG ctx, inst; IP_ADAPTER_INFO ai[16]; DWORD len = sizeof(ai); PIP_ADAPTER_INFO p; PIP_ADDR_STRING ips; if (GetAdaptersInfo(ai, &len) != ERROR_SUCCESS) return -1; p = ai; while (p) { if (strcmp(priv->tc_guid, p->AdapterName) != 0) { p = p->Next; continue; } /* delete ips */ ips = &p->IpAddressList; while (ips) { DeleteIPAddress(ips->Context); ips = ips->Next; } /* add ip */ if (AddIPAddress(ip->s_addr, htonl(0xffffff00), p->Index, &ctx, &inst) != NO_ERROR) return -1; break; } return 0; } static int ti_fd_cygwin(struct tif * ti) { struct tip_cygwin * priv = ti_priv(ti); return priv->tc_pipe[0]; } static int ti_read_cygwin(struct tif * ti, void * buf, int len) { struct tip_cygwin * priv = ti_priv(ti); int plen; if (priv->tc_running != 1) return -1; /* read len */ if (net_read_exact(priv->tc_pipe[0], &plen, sizeof(plen)) == -1) return -1; return cygwin_read_reader(priv->tc_pipe[0], plen, buf, len); } static int ti_wait_complete(struct tip_cygwin * priv, OVERLAPPED * o) { DWORD sz; if (!GetOverlappedResult(priv->tc_h, o, &sz, TRUE)) return -1; return sz; } static int ti_do_io(struct tip_cygwin * priv, void * buf, int len, OVERLAPPED * o, int wr) { BOOL rc; DWORD sz; int err; /* setup overlapped */ memset(o, 0, sizeof(*o)); /* do io */ if (wr) rc = WriteFile(priv->tc_h, buf, len, &sz, o); else rc = ReadFile(priv->tc_h, buf, len, &sz, o); /* done */ if (rc) return sz; if ((err = GetLastError()) != ERROR_IO_PENDING) return -1; return 0; /* pending */ } static int ti_do_io_lock( struct tip_cygwin * priv, void * buf, int len, OVERLAPPED * o, int wr) { int rc; if (pthread_mutex_lock(&priv->tc_mtx)) return -1; rc = ti_do_io(priv, buf, len, o, wr); if (pthread_mutex_unlock(&priv->tc_mtx)) return -1; /* done */ if (rc) return rc; return ti_wait_complete(priv, o); } static int ti_write_cygwin(struct tif * ti, void * buf, int len) { struct tip_cygwin * priv = ti_priv(ti); OVERLAPPED o; return ti_do_io_lock(priv, buf, len, &o, 1); } static int ti_read_packet(struct tip_cygwin * priv, void * buf, int len) { OVERLAPPED o; int rc; while (priv->tc_running) { rc = ti_do_io_lock(priv, buf, len, &o, 0); if (rc) return rc; } return -1; } static void * ti_reader(void * arg) { struct tip_cygwin * priv = arg; unsigned char buf[2048]; int len; while (priv->tc_running) { /* read a packet */ if ((len = ti_read_packet(priv, buf, sizeof(buf))) == -1) break; assert(len > 0); /* write it's length */ if (write(priv->tc_pipe[1], &len, sizeof(len)) != sizeof(len)) break; /* write payload */ if (write(priv->tc_pipe[1], buf, len) != len) break; } priv->tc_running = -1; return NULL; } static struct tif * ti_open_cygwin(char * iface) { struct tif * ti; struct tip_cygwin * priv; /* setup ti struct */ ti = ti_alloc(sizeof(*priv)); if (!ti) return NULL; priv = ti_priv(ti); ti->ti_name = ti_name_cygwin; ti->ti_set_mtu = ti_set_mtu_cygwin; ti->ti_close = ti_close_cygwin; ti->ti_fd = ti_fd_cygwin; ti->ti_read = ti_read_cygwin; ti->ti_write = ti_write_cygwin; ti->ti_set_mac = ti_set_mac_cygwin; ti->ti_set_ip = ti_set_ip_cygwin; /* setup iface */ if (iface) snprintf(priv->tc_guid, sizeof(priv->tc_guid), "%s", iface); if (ti_do_open_cygwin(priv) == -1) goto err; /* setup reader */ if (pipe(priv->tc_pipe) == -1) goto err; if (pthread_mutex_init(&priv->tc_mtx, NULL)) goto err; /* launch reader */ if (start_reader(priv)) goto err; return ti; err: ti_do_free(ti); return NULL; } EXPORT struct tif * ti_open(char * iface) { return ti_open_cygwin(iface); } aircrack-ng-1.6/lib/osdep/darwin.c000066400000000000000000000024041361312141100170420ustar00rootroot00000000000000/* * Copyright (c) 2009, Kyle Fuller , based upon * freebsd.c by Andrea Bittau * * OS dependent API for Darwin. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include "osdep.h" struct wif * wi_open_osdep(char * iface) { if (iface) { } /* XXX unused parameter */ errno = EOPNOTSUPP; return NULL; } EXPORT int get_battery_state(void) { errno = EOPNOTSUPP; return -1; } int create_tap(void) { errno = EOPNOTSUPP; return -1; } aircrack-ng-1.6/lib/osdep/darwin_tap.c000066400000000000000000000120351361312141100177070ustar00rootroot00000000000000/* * Copyright (c) 2009, Kyle Fuller , based upon * freebsd_tap.c by Andrea Bittau * * OS dependent API for Darwin. TAP routines * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include #include #include #include #include #include "osdep.h" #define MAX_TAP_DEVS 16 struct tip_darwin { int tf_fd; int tf_ioctls; struct ifreq tf_ifr; char tf_name[MAX_IFACE_NAME]; int tf_destroy; }; static int ti_do_open_darwin(struct tif * ti, char * name) { int fd = -1; char iface[12]; struct stat st; struct tip_darwin * priv = ti_priv(ti); int s; unsigned int flags; struct ifreq * ifr; int i; /* open tap */ if (name) { fd = open(name, O_RDWR); } else { priv->tf_destroy = 1; /* we create, we destroy */ for (i = 0; i < MAX_TAP_DEVS; i++) { snprintf(iface, sizeof(iface), "/dev/tap%d", i); fd = open(iface, O_RDWR); if (fd != -1) { break; } } } if (fd == -1) { return -1; } /* get name */ if (fstat(fd, &st) == -1) goto err; snprintf(priv->tf_name, sizeof(priv->tf_name) - 1, "%s", devname(st.st_rdev, S_IFCHR)); /* bring iface up */ s = socket(PF_INET, SOCK_DGRAM, 0); if (s == -1) goto err; priv->tf_ioctls = s; /* get flags */ ifr = &priv->tf_ifr; memset(ifr, 0, sizeof(*ifr)); snprintf(ifr->ifr_name, sizeof(ifr->ifr_name) - 1, "%s", priv->tf_name); if (ioctl(s, SIOCGIFFLAGS, ifr) == -1) goto err2; flags = (ifr->ifr_flags & 0xffff); /* set flags */ flags |= IFF_UP; ifr->ifr_flags = flags & 0xffff; if (ioctl(s, SIOCSIFFLAGS, ifr) == -1) goto err2; return fd; err: /* XXX destroy */ close(fd); return -1; err2: close(s); goto err; } static void ti_do_free(struct tif * ti) { struct tip_darwin * priv = ti_priv(ti); free(priv); free(ti); } static void ti_destroy(struct tip_darwin * priv) { ioctl(priv->tf_ioctls, SIOCIFDESTROY, &priv->tf_ifr); } static void ti_close_darwin(struct tif * ti) { struct tip_darwin * priv = ti_priv(ti); if (priv->tf_destroy) ti_destroy(priv); close(priv->tf_fd); close(priv->tf_ioctls); ti_do_free(ti); } static char * ti_name_darwin(struct tif * ti) { struct tip_darwin * priv = ti_priv(ti); return priv->tf_name; } static int ti_set_mtu_darwin(struct tif * ti, int mtu) { struct tip_darwin * priv = ti_priv(ti); priv->tf_ifr.ifr_mtu = mtu; return ioctl(priv->tf_ioctls, SIOCSIFMTU, &priv->tf_ifr); } static int ti_set_mac_darwin(struct tif * ti, unsigned char * mac) { struct tip_darwin * priv = ti_priv(ti); struct ifreq * ifr = &priv->tf_ifr; ifr->ifr_addr.sa_family = AF_LINK; ifr->ifr_addr.sa_len = 6; memcpy(ifr->ifr_addr.sa_data, mac, 6); return ioctl(priv->tf_ioctls, SIOCSIFLLADDR, ifr); } static int ti_set_ip_darwin(struct tif * ti, struct in_addr * ip) { struct tip_darwin * priv = ti_priv(ti); struct ifaliasreq ifra; struct sockaddr_in * s_in; /* assume same size */ memset(&ifra, 0, sizeof(ifra)); strcpy(ifra.ifra_name, priv->tf_ifr.ifr_name); s_in = (struct sockaddr_in *) &ifra.ifra_addr; s_in->sin_family = PF_INET; s_in->sin_addr = *ip; s_in->sin_len = sizeof(*s_in); return ioctl(priv->tf_ioctls, SIOCAIFADDR, &ifra); } static int ti_fd_darwin(struct tif * ti) { struct tip_darwin * priv = ti_priv(ti); return priv->tf_fd; } static int ti_read_darwin(struct tif * ti, void * buf, int len) { return read(ti_fd(ti), buf, len); } static int ti_write_darwin(struct tif * ti, void * buf, int len) { return write(ti_fd(ti), buf, len); } static struct tif * ti_open_darwin(char * iface) { struct tif * ti; struct tip_darwin * priv; int fd; /* setup ti struct */ ti = ti_alloc(sizeof(*priv)); if (!ti) return NULL; ti->ti_name = ti_name_darwin; ti->ti_set_mtu = ti_set_mtu_darwin; ti->ti_close = ti_close_darwin; ti->ti_fd = ti_fd_darwin; ti->ti_read = ti_read_darwin; ti->ti_write = ti_write_darwin; ti->ti_set_mac = ti_set_mac_darwin; ti->ti_set_ip = ti_set_ip_darwin; /* setup iface */ fd = ti_do_open_darwin(ti, iface); if (fd == -1) { ti_do_free(ti); return NULL; } /* setup private state */ priv = ti_priv(ti); priv->tf_fd = fd; return ti; } EXPORT struct tif * ti_open(char * iface) { return ti_open_darwin(iface); } aircrack-ng-1.6/lib/osdep/dummy.c000066400000000000000000000023211361312141100167070ustar00rootroot00000000000000/* * Copyright (c) 2007, 2008, Andrea Bittau * * OS dependent API for unsupported APIs. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include "osdep.h" struct wif * wi_open_osdep(char * iface) { if (iface) { } /* XXX unused parameter */ errno = EOPNOTSUPP; return NULL; } EXPORT int get_battery_state(void) { errno = EOPNOTSUPP; return -1; } int create_tap(void) { errno = EOPNOTSUPP; return -1; } aircrack-ng-1.6/lib/osdep/dummy_tap.c000066400000000000000000000022311361312141100175530ustar00rootroot00000000000000/* * Copyright (c) 2007, 2008, Andrea Bittau * * OS dependent API for unsupported APIs. TAP routines * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include "osdep.h" static struct tif * ti_open_dummy(char * iface) { if (iface) { } /* XXX unused parameter */ return NULL; } EXPORT struct tif * ti_open(char * iface) { return ti_open_dummy(iface); } aircrack-ng-1.6/lib/osdep/file.c000066400000000000000000000201211361312141100164710ustar00rootroot00000000000000/* * Copyright (c) 2010 Andrea Bittau * * OS dependent API for using card via a pcap file. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include "osdep.h" #include "aircrack-ng/support/pcap_local.h" #include "radiotap/radiotap_iter.h" #include "common.h" struct priv_file { int pf_fd; int pf_chan; int pf_rate; int pf_dtl; uint32_t pf_magic; unsigned char pf_mac[6]; }; static int file_read(struct wif * wi, struct timespec * ts, int * dlt, unsigned char * h80211, int len, struct rx_info * ri) { struct priv_file * pf = wi_priv(wi); struct pcap_pkthdr pkh; int rc; int got_signal = 0; int got_noise = 0; unsigned char buf[4096] __attribute__((aligned(8))); int off = 0; struct ieee80211_radiotap_header * rh; struct ieee80211_radiotap_iterator iterator; memset(&iterator, 0, sizeof(iterator)); rc = read(pf->pf_fd, &pkh, sizeof(pkh)); if (rc != sizeof(pkh)) return -1; if (pf->pf_magic == TCPDUMP_CIGAM) { pkh.caplen = ___my_swab32(pkh.caplen); pkh.len = ___my_swab32(pkh.len); } if (pkh.caplen > sizeof(buf)) { printf("Bad caplen %lu\n", (unsigned long) pkh.caplen); return 0; } assert(pkh.caplen <= sizeof(buf)); //-V547 rc = read(pf->pf_fd, buf, pkh.caplen); if (rc != (int) pkh.caplen) return -1; if (ri) memset(ri, 0, sizeof(*ri)); switch (pf->pf_dtl) { case LINKTYPE_IEEE802_11: off = 0; break; case LINKTYPE_RADIOTAP_HDR: rh = (struct ieee80211_radiotap_header *) buf; off = le16_to_cpu(rh->it_len); if (ieee80211_radiotap_iterator_init(&iterator, rh, rc, NULL) < 0) return -1; while (ieee80211_radiotap_iterator_next(&iterator) >= 0) { switch (iterator.this_arg_index) { case IEEE80211_RADIOTAP_TSFT: if (ri) ri->ri_mactime = le64_to_cpu( *((uint64_t *) iterator.this_arg)); break; case IEEE80211_RADIOTAP_DBM_ANTSIGNAL: if (ri && !got_signal) { if (*iterator.this_arg < 127) ri->ri_power = *iterator.this_arg; else ri->ri_power = *iterator.this_arg - 255; got_signal = 1; } break; case IEEE80211_RADIOTAP_DB_ANTSIGNAL: if (ri && !got_signal) { if (*iterator.this_arg < 127) ri->ri_power = *iterator.this_arg; else ri->ri_power = *iterator.this_arg - 255; got_signal = 1; } break; case IEEE80211_RADIOTAP_DBM_ANTNOISE: if (ri && !got_noise) { if (*iterator.this_arg < 127) ri->ri_noise = *iterator.this_arg; else ri->ri_noise = *iterator.this_arg - 255; got_noise = 1; } break; case IEEE80211_RADIOTAP_DB_ANTNOISE: if (ri && !got_noise) { if (*iterator.this_arg < 127) ri->ri_noise = *iterator.this_arg; else ri->ri_noise = *iterator.this_arg - 255; got_noise = 1; } break; case IEEE80211_RADIOTAP_ANTENNA: if (ri) ri->ri_antenna = *iterator.this_arg; break; case IEEE80211_RADIOTAP_CHANNEL: if (ri) ri->ri_channel = getChannelFromFrequency( le16toh(*(uint16_t *) iterator.this_arg)); break; case IEEE80211_RADIOTAP_RATE: if (ri) ri->ri_rate = (*iterator.this_arg) * 500000; break; case IEEE80211_RADIOTAP_FLAGS: if (*iterator.this_arg & IEEE80211_RADIOTAP_F_FCS) rc -= 4; break; } } break; case LINKTYPE_PRISM_HEADER: if (buf[7] == 0x40) { off = 0x40; if (ri) { ri->ri_power = -((int32_t) load32_le(buf + 0x33)); ri->ri_noise = (int32_t) load32_le(buf + 0x33 + 12); ri->ri_rate = load32_le(buf + 0x33 + 24) * 500000; got_signal = 1; got_noise = 1; } } else { off = load32_le(buf + 4); if (ri) { ri->ri_mactime = load64_le(buf + 0x5C - 48); ri->ri_channel = load32_le(buf + 0x5C - 36); ri->ri_power = -((int32_t) load32_le(buf + 0x5C)); ri->ri_noise = (int32_t) load32_le(buf + 0x5C + 12); ri->ri_rate = load32_le(buf + 0x5C + 24) * 500000; } } rc -= 4; break; case LINKTYPE_PPI_HDR: off = load16_le(buf + 2); /* for a while Kismet logged broken PPI headers */ if (off == 24 && load16_le(buf + 8) == 2) off = 32; break; case LINKTYPE_ETHERNET: printf("Ethernet packets\n"); return 0; default: errx(1, "Unknown DTL %d", pf->pf_dtl); break; } rc -= off; assert(rc >= 0); if (off < 0 || rc < 0) return -1; if (rc > len) rc = len; if (dlt) { *dlt = LINKTYPE_IEEE802_11; } if (ts) { ts->tv_sec = pkh.tv_sec; ts->tv_nsec = pkh.tv_usec * 1000UL; } memcpy(h80211, &buf[off], rc); return rc; } static int file_get_mac(struct wif * wi, unsigned char * mac) { struct priv_file * pn = wi_priv(wi); memcpy(mac, pn->pf_mac, sizeof(pn->pf_mac)); return 0; } static int file_write(struct wif * wi, struct timespec * ts, int dlt, unsigned char * h80211, int len, struct tx_info * ti) { struct priv_file * pn = wi_priv(wi); if (h80211 && ti && pn && ts && dlt) { } return len; } static int file_set_channel(struct wif * wi, int chan) { struct priv_file * pf = wi_priv(wi); pf->pf_chan = chan; return 0; } static int file_get_channel(struct wif * wi) { struct priv_file * pf = wi_priv(wi); return pf->pf_chan; } static int file_set_rate(struct wif * wi, int rate) { struct priv_file * pf = wi_priv(wi); pf->pf_rate = rate; return 0; } static int file_get_rate(struct wif * wi) { struct priv_file * pf = wi_priv(wi); return pf->pf_rate; } static int file_get_monitor(struct wif * wi) { if (wi) { } return 1; } static void file_close(struct wif * wi) { struct priv_file * pn = wi_priv(wi); if (pn) { if (pn->pf_fd) { close(pn->pf_fd); } free(pn); } free(wi); } static int file_fd(struct wif * wi) { struct priv_file * pf = wi_priv(wi); return pf->pf_fd; } struct wif * file_open(char * iface) { struct wif * wi; struct priv_file * pf; int fd; struct pcap_file_header pfh; int rc; if (iface == NULL || strncmp(iface, "file://", 7) != 0) return NULL; /* setup wi struct */ wi = wi_alloc(sizeof(*pf)); if (!wi) return NULL; wi->wi_read = file_read; wi->wi_write = file_write; wi->wi_set_channel = file_set_channel; wi->wi_get_channel = file_get_channel; wi->wi_set_rate = file_set_rate; wi->wi_get_rate = file_get_rate; wi->wi_close = file_close; wi->wi_fd = file_fd; wi->wi_get_mac = file_get_mac; wi->wi_get_monitor = file_get_monitor; pf = wi_priv(wi); fd = open(iface + 7, O_RDONLY); if (fd == -1) err(1, "open()"); pf->pf_fd = fd; if ((rc = read(fd, &pfh, sizeof(pfh))) != sizeof(pfh)) goto __err; if (pfh.magic != TCPDUMP_MAGIC && pfh.magic != TCPDUMP_CIGAM) goto __err; if (pfh.magic == TCPDUMP_CIGAM) { pfh.version_major = ___my_swab16(pfh.version_major); pfh.version_minor = ___my_swab16(pfh.version_minor); pfh.linktype = ___my_swab32(pfh.linktype); } if (pfh.version_major != PCAP_VERSION_MAJOR || pfh.version_minor != PCAP_VERSION_MINOR) goto __err; pf->pf_dtl = pfh.linktype; pf->pf_magic = pfh.magic; return wi; __err: wi_close(wi); return (struct wif *) -1; } aircrack-ng-1.6/lib/osdep/freebsd.c000066400000000000000000000332301361312141100171710ustar00rootroot00000000000000/* * Copyright (c) 2007, 2008, Andrea Bittau * * OS dependent API for FreeBSD. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include #include #include #include #include #ifdef __DragonFly__ #include #include #include #else #include #include #include #endif #include #include #include #include #include #include #include #include "osdep.h" #ifndef LINKTYPE_IEEE802_11 #define LINKTYPE_IEEE802_11 105 #endif struct priv_fbsd { /* iface */ int pf_fd; /* rx */ int pf_nocrc; /* tx */ unsigned char pf_buf[4096]; unsigned char * pf_next; int pf_totlen; struct ieee80211_bpf_params pf_txparams; /* setchan */ int pf_s; struct ifreq pf_ifr; struct ieee80211req pf_ireq; int pf_chan; }; /* from ifconfig */ static __inline int mapgsm(u_int freq, u_int flags) { freq *= 10; if (flags & IEEE80211_CHAN_QUARTER) freq += 5; else if (flags & IEEE80211_CHAN_HALF) freq += 10; else freq += 20; /* NB: there is no 907/20 wide but leave room */ return (freq - 906 * 10) / 5; } static __inline int mappsb(u_int freq) { return 37 + ((freq * 10) + ((freq % 5) == 2 ? 5 : 0) - 49400) / 5; } /* * Convert MHz frequency to IEEE channel number. */ static u_int ieee80211_mhz2ieee(u_int freq, u_int flags) { if ((flags & IEEE80211_CHAN_GSM) || (907 <= freq && freq <= 922)) return mapgsm(freq, flags); if (freq == 2484) return 14; if (freq < 2484) return (freq - 2407) / 5; if (freq < 5000) { if (flags & (IEEE80211_CHAN_HALF | IEEE80211_CHAN_QUARTER)) return mappsb(freq); else if (freq > 4900) return (freq - 4000) / 5; else return 15 + ((freq - 2512) / 20); } return (freq - 5000) / 5; } /* end of ifconfig */ static void get_radiotap_info(struct priv_fbsd * pf, struct ieee80211_radiotap_header * rth, int * plen, struct rx_info * ri) { uint32_t present; uint8_t rflags = 0; int i; unsigned char * body = (unsigned char *) (rth + 1); int dbm_power = 0, db_power = 0; /* reset control info */ if (ri) memset(ri, 0, sizeof(*ri)); /* get info */ present = le32toh(rth->it_present); for (i = IEEE80211_RADIOTAP_TSFT; i <= IEEE80211_RADIOTAP_EXT; i++) { if (!(present & (1 << i))) continue; switch (i) { case IEEE80211_RADIOTAP_TSFT: body += sizeof(uint64_t); break; case IEEE80211_RADIOTAP_FLAGS: rflags = *((uint8_t *) body); /* fall through */ case IEEE80211_RADIOTAP_RATE: body += sizeof(uint8_t); break; case IEEE80211_RADIOTAP_CHANNEL: if (ri) { uint16_t * p = (uint16_t *) body; int c = ieee80211_mhz2ieee(*p, *(p + 1)); ri->ri_channel = c; } body += sizeof(uint16_t) * 2; break; case IEEE80211_RADIOTAP_FHSS: body += sizeof(uint16_t); break; case IEEE80211_RADIOTAP_DBM_ANTSIGNAL: dbm_power = *body++; break; case IEEE80211_RADIOTAP_DBM_ANTNOISE: dbm_power -= *body++; break; case IEEE80211_RADIOTAP_DB_ANTSIGNAL: db_power = *body++; break; case IEEE80211_RADIOTAP_DB_ANTNOISE: db_power -= *body++; break; default: i = IEEE80211_RADIOTAP_EXT + 1; break; } } /* set power */ if (ri) { if (dbm_power) ri->ri_power = dbm_power; else ri->ri_power = db_power; } /* XXX cache; drivers won't change this per-packet */ /* check if FCS/CRC is included in packet */ if (pf->pf_nocrc || (rflags & IEEE80211_RADIOTAP_F_FCS)) { *plen -= IEEE80211_CRC_LEN; pf->pf_nocrc = 1; } } static unsigned char * get_80211(struct priv_fbsd * pf, int * plen, struct rx_info * ri) { struct bpf_hdr * bpfh; struct ieee80211_radiotap_header * rth; void * ptr; unsigned char ** data; int * totlen; data = &pf->pf_next; totlen = &pf->pf_totlen; assert(*totlen); /* bpf hdr */ bpfh = (struct bpf_hdr *) (*data); assert(bpfh->bh_caplen == bpfh->bh_datalen); /* XXX */ *totlen -= bpfh->bh_hdrlen; /* check if more packets */ if ((int) bpfh->bh_caplen < *totlen) { int tot = bpfh->bh_hdrlen + bpfh->bh_caplen; int offset = BPF_WORDALIGN(tot); *data = (unsigned char *) bpfh + offset; *totlen -= offset - tot; /* take into account align bytes */ } else if ((int) bpfh->bh_caplen > *totlen) abort(); *plen = bpfh->bh_caplen; *totlen -= bpfh->bh_caplen; assert(*totlen >= 0); /* radiotap */ rth = (struct ieee80211_radiotap_header *) ((char *) bpfh + bpfh->bh_hdrlen); get_radiotap_info(pf, rth, plen, ri); *plen -= rth->it_len; assert(*plen > 0); /* data */ ptr = (char *) rth + rth->it_len; return ptr; } static int fbsd_get_channel(struct wif * wi) { struct priv_fbsd * pf = wi_priv(wi); if (ioctl(pf->pf_s, SIOCG80211, &pf->pf_ireq) != 0) return -1; return pf->pf_ireq.i_val; } static int fbsd_read(struct wif * wi, struct timespec * ts, int * dlt, unsigned char * h80211, int len, struct rx_info * ri) { struct priv_fbsd * pf = wi_priv(wi); unsigned char * wh; int plen; assert(len > 0); /* need to read more */ if (pf->pf_totlen == 0) { pf->pf_totlen = read(pf->pf_fd, pf->pf_buf, sizeof(pf->pf_buf)); if (pf->pf_totlen == -1) { pf->pf_totlen = 0; return -1; } pf->pf_next = pf->pf_buf; } /* read 802.11 packet */ wh = get_80211(pf, &plen, ri); if (plen > len) plen = len; assert(plen > 0); memcpy(h80211, wh, plen); if (dlt) { *dlt = LINKTYPE_IEEE802_11; } if (ts) { clock_gettime(CLOCK_REALTIME, ts); } if (ri && !ri->ri_channel) ri->ri_channel = wi_get_channel(wi); return plen; } static int fbsd_write(struct wif * wi, struct timespec * ts, int dlt, unsigned char * h80211, int len, struct tx_info * ti) { struct iovec iov[2]; struct priv_fbsd * pf = wi_priv(wi); int rc; (void) ts; (void) dlt; /* XXX make use of ti */ if (ti) { } iov[0].iov_base = &pf->pf_txparams; iov[0].iov_len = pf->pf_txparams.ibp_len; iov[1].iov_base = h80211; iov[1].iov_len = len; rc = writev(pf->pf_fd, iov, 2); if (rc == -1) return rc; if (rc < (int) iov[0].iov_len) return 0; return rc - iov[0].iov_len; } static int fbsd_set_channel(struct wif * wi, int chan) { struct priv_fbsd * pf = wi_priv(wi); pf->pf_ireq.i_val = chan; if (ioctl(pf->pf_s, SIOCS80211, &pf->pf_ireq) != 0) return -1; pf->pf_chan = chan; return 0; } static void do_free(struct wif * wi) { assert(wi->wi_priv); free(wi->wi_priv); wi->wi_priv = 0; free(wi); } static void fbsd_close(struct wif * wi) { struct priv_fbsd * pf = wi_priv(wi); close(pf->pf_fd); close(pf->pf_s); do_free(wi); } static int do_fbsd_open(struct wif * wi, char * iface) { int i; char buf[64]; int fd = -1; struct ifreq ifr; unsigned int dlt = DLT_IEEE802_11_RADIO; int s; unsigned int flags; struct ifmediareq ifmr; int * mwords; struct priv_fbsd * pf = wi_priv(wi); /* basic sanity check */ if (strlen(iface) >= sizeof(ifr.ifr_name)) return -1; /* open wifi */ s = socket(PF_INET, SOCK_DGRAM, 0); if (s == -1) return -1; pf->pf_s = s; /* set iface up and promisc */ memset(&ifr, 0, sizeof(ifr)); strcpy(ifr.ifr_name, iface); if (ioctl(s, SIOCGIFFLAGS, &ifr) == -1) goto close_sock; flags = (ifr.ifr_flags & 0xffff) | (ifr.ifr_flagshigh << 16); flags |= IFF_UP | IFF_PPROMISC; memset(&ifr, 0, sizeof(ifr)); strcpy(ifr.ifr_name, iface); ifr.ifr_flags = flags & 0xffff; ifr.ifr_flagshigh = flags >> 16; if (ioctl(s, SIOCSIFFLAGS, &ifr) == -1) goto close_sock; /* monitor mode */ memset(&ifmr, 0, sizeof(ifmr)); strcpy(ifmr.ifm_name, iface); if (ioctl(s, SIOCGIFMEDIA, &ifmr) == -1) goto close_sock; assert(ifmr.ifm_count != 0); mwords = (int *) malloc(ifmr.ifm_count * sizeof(int)); if (!mwords) goto close_sock; ifmr.ifm_ulist = mwords; if (ioctl(s, SIOCGIFMEDIA, &ifmr) == -1) { free(mwords); goto close_sock; } free(mwords); memset(&ifr, 0, sizeof(ifr)); strcpy(ifr.ifr_name, iface); ifr.ifr_media = ifmr.ifm_current; if (ioctl(s, SIOCSIFMEDIA, &ifr) == -1) goto close_sock; /* setup ifreq for chan that may be used in future */ strcpy(pf->pf_ireq.i_name, iface); pf->pf_ireq.i_type = IEEE80211_IOC_CHANNEL; /* same for ifreq [mac addr] */ strcpy(pf->pf_ifr.ifr_name, iface); /* open bpf */ for (i = 0; i < 256; i++) { sprintf(buf, "/dev/bpf%d", i); fd = open(buf, O_RDWR); if (fd < 0) { if (errno != EBUSY) return -1; continue; } else break; } if (fd < 0) goto close_sock; strcpy(ifr.ifr_name, iface); if (ioctl(fd, BIOCSETIF, &ifr) < 0) goto close_bpf; if (ioctl(fd, BIOCSDLT, &dlt) < 0) goto close_bpf; dlt = 1; if (ioctl(fd, BIOCIMMEDIATE, &dlt) == -1) goto close_bpf; return fd; close_sock: close(s); return -1; close_bpf: close(fd); goto close_sock; } static int fbsd_fd(struct wif * wi) { struct priv_fbsd * pf = wi_priv(wi); return pf->pf_fd; } static int fbsd_get_mac(struct wif * wi, unsigned char * mac) { struct ifaddrs *ifa, *p; char * name = wi_get_ifname(wi); int rc = -1; struct sockaddr_dl * sdp; if (getifaddrs(&ifa) == -1) return -1; p = ifa; while (p) { if (p->ifa_addr->sa_family == AF_LINK && strcmp(name, p->ifa_name) == 0) { sdp = (struct sockaddr_dl *) p->ifa_addr; memcpy(mac, sdp->sdl_data + sdp->sdl_nlen, 6); rc = 0; break; } p = p->ifa_next; } freeifaddrs(ifa); return rc; } static int fbsd_get_monitor(struct wif * wi) { if (wi) { } /* XXX unused */ /* XXX */ return 0; } static int fbsd_get_rate(struct wif * wi) { if (wi) { } /* XXX unused */ /* XXX */ return 1000000; } static int fbsd_set_rate(struct wif * wi, int rate) { if (wi || rate) { } /* XXX unused */ /* XXX */ return 0; } static int fbsd_set_mac(struct wif * wi, unsigned char * mac) { struct priv_fbsd * priv = wi_priv(wi); struct ifreq * ifr = &priv->pf_ifr; ifr->ifr_addr.sa_family = AF_LINK; ifr->ifr_addr.sa_len = 6; memcpy(ifr->ifr_addr.sa_data, mac, 6); return ioctl(priv->pf_s, SIOCSIFLLADDR, ifr); } static int fbsd_set_mtu(struct wif * wi, int mtu) { struct priv_fbsd * priv = wi_priv(wi); struct ifreq * ifr = &priv->pf_ifr; memset(ifr, 0, sizeof(struct ifreq)); strncpy(ifr->ifr_name, wi_get_ifname(wi), sizeof(ifr->ifr_name)); ifr->ifr_mtu = mtu; if (ioctl(priv->pf_s, SIOCSIFMTU, ifr) < 0) return -1; return 0; } static int fbsd_get_mtu(struct wif * wi) { struct priv_fbsd * priv = wi_priv(wi); struct ifreq ifr; memset(&ifr, 0, sizeof(struct ifreq)); ifr.ifr_addr.sa_family = AF_INET; strncpy(ifr.ifr_name, wi_get_ifname(wi), sizeof(ifr.ifr_name)); if (ioctl(priv->pf_s, SIOCGIFMTU, (caddr_t) &ifr) < 0) return -1; return ifr.ifr_mtu; } static struct wif * fbsd_open(char * iface) { struct wif * wi; struct priv_fbsd * pf; int fd; /* setup wi struct */ wi = wi_alloc(sizeof(*pf)); if (!wi) return NULL; wi->wi_read = fbsd_read; wi->wi_write = fbsd_write; wi->wi_set_channel = fbsd_set_channel; wi->wi_get_channel = fbsd_get_channel; wi->wi_close = fbsd_close; wi->wi_fd = fbsd_fd; wi->wi_get_mac = fbsd_get_mac; wi->wi_set_mac = fbsd_set_mac; wi->wi_get_rate = fbsd_get_rate; wi->wi_set_rate = fbsd_set_rate; wi->wi_get_monitor = fbsd_get_monitor; wi->wi_get_mtu = fbsd_get_mtu; wi->wi_set_mtu = fbsd_set_mtu; /* setup iface */ fd = do_fbsd_open(wi, iface); if (fd == -1) { do_free(wi); return NULL; } /* setup private state */ pf = wi_priv(wi); pf->pf_fd = fd; pf->pf_txparams.ibp_vers = IEEE80211_BPF_VERSION; pf->pf_txparams.ibp_len = sizeof(struct ieee80211_bpf_params) - 6; pf->pf_txparams.ibp_rate0 = 2; /* 1 MB/s XXX */ pf->pf_txparams.ibp_try0 = 1; /* no retransmits */ pf->pf_txparams.ibp_rate1 = 2; /* 1 MB/s XXX */ pf->pf_txparams.ibp_try1 = 1; /* no retransmits */ pf->pf_txparams.ibp_flags = IEEE80211_BPF_NOACK; pf->pf_txparams.ibp_power = 100; /* nominal max */ pf->pf_txparams.ibp_pri = WME_AC_VO; /* high priority */ return wi; } struct wif * wi_open_osdep(char * iface) { return fbsd_open(iface); } EXPORT int get_battery_state(void) { #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__MidnightBSD__) int value; size_t len; len = 4; value = 0; sysctlbyname("hw.acpi.acline", &value, &len, NULL, 0); if (value == 0) { sysctlbyname("hw.acpi.battery.time", &value, &len, NULL, 0); value = value * 60; } else { value = 0; } return (value); #elif defined(_BSD_SOURCE) struct apm_power_info api; int apmfd; if ((apmfd = open("/dev/apm", O_RDONLY)) < 0) return 0; if (ioctl(apmfd, APM_IOC_GETPOWER, &api) < 0) { close(apmfd); return 0; } close(apmfd); if (api.battery_state == APM_BATT_UNKNOWN || api.battery_state == APM_BATTERY_ABSENT || api.battery_state == APM_BATT_CHARGING || api.ac_state == APM_AC_ON) { return 0; } return ((int) (api.minutes_left)) * 60; #else return 0; #endif } aircrack-ng-1.6/lib/osdep/freebsd_tap.c000066400000000000000000000114611361312141100200370ustar00rootroot00000000000000/* * Copyright (c) 2007, 2008, Andrea Bittau * * OS dependent API for FreeBSD. TAP routines * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include #include #include #include #include #include "aircrack-ng/defs.h" #include "osdep.h" struct tip_fbsd { int tf_fd; int tf_ioctls; struct ifreq tf_ifr; char tf_name[IFNAMSIZ]; int tf_destroy; }; static int ti_do_open_fbsd(struct tif * ti, char * name) { int fd; char * iface = "/dev/tap"; struct stat st; struct tip_fbsd * priv = ti_priv(ti); int s; unsigned int flags; struct ifreq * ifr; /* open tap */ if (name) iface = name; else priv->tf_destroy = 1; /* we create, we destroy */ fd = open(iface, O_RDWR); if (fd == -1) return -1; /* get name */ if (fstat(fd, &st) == -1) goto err; snprintf(priv->tf_name, sizeof(priv->tf_name) - 1, "%s", devname(st.st_rdev, S_IFCHR)); /* bring iface up */ s = socket(PF_INET, SOCK_DGRAM, 0); if (s == -1) goto err; priv->tf_ioctls = s; /* get flags */ ifr = &priv->tf_ifr; memset(ifr, 0, sizeof(*ifr)); snprintf(ifr->ifr_name, sizeof(ifr->ifr_name) - 1, "%s", priv->tf_name); if (ioctl(s, SIOCGIFFLAGS, ifr) == -1) goto err2; flags = (ifr->ifr_flags & 0xffff) | (ifr->ifr_flagshigh << 16); /* set flags */ flags |= IFF_UP; ifr->ifr_flags = flags & 0xffff; ifr->ifr_flagshigh = flags >> 16; if (ioctl(s, SIOCSIFFLAGS, ifr) == -1) goto err2; return fd; err: /* XXX destroy */ close(fd); return -1; err2: close(s); goto err; } static void ti_do_free(struct tif * ti) { struct tip_fbsd * priv = ti_priv(ti); free(priv); free(ti); } static void ti_destroy(struct tip_fbsd * priv) { ioctl(priv->tf_ioctls, SIOCIFDESTROY, &priv->tf_ifr); } static void ti_close_fbsd(struct tif * ti) { struct tip_fbsd * priv = ti_priv(ti); if (priv->tf_destroy) ti_destroy(priv); close(priv->tf_fd); close(priv->tf_ioctls); ti_do_free(ti); } static char * ti_name_fbsd(struct tif * ti) { struct tip_fbsd * priv = ti_priv(ti); return priv->tf_name; } static int ti_set_mtu_fbsd(struct tif * ti, int mtu) { struct tip_fbsd * priv = ti_priv(ti); priv->tf_ifr.ifr_mtu = mtu; return ioctl(priv->tf_ioctls, SIOCSIFMTU, &priv->tf_ifr); } static int ti_set_mac_fbsd(struct tif * ti, unsigned char * mac) { struct tip_fbsd * priv = ti_priv(ti); struct ifreq * ifr = &priv->tf_ifr; ifr->ifr_addr.sa_family = AF_LINK; ifr->ifr_addr.sa_len = 6; memcpy(ifr->ifr_addr.sa_data, mac, 6); return ioctl(priv->tf_ioctls, SIOCSIFLLADDR, ifr); } static int ti_set_ip_fbsd(struct tif * ti, struct in_addr * ip) { struct tip_fbsd * priv = ti_priv(ti); struct ifaliasreq ifra; struct sockaddr_in * s_in; /* assume same size */ memset(&ifra, 0, sizeof(ifra)); strcpy(ifra.ifra_name, priv->tf_ifr.ifr_name); s_in = (struct sockaddr_in *) &ifra.ifra_addr; s_in->sin_family = PF_INET; s_in->sin_addr = *ip; s_in->sin_len = sizeof(*s_in); return ioctl(priv->tf_ioctls, SIOCAIFADDR, &ifra); } static int ti_fd_fbsd(struct tif * ti) { struct tip_fbsd * priv = ti_priv(ti); return priv->tf_fd; } static int ti_read_fbsd(struct tif * ti, void * buf, int len) { return read(ti_fd(ti), buf, len); } static int ti_write_fbsd(struct tif * ti, void * buf, int len) { return write(ti_fd(ti), buf, len); } static struct tif * ti_open_fbsd(char * iface) { struct tif * ti; struct tip_fbsd * priv; int fd; /* setup ti struct */ ti = ti_alloc(sizeof(*priv)); if (!ti) return NULL; ti->ti_name = ti_name_fbsd; ti->ti_set_mtu = ti_set_mtu_fbsd; ti->ti_close = ti_close_fbsd; ti->ti_fd = ti_fd_fbsd; ti->ti_read = ti_read_fbsd; ti->ti_write = ti_write_fbsd; ti->ti_set_mac = ti_set_mac_fbsd; ti->ti_set_ip = ti_set_ip_fbsd; /* setup iface */ fd = ti_do_open_fbsd(ti, iface); if (fd == -1) { ti_do_free(ti); return NULL; } /* setup private state */ priv = ti_priv(ti); priv->tf_fd = fd; return ti; } EXPORT struct tif * ti_open(char * iface) { return ti_open_fbsd(iface); } aircrack-ng-1.6/lib/osdep/linux.c000066400000000000000000001542171361312141100167270ustar00rootroot00000000000000/* * OS dependent APIs for Linux * * Copyright (C) 2006-2018 Thomas d'Otreppe * Copyright (C) 2004, 2005 Christophe Devine * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef CONFIG_LIBNL #include #include #include #include #include #include #include #endif // CONFIG_LIBNL #include "radiotap/radiotap.h" #include "radiotap/radiotap_iter.h" /* radiotap-parser defines types like u8 that * ieee80211_radiotap.h needs * * we use our local copy of ieee80211_radiotap.h * * - since we can't support extensions we don't understand * - since linux does not include it in userspace headers */ #include "osdep.h" #include "aircrack-ng/support/pcap_local.h" #include "crctable_osdep.h" #include "common.h" #include "channel.h" #include "aircrack-ng/defs.h" #ifdef CONFIG_LIBNL struct nl80211_state state; static int chan; #endif // CONFIG_LIBNL /* if_nametoindex is defined in net/if.h but that conflicts with linux/if.h */ extern unsigned int if_nametoindex(const char * __ifname); extern char * if_indextoname(unsigned int __ifindex, char * __ifname); typedef enum { DT_NULL = 0, DT_WLANNG, DT_HOSTAP, DT_MADWIFI, DT_MADWIFING, DT_BCM43XX, DT_ORINOCO, DT_ZD1211RW, DT_ACX, DT_MAC80211_RT, DT_AT76USB, DT_IPW2200 } DRIVER_TYPE; /* * XXX need to have a different read/write/open function for each Linux driver. */ struct priv_linux { int fd_in, arptype_in; int fd_out, arptype_out; int fd_main; int fd_rtc; DRIVER_TYPE drivertype; /* inited to DT_UNKNOWN on allocation by wi_alloc */ FILE * f_cap_in; struct pcap_file_header pfh_in; int sysfs_inject; int channel; int freq; int rate; int tx_power; char * wlanctlng; /* XXX never set */ char * iwpriv; char * iwconfig; char * ifconfig; char * wl; char * main_if; unsigned char pl_mac[6]; int inject_wlanng; }; #ifndef ETH_P_80211_RAW #define ETH_P_80211_RAW 25 #endif #define ARPHRD_ETHERNET 1 #define ARPHRD_IEEE80211 801 #define ARPHRD_IEEE80211_PRISM 802 #define ARPHRD_IEEE80211_FULL 803 #ifndef NULL_MAC #define NULL_MAC "\x00\x00\x00\x00\x00\x00" #endif static unsigned long calc_crc_osdep(unsigned char * buf, int len) { unsigned long crc = 0xFFFFFFFF; for (; len > 0; len--, buf++) crc = crc_tbl_osdep[(crc ^ *buf) & 0xFF] ^ (crc >> 8); return (~crc); } /* CRC checksum verification routine */ static int check_crc_buf_osdep(unsigned char * buf, int len) { unsigned long crc; if (len < 0) return 0; crc = calc_crc_osdep(buf, len); buf += len; return (((crc) &0xFF) == buf[0] && ((crc >> 8) & 0xFF) == buf[1] && ((crc >> 16) & 0xFF) == buf[2] && ((crc >> 24) & 0xFF) == buf[3]); } // Check if the driver is ndiswrapper */ static int is_ndiswrapper(const char * iface, const char * path) { int n, pid; if (!path || !iface || strlen(iface) >= IFNAMSIZ) { return 0; } if ((pid = fork()) == 0) { close(0); close(1); close(2); IGNORE_NZ(chdir("/")); execl(path, "iwpriv", iface, "ndis_reset", NULL); exit(1); } waitpid(pid, &n, 0); return ((WIFEXITED(n) && WEXITSTATUS(n) == 0)); } /* Search a file recursively */ static char * searchInside(const char * dir, const char * filename) { char * ret; char * curfile; struct stat sb; int len, lentot; DIR * dp; struct dirent * ep; dp = opendir(dir); if (dp == NULL) { return NULL; } len = strlen(filename); lentot = strlen(dir) + 256 + 2; curfile = (char *) calloc(1, lentot); if (curfile == NULL) { (void) closedir(dp); return (NULL); } while ((ep = readdir(dp)) != NULL) { memset(curfile, 0, lentot); sprintf(curfile, "%s/%s", dir, ep->d_name); // Checking if it's the good file if ((int) strlen(ep->d_name) == len && !strcmp(ep->d_name, filename)) { (void) closedir(dp); return curfile; } // If it's a directory and not a link, try to go inside to search if (lstat(curfile, &sb) == 0 && S_ISDIR(sb.st_mode) && !S_ISLNK(sb.st_mode)) { // Check if the directory isn't "." or ".." if (strcmp(".", ep->d_name) && strcmp("..", ep->d_name)) { // Recursive call ret = searchInside(curfile, filename); if (ret != NULL) { (void) closedir(dp); free(curfile); return ret; } } } } (void) closedir(dp); free(curfile); return NULL; } /* Search a wireless tool and return its path */ static char * wiToolsPath(const char * tool) { char * path /*, *found, *env */; int i, nbelems; static const char * paths[] = {"/sbin", "/usr/sbin", "/usr/local/sbin", "/bin", "/usr/bin", "/usr/local/bin", "/tmp"}; // Also search in other known location just in case we haven't found it yet nbelems = sizeof(paths) / sizeof(char *); for (i = 0; i < nbelems; i++) { path = searchInside(paths[i], tool); if (path != NULL) return path; } return NULL; } /* nl80211 */ #ifdef CONFIG_LIBNL struct nl80211_state { #if !defined(CONFIG_LIBNL30) && !defined(CONFIG_LIBNL20) struct nl_handle * nl_sock; #else struct nl_sock * nl_sock; #endif struct nl_cache * nl_cache; struct genl_family * nl80211; }; #if !defined(CONFIG_LIBNL30) && !defined(CONFIG_LIBNL20) static inline struct nl_handle * nl_socket_alloc(void) { return nl_handle_alloc(); } static inline void nl_socket_free(struct nl_handle * h) { nl_handle_destroy(h); } static inline int __genl_ctrl_alloc_cache(struct nl_handle * h, struct nl_cache ** cache) { struct nl_cache * tmp = genl_ctrl_alloc_cache(h); if (!tmp) return -ENOMEM; *cache = tmp; return 0; } #define genl_ctrl_alloc_cache __genl_ctrl_alloc_cache #endif static int linux_nl80211_init(struct nl80211_state * state) { int err; state->nl_sock = nl_socket_alloc(); if (!state->nl_sock) { fprintf(stderr, "Failed to allocate netlink socket.\n"); return -ENOMEM; } if (genl_connect(state->nl_sock)) { fprintf(stderr, "Failed to connect to generic netlink.\n"); err = -ENOLINK; goto out_handle_destroy; } if (genl_ctrl_alloc_cache(state->nl_sock, &state->nl_cache)) { fprintf(stderr, "Failed to allocate generic netlink cache.\n"); err = -ENOMEM; goto out_handle_destroy; } state->nl80211 = genl_ctrl_search_by_name(state->nl_cache, "nl80211"); if (!state->nl80211) { fprintf(stderr, "nl80211 not found.\n"); err = -ENOENT; goto out_cache_free; } return 0; out_cache_free: nl_cache_free(state->nl_cache); out_handle_destroy: nl_socket_free(state->nl_sock); return err; } static void nl80211_cleanup(struct nl80211_state * state) { genl_family_put(state->nl80211); nl_cache_free(state->nl_cache); nl_socket_free(state->nl_sock); } /* Callbacks */ /* static int error_handler(struct sockaddr_nl *nla, struct nlmsgerr *err, void *arg) { if (nla) { } printf("\n\n\nERROR"); int *ret = arg; *ret = err->error; return NL_STOP; } */ /* static void test_callback(struct nl_msg *msg, void *arg) { if (msg || arg) { } } */ #endif /* End nl80211 */ static int linux_get_channel(struct wif * wi) { struct priv_linux * dev = wi_priv(wi); struct iwreq wrq; int fd, frequency; int chan = 0; memset(&wrq, 0, sizeof(struct iwreq)); if (dev->main_if) strncpy(wrq.ifr_name, dev->main_if, IFNAMSIZ); else strncpy(wrq.ifr_name, wi_get_ifname(wi), IFNAMSIZ); wrq.ifr_name[IFNAMSIZ - 1] = 0; fd = dev->fd_in; if (dev->drivertype == DT_IPW2200) fd = dev->fd_main; if (ioctl(fd, SIOCGIWFREQ, &wrq) < 0) return (-1); frequency = wrq.u.freq.m; if (frequency > 100000000) frequency /= 100000; else if (frequency > 1000000) frequency /= 1000; if (frequency > 1000) chan = getChannelFromFrequency(frequency); else chan = frequency; return chan; } static int linux_get_freq(struct wif * wi) { struct priv_linux * dev = wi_priv(wi); struct iwreq wrq; int fd, frequency; memset(&wrq, 0, sizeof(struct iwreq)); if (dev->main_if) strncpy(wrq.ifr_name, dev->main_if, IFNAMSIZ); else strncpy(wrq.ifr_name, wi_get_ifname(wi), IFNAMSIZ); wrq.ifr_name[IFNAMSIZ - 1] = 0; fd = dev->fd_in; if (dev->drivertype == DT_IPW2200) fd = dev->fd_main; if (ioctl(fd, SIOCGIWFREQ, &wrq) < 0) return (-1); frequency = wrq.u.freq.m; if (frequency > 100000000) frequency /= 100000; else if (frequency > 1000000) frequency /= 1000; if (frequency < 500) // it's not a freq, but the actual channel frequency = getFrequencyFromChannel(frequency); return frequency; } static int linux_set_rate(struct wif * wi, int rate) { struct priv_linux * dev = wi_priv(wi); struct ifreq ifr; struct iwreq wrq; char s[32]; int pid, status; memset(s, 0, sizeof(s)); switch (dev->drivertype) { case DT_MADWIFING: memset(&ifr, 0, sizeof(ifr)); strncpy(ifr.ifr_name, wi_get_ifname(wi), sizeof(ifr.ifr_name) - 1); if (ioctl(dev->fd_in, SIOCGIFINDEX, &ifr) < 0) { printf("Interface %s: \n", wi_get_ifname(wi)); perror("ioctl(SIOCGIFINDEX) failed"); return (1); } /* Bring interface down*/ ifr.ifr_flags = 0; if (ioctl(dev->fd_in, SIOCSIFFLAGS, &ifr) < 0) { perror("ioctl(SIOCSIFFLAGS) failed"); return (1); } usleep(100000); snprintf(s, sizeof(s) - 1, "%.1fM", (rate / 1000000.0)); if ((pid = fork()) == 0) { close(0); close(1); close(2); IGNORE_NZ(chdir("/")); execlp(dev->iwconfig, "iwconfig", wi_get_ifname(wi), "rate", s, NULL); exit(1); } waitpid(pid, &status, 0); return 0; break; case DT_MAC80211_RT: dev->rate = (rate / 500000); // return 0; // Newer mac80211 stacks (2.6.31 and up) // don't care about Radiotap header anymore, so ioctl below must // also be done! //[see Documentation/networking/mac80211-injection.txt] break; default: break; } /* ELSE */ memset(&wrq, 0, sizeof(struct iwreq)); if (dev->main_if) strncpy(wrq.ifr_name, dev->main_if, IFNAMSIZ); else strncpy(wrq.ifr_name, wi_get_ifname(wi), IFNAMSIZ); wrq.ifr_name[IFNAMSIZ - 1] = 0; wrq.u.bitrate.value = rate; wrq.u.bitrate.fixed = 1; if (ioctl(dev->fd_in, SIOCSIWRATE, &wrq) < 0) { return (-1); } return 0; } static int linux_get_rate(struct wif * wi) { struct priv_linux * dev = wi_priv(wi); struct iwreq wrq; memset(&wrq, 0, sizeof(struct iwreq)); if (dev->drivertype == DT_MAC80211_RT) return (dev->rate * 500000); if (dev->main_if) strncpy(wrq.ifr_name, dev->main_if, IFNAMSIZ); else strncpy(wrq.ifr_name, wi_get_ifname(wi), IFNAMSIZ); wrq.ifr_name[IFNAMSIZ - 1] = 0; if (ioctl(dev->fd_in, SIOCGIWRATE, &wrq) < 0) { return (-1); } return wrq.u.bitrate.value; } static int linux_set_mtu(struct wif * wi, int mtu) { struct priv_linux * dev = wi_priv(wi); struct ifreq ifr; memset(&ifr, 0, sizeof(struct ifreq)); if (dev->main_if) strncpy(ifr.ifr_name, dev->main_if, sizeof(ifr.ifr_name) - 1); else strncpy(ifr.ifr_name, wi_get_ifname(wi), sizeof(ifr.ifr_name) - 1); ifr.ifr_mtu = mtu; if (ioctl(dev->fd_in, SIOCSIFMTU, &ifr) < 0) { return (-1); } return 0; } static int linux_get_mtu(struct wif * wi) { struct priv_linux * dev = wi_priv(wi); struct ifreq ifr; memset(&ifr, 0, sizeof(struct ifreq)); if (dev->main_if) strncpy(ifr.ifr_name, dev->main_if, sizeof(ifr.ifr_name) - 1); else strncpy(ifr.ifr_name, wi_get_ifname(wi), sizeof(ifr.ifr_name) - 1); if (ioctl(dev->fd_in, SIOCGIFMTU, &ifr) < 0) { return (-1); } return ifr.ifr_mtu; } static int linux_read(struct wif * wi, struct timespec * ts, int * dlt, unsigned char * buf, int count, struct rx_info * ri) { struct priv_linux * dev = wi_priv(wi); unsigned char tmpbuf[4096] __attribute__((aligned(8))); int caplen, n, got_signal, got_noise, got_channel, fcs_removed; n = got_signal = got_noise = got_channel = fcs_removed = 0; if ((unsigned) count > sizeof(tmpbuf)) return (-1); if ((caplen = read(dev->fd_in, tmpbuf, count)) < 0) { if (errno == EAGAIN) return (0); perror("read failed"); return (-1); } switch (dev->drivertype) { case DT_MADWIFI: caplen -= 4; /* remove the FCS for madwifi-old! only (not -ng)*/ break; default: break; } memset(buf, 0, count); /* XXX */ if (ri) memset(ri, 0, sizeof(*ri)); if (dlt) { // TODO(jbenden): Future code could receive the actual linktype received. *dlt = LINKTYPE_IEEE802_11; } if (ts) { clock_gettime(CLOCK_REALTIME, ts); } if (dev->arptype_in == ARPHRD_IEEE80211_PRISM) { /* skip the prism header */ if (tmpbuf[7] == 0x40) { /* prism54 uses a different format */ if (ri) { ri->ri_power = (int32_t) load32_le(tmpbuf + 0x33); ri->ri_noise = (int32_t) load32_le(tmpbuf + 0x33 + 12); ri->ri_rate = load32_le(buf + 0x33 + 24) * 500000; got_signal = 1; got_noise = 1; } n = 0x40; } else { if (ri) { ri->ri_mactime = load64_le(tmpbuf + 0x5C - 48); ri->ri_channel = load32_le(tmpbuf + 0x5C - 36); ri->ri_power = (int32_t) load32_le(tmpbuf + 0x5C); ri->ri_noise = (int32_t) load32_le(tmpbuf + 0x5C + 12); ri->ri_rate = load32_le(tmpbuf + 0x5C + 24) * 500000; if (dev->drivertype == DT_MADWIFI || dev->drivertype == DT_MADWIFING) ri->ri_power -= (int32_t) load32_le(tmpbuf + 0x68); got_channel = 1; got_signal = 1; got_noise = 1; } n = load32_le(tmpbuf + 4); } if (n < 8 || n >= caplen) return (0); } if (dev->arptype_in == ARPHRD_IEEE80211_FULL) { struct ieee80211_radiotap_iterator iterator; struct ieee80211_radiotap_header * rthdr; rthdr = (struct ieee80211_radiotap_header *) tmpbuf; //-V1032 if (ieee80211_radiotap_iterator_init(&iterator, rthdr, caplen, NULL) < 0) return (0); /* go through the radiotap arguments we have been given * by the driver */ while (ri && (ieee80211_radiotap_iterator_next(&iterator) >= 0)) { switch (iterator.this_arg_index) { case IEEE80211_RADIOTAP_TSFT: ri->ri_mactime = le64_to_cpu(*((uint64_t *) iterator.this_arg)); break; case IEEE80211_RADIOTAP_DBM_ANTSIGNAL: if (!got_signal) { if (*iterator.this_arg < 127) ri->ri_power = *iterator.this_arg; else ri->ri_power = *iterator.this_arg - 255; got_signal = 1; } break; case IEEE80211_RADIOTAP_DB_ANTSIGNAL: if (!got_signal) { if (*iterator.this_arg < 127) ri->ri_power = *iterator.this_arg; else ri->ri_power = *iterator.this_arg - 255; got_signal = 1; } break; case IEEE80211_RADIOTAP_DBM_ANTNOISE: if (!got_noise) { if (*iterator.this_arg < 127) ri->ri_noise = *iterator.this_arg; else ri->ri_noise = *iterator.this_arg - 255; got_noise = 1; } break; case IEEE80211_RADIOTAP_DB_ANTNOISE: if (!got_noise) { if (*iterator.this_arg < 127) ri->ri_noise = *iterator.this_arg; else ri->ri_noise = *iterator.this_arg - 255; got_noise = 1; } break; case IEEE80211_RADIOTAP_ANTENNA: ri->ri_antenna = *iterator.this_arg; break; case IEEE80211_RADIOTAP_CHANNEL: ri->ri_channel = getChannelFromFrequency( le16toh(*(uint16_t *) iterator.this_arg)); got_channel = 1; break; case IEEE80211_RADIOTAP_RATE: ri->ri_rate = (*iterator.this_arg) * 500000; break; case IEEE80211_RADIOTAP_FLAGS: /* is the CRC visible at the end? * remove */ if (*iterator.this_arg & IEEE80211_RADIOTAP_F_FCS) { fcs_removed = 1; caplen -= 4; } if (*iterator.this_arg & IEEE80211_RADIOTAP_F_BADFCS) return (0); break; } } n = le16_to_cpu(rthdr->it_len); if (n <= 0 || n >= caplen) return (0); } caplen -= n; // detect fcs at the end, even if the flag wasn't set and remove it if (fcs_removed == 0 && check_crc_buf_osdep(tmpbuf + n, caplen - 4) == 1) { caplen -= 4; } memcpy(buf, tmpbuf + n, caplen); if (ri && !got_channel) ri->ri_channel = wi_get_channel(wi); return (caplen); } static int linux_write(struct wif * wi, struct timespec * ts, int dlt, unsigned char * buf, int count, struct tx_info * ti) { struct priv_linux * dev = wi_priv(wi); unsigned char maddr[6]; int ret, usedrtap = 0; unsigned char tmpbuf[4096]; unsigned char rate; unsigned short int * p_rtlen; unsigned char u8aRadiotap[] __attribute__((aligned(8))) = { 0x00, 0x00, // <-- radiotap version 0x0c, 0x00, // <- radiotap header length 0x04, 0x80, 0x00, 0x00, // <-- bitmap 0x00, // <-- rate 0x00, // <-- padding for natural alignment 0x18, 0x00, // <-- TX flags }; /* Pointer to the radiotap header length field for later use. */ p_rtlen = (unsigned short int *) (u8aRadiotap + 2); //-V1032 if ((unsigned) count > sizeof(tmpbuf) - 22) return -1; /* XXX honor ti */ if (ti) { } (void) ts; (void) dlt; rate = dev->rate; u8aRadiotap[8] = rate; switch (dev->drivertype) { case DT_MAC80211_RT: memcpy(tmpbuf, u8aRadiotap, sizeof(u8aRadiotap)); memcpy(tmpbuf + sizeof(u8aRadiotap), buf, count); count += sizeof(u8aRadiotap); buf = tmpbuf; usedrtap = 1; break; case DT_WLANNG: /* Wlan-ng isn't able to inject on kernel > 2.6.11 */ if (dev->inject_wlanng == 0) { perror("write failed"); return (-1); } if (count >= 24) { /* for some reason, wlan-ng requires a special header */ if ((((unsigned char *) buf)[1] & 3) != 3) { memcpy(tmpbuf, buf, 24); memset(tmpbuf + 24, 0, 22); tmpbuf[30] = (count - 24) & 0xFF; tmpbuf[31] = (count - 24) >> 8; memcpy(tmpbuf + 46, buf + 24, count - 24); count += 22; } else { memcpy(tmpbuf, buf, 30); memset(tmpbuf + 30, 0, 16); tmpbuf[30] = (count - 30) & 0xFF; tmpbuf[31] = (count - 30) >> 8; //-V610 memcpy(tmpbuf + 46, buf + 30, count - 30); count += 16; } buf = tmpbuf; } /* fall through */ case DT_HOSTAP: if ((((unsigned char *) buf)[1] & 3) == 2) { /* Prism2 firmware swaps the dmac and smac in FromDS packets */ memcpy(maddr, buf + 4, 6); memcpy(buf + 4, buf + 16, 6); memcpy(buf + 16, maddr, 6); } break; default: break; } ret = write(dev->fd_out, buf, count); if (ret < 0) { if (errno == EAGAIN || errno == EWOULDBLOCK || errno == ENOBUFS || errno == ENOMEM) { usleep(10000); return (0); } perror("write failed"); return (-1); } /* radiotap header length is stored little endian on all systems */ if (usedrtap) ret -= letoh16(*p_rtlen); if (ret < 0) { if (errno == EAGAIN || errno == EWOULDBLOCK || errno == ENOBUFS || errno == ENOMEM) { usleep(10000); return (0); } perror("write failed"); return (-1); } return (ret); } #if defined(CONFIG_LIBNL) static int ieee80211_channel_to_frequency(int chan) { if (chan < 14) return 2407 + chan * 5; if (chan == 14) return 2484; /* FIXME: dot11ChannelStartingFactor (802.11-2007 17.3.8.3.2) */ return (chan + 1000) * 5; } static int linux_set_ht_channel_nl80211(struct wif * wi, int channel, unsigned int htval) { struct priv_linux * dev = wi_priv(wi); char s[32]; int pid, status; unsigned int devid; struct nl_msg * msg; unsigned int freq; memset(s, 0, sizeof(s)); switch (dev->drivertype) { case DT_WLANNG: snprintf(s, sizeof(s) - 1, "channel=%d", channel); if ((pid = fork()) == 0) { close(0); close(1); close(2); IGNORE_NZ(chdir("/")); execl(dev->wlanctlng, "wlanctl-ng", wi_get_ifname(wi), "lnxreq_wlansniff", s, NULL); exit(1); } waitpid(pid, &status, 0); if (WIFEXITED(status)) { dev->channel = channel; return (WEXITSTATUS(status)); } else return (1); break; case DT_ORINOCO: snprintf(s, sizeof(s) - 1, "%d", channel); if ((pid = fork()) == 0) { close(0); close(1); close(2); IGNORE_NZ(chdir("/")); execlp(dev->iwpriv, "iwpriv", wi_get_ifname(wi), "monitor", "1", s, NULL); exit(1); } waitpid(pid, &status, 0); dev->channel = channel; return 0; break; // yeah ;) case DT_ZD1211RW: snprintf(s, sizeof(s) - 1, "%d", channel); if ((pid = fork()) == 0) { close(0); close(1); close(2); IGNORE_NZ(chdir("/")); execlp(dev->iwconfig, "iwconfig", wi_get_ifname(wi), "channel", s, NULL); exit(1); } waitpid(pid, &status, 0); dev->channel = channel; chan = channel; return 0; break; // yeah ;) default: break; } /* libnl stuff */ chan = channel; devid = if_nametoindex(wi->wi_interface); freq = ieee80211_channel_to_frequency(channel); msg = nlmsg_alloc(); if (!msg) { fprintf(stderr, "failed to allocate netlink message\n"); return 2; } genlmsg_put(msg, 0, 0, genl_family_get_id(state.nl80211), 0, 0, NL80211_CMD_SET_WIPHY, 0); NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, devid); NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_FREQ, freq); unsigned ht = NL80211_CHAN_NO_HT; switch (htval) { case CHANNEL_HT20: ht = NL80211_CHAN_HT20; break; case CHANNEL_HT40_PLUS: ht = NL80211_CHAN_HT40PLUS; break; case CHANNEL_HT40_MINUS: ht = NL80211_CHAN_HT40MINUS; break; } NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_CHANNEL_TYPE, ht); nl_send_auto_complete(state.nl_sock, msg); nlmsg_free(msg); dev->channel = channel; return (0); nla_put_failure: return -ENOBUFS; } static int linux_set_channel_nl80211(struct wif * wi, int channel) { return linux_set_ht_channel_nl80211(wi, channel, CHANNEL_NO_HT); } #else // CONFIG_LIBNL static int linux_set_channel(struct wif * wi, int channel) { struct priv_linux * dev = wi_priv(wi); char s[32]; int pid, status; struct iwreq wrq; memset(s, 0, sizeof(s)); switch (dev->drivertype) { case DT_WLANNG: snprintf(s, sizeof(s) - 1, "channel=%d", channel); if ((pid = fork()) == 0) { close(0); close(1); close(2); IGNORE_NZ(chdir("/")); execl(dev->wlanctlng, "wlanctl-ng", wi_get_ifname(wi), "lnxreq_wlansniff", s, NULL); exit(1); } waitpid(pid, &status, 0); if (WIFEXITED(status)) { dev->channel = channel; return (WEXITSTATUS(status)); } else return (1); break; case DT_ORINOCO: snprintf(s, sizeof(s) - 1, "%d", channel); if ((pid = fork()) == 0) { close(0); close(1); close(2); IGNORE_NZ(chdir("/")); execlp(dev->iwpriv, "iwpriv", wi_get_ifname(wi), "monitor", "1", s, NULL); exit(1); } waitpid(pid, &status, 0); dev->channel = channel; return 0; break; // yeah ;) case DT_ZD1211RW: snprintf(s, sizeof(s) - 1, "%d", channel); if ((pid = fork()) == 0) { close(0); close(1); close(2); IGNORE_NZ(chdir("/")); execlp(dev->iwconfig, "iwconfig", wi_get_ifname(wi), "channel", s, NULL); exit(1); } waitpid(pid, &status, 0); dev->channel = channel; return 0; break; // yeah ;) default: break; } memset(&wrq, 0, sizeof(struct iwreq)); strncpy(wrq.ifr_name, wi_get_ifname(wi), IFNAMSIZ); wrq.ifr_name[IFNAMSIZ - 1] = 0; wrq.u.freq.m = (double) channel; wrq.u.freq.e = (double) 0; if (ioctl(dev->fd_in, SIOCSIWFREQ, &wrq) < 0) { usleep(10000); /* madwifi needs a second chance */ if (ioctl(dev->fd_in, SIOCSIWFREQ, &wrq) < 0) { /* perror( "ioctl(SIOCSIWFREQ) failed" ); */ return (1); } } dev->channel = channel; return (0); } #endif static int linux_set_freq(struct wif * wi, int freq) { struct priv_linux * dev = wi_priv(wi); char s[32]; int pid, status; struct iwreq wrq; memset(s, 0, sizeof(s)); switch (dev->drivertype) { case DT_WLANNG: case DT_ORINOCO: case DT_ZD1211RW: snprintf(s, sizeof(s) - 1, "%dM", freq); if ((pid = fork()) == 0) { close(0); close(1); close(2); IGNORE_NZ(chdir("/")); execlp(dev->iwconfig, "iwconfig", wi_get_ifname(wi), "freq", s, NULL); exit(1); } waitpid(pid, &status, 0); dev->freq = freq; return 0; break; // yeah ;) default: break; } memset(&wrq, 0, sizeof(struct iwreq)); strncpy(wrq.ifr_name, wi_get_ifname(wi), IFNAMSIZ); wrq.ifr_name[IFNAMSIZ - 1] = 0; wrq.u.freq.m = (double) freq * 100000; wrq.u.freq.e = (double) 1; if (ioctl(dev->fd_in, SIOCSIWFREQ, &wrq) < 0) { usleep(10000); /* madwifi needs a second chance */ if (ioctl(dev->fd_in, SIOCSIWFREQ, &wrq) < 0) { /* perror( "ioctl(SIOCSIWFREQ) failed" ); */ return (1); } } dev->freq = freq; return (0); } static int opensysfs(struct priv_linux * dev, char * iface, int fd) { int fd2; char buf[256]; if (iface == NULL || strlen(iface) >= IFNAMSIZ) { return 1; } /* ipw2200 injection */ snprintf(buf, 256, "/sys/class/net/%s/device/inject", iface); fd2 = open(buf, O_WRONLY); /* bcm43xx injection */ if (fd2 == -1) { snprintf(buf, 256, "/sys/class/net/%s/device/inject_nofcs", iface); fd2 = open(buf, O_WRONLY); } if (fd2 == -1) return -1; dup2(fd2, fd); close(fd2); dev->sysfs_inject = 1; return 0; } static int linux_get_monitor(struct wif * wi) { struct priv_linux * dev = wi_priv(wi); struct ifreq ifr; struct iwreq wrq; /* find the interface index */ if (dev->drivertype == DT_IPW2200) return (0); memset(&ifr, 0, sizeof(ifr)); strncpy(ifr.ifr_name, wi_get_ifname(wi), sizeof(ifr.ifr_name) - 1); // if( ioctl( fd, SIOCGIFINDEX, &ifr ) < 0 ) // { // printf("Interface %s: \n", iface); // perror( "ioctl(SIOCGIFINDEX) failed" ); // return( 1 ); // } /* lookup the hardware type */ if (ioctl(wi_fd(wi), SIOCGIFHWADDR, &ifr) < 0) { printf("Interface %s: \n", wi_get_ifname(wi)); perror("ioctl(SIOCGIFHWADDR) failed"); return (1); } /* lookup iw mode */ memset(&wrq, 0, sizeof(struct iwreq)); strncpy(wrq.ifr_name, wi_get_ifname(wi), IFNAMSIZ); wrq.ifr_name[IFNAMSIZ - 1] = 0; if (ioctl(wi_fd(wi), SIOCGIWMODE, &wrq) < 0) { /* most probably not supported (ie for rtap ipw interface) * * so just assume its correctly set... */ wrq.u.mode = IW_MODE_MONITOR; } if ((ifr.ifr_hwaddr.sa_family != ARPHRD_IEEE80211 && ifr.ifr_hwaddr.sa_family != ARPHRD_IEEE80211_PRISM && ifr.ifr_hwaddr.sa_family != ARPHRD_IEEE80211_FULL) || (wrq.u.mode != IW_MODE_MONITOR && (dev->drivertype != DT_ORINOCO))) { return (1); } return (0); } __attribute__((unused)) static char * get_linux_driver(const char * iface) { char path[PATH_MAX]; char link[PATH_MAX]; if (iface == NULL || strlen(iface) >= IFNAMSIZ) { return NULL; } // Read the link path memset(path, 0, sizeof(path)); snprintf(path, sizeof(path), "/sys/class/net/%s/device/driver", iface); // Read the link path ssize_t len = readlink(path, link, sizeof(link)); if (len < 1 || len >= PATH_MAX) { return NULL; } memset(link + len, 0, sizeof(link) - len); // Get driver name const char * drv_idx = strrchr(link, '/'); if (drv_idx == NULL) { return NULL; } // Copy it to a new char * and return ssize_t drv_len = len - (drv_idx - link); if (drv_len <= 1) { return NULL; } char * ret = (char *) calloc(1, drv_len); // includes / if (ret == NULL) { return NULL; } memcpy(ret, drv_idx + 1, drv_len - 1); return ret; } static int set_monitor(struct priv_linux * dev, char * iface, int fd) { int pid, status; struct iwreq wrq; if (iface == NULL || strlen(iface) >= IFNAMSIZ) { return (1); } if (strcmp(iface, "prism0") == 0) { dev->wl = wiToolsPath("wl"); if ((pid = fork()) == 0) { close(0); close(1); close(2); IGNORE_NZ(chdir("/")); ALLEGE(dev->wl != NULL); execl(dev->wl, "wl", "monitor", "1", NULL); exit(1); } waitpid(pid, &status, 0); if (WIFEXITED(status)) return (WEXITSTATUS(status)); return (1); } else if (strncmp(iface, "rtap", 4) == 0) { return 0; } else { switch (dev->drivertype) { case DT_WLANNG: if ((pid = fork()) == 0) { close(0); close(1); close(2); IGNORE_NZ(chdir("/")); execl(dev->wlanctlng, "wlanctl-ng", iface, "lnxreq_wlansniff", "enable=true", "prismheader=true", "wlanheader=false", "stripfcs=true", "keepwepflags=true", "6", NULL); exit(1); } waitpid(pid, &status, 0); if (WIFEXITED(status)) return (WEXITSTATUS(status)); return (1); break; case DT_ORINOCO: if ((pid = fork()) == 0) { close(0); close(1); close(2); IGNORE_NZ(chdir("/")); execlp(dev->iwpriv, "iwpriv", iface, "monitor", "1", "1", NULL); exit(1); } waitpid(pid, &status, 0); if (WIFEXITED(status)) return (WEXITSTATUS(status)); return 1; break; case DT_ACX: if ((pid = fork()) == 0) { close(0); close(1); close(2); IGNORE_NZ(chdir("/")); execlp(dev->iwpriv, "iwpriv", iface, "monitor", "2", "1", NULL); exit(1); } waitpid(pid, &status, 0); if (WIFEXITED(status)) return (WEXITSTATUS(status)); return 1; break; default: break; } memset(&wrq, 0, sizeof(struct iwreq)); strncpy(wrq.ifr_name, iface, IFNAMSIZ); wrq.ifr_name[IFNAMSIZ - 1] = 0; wrq.u.mode = IW_MODE_MONITOR; if (ioctl(fd, SIOCSIWMODE, &wrq) < 0) { perror("ioctl(SIOCSIWMODE) failed"); return (1); } if (dev->drivertype == DT_AT76USB) { sleep(3); } } /* couple of iwprivs to enable the prism header */ if (!fork()) /* hostap */ { close(0); close(1); close(2); IGNORE_NZ(chdir("/")); execlp("iwpriv", "iwpriv", iface, "monitor_type", "1", NULL); exit(1); } wait(NULL); if (!fork()) /* r8180 */ { close(0); close(1); close(2); IGNORE_NZ(chdir("/")); execlp("iwpriv", "iwpriv", iface, "prismhdr", "1", NULL); exit(1); } wait(NULL); if (!fork()) /* prism54 */ { close(0); close(1); close(2); IGNORE_NZ(chdir("/")); execlp("iwpriv", "iwpriv", iface, "set_prismhdr", "1", NULL); exit(1); } wait(NULL); return (0); } static int openraw(struct priv_linux * dev, char * iface, int fd, int * arptype, unsigned char * mac) { REQUIRE(iface != NULL); struct ifreq ifr; struct ifreq ifr2; struct iwreq wrq; struct iwreq wrq2; struct packet_mreq mr; struct sockaddr_ll sll; struct sockaddr_ll sll2; if (strlen(iface) >= sizeof(ifr.ifr_name)) { printf("Interface name too long: %s\n", iface); return (1); } /* find the interface index */ memset(&ifr, 0, sizeof(ifr)); strncpy(ifr.ifr_name, iface, sizeof(ifr.ifr_name) - 1); if (ioctl(fd, SIOCGIFINDEX, &ifr) < 0) { printf("Interface %s: \n", iface); perror("ioctl(SIOCGIFINDEX) failed"); return (1); } memset(&sll, 0, sizeof(sll)); sll.sll_family = AF_PACKET; sll.sll_ifindex = ifr.ifr_ifindex; switch (dev->drivertype) { case DT_IPW2200: /* find the interface index */ if (dev->main_if == NULL) { perror("Missing interface name"); return 1; } memset(&ifr2, 0, sizeof(ifr)); strncpy(ifr2.ifr_name, dev->main_if, sizeof(ifr2.ifr_name) - 1); if (ioctl(dev->fd_main, SIOCGIFINDEX, &ifr2) < 0) { printf("Interface %s: \n", dev->main_if); perror("ioctl(SIOCGIFINDEX) failed"); return (1); } /* set iw mode to managed on main interface */ memset(&wrq2, 0, sizeof(struct iwreq)); strncpy(wrq2.ifr_name, dev->main_if, IFNAMSIZ); wrq2.ifr_name[IFNAMSIZ - 1] = 0; if (ioctl(dev->fd_main, SIOCGIWMODE, &wrq2) < 0) { perror("SIOCGIWMODE"); return 1; } wrq2.u.mode = IW_MODE_INFRA; if (ioctl(dev->fd_main, SIOCSIWMODE, &wrq2) < 0) { perror("SIOCSIWMODE"); return 1; } /* bind the raw socket to the interface */ memset(&sll2, 0, sizeof(sll2)); sll2.sll_family = AF_PACKET; sll2.sll_ifindex = ifr2.ifr_ifindex; sll2.sll_protocol = htons(ETH_P_ALL); if (bind(dev->fd_main, //-V641 (struct sockaddr *) &sll2, //-V641 sizeof(sll2)) //-V641 < 0) { printf("Interface %s: \n", dev->main_if); perror("bind(ETH_P_ALL) failed"); return (1); } opensysfs(dev, dev->main_if, dev->fd_in); break; case DT_BCM43XX: opensysfs(dev, iface, dev->fd_in); break; case DT_WLANNG: sll.sll_protocol = htons(ETH_P_80211_RAW); break; default: sll.sll_protocol = htons(ETH_P_ALL); break; } /* lookup the hardware type */ if (ioctl(fd, SIOCGIFHWADDR, &ifr) < 0) { printf("Interface %s: \n", iface); perror("ioctl(SIOCGIFHWADDR) failed"); return (1); } /* lookup iw mode */ memset(&wrq, 0, sizeof(struct iwreq)); strncpy(wrq.ifr_name, iface, IFNAMSIZ); wrq.ifr_name[IFNAMSIZ - 1] = 0; if (ioctl(fd, SIOCGIWMODE, &wrq) < 0) { /* most probably not supported (ie for rtap ipw interface) * * so just assume its correctly set... */ wrq.u.mode = IW_MODE_MONITOR; } if ((ifr.ifr_hwaddr.sa_family != ARPHRD_IEEE80211 && ifr.ifr_hwaddr.sa_family != ARPHRD_IEEE80211_PRISM && ifr.ifr_hwaddr.sa_family != ARPHRD_IEEE80211_FULL) || (wrq.u.mode != IW_MODE_MONITOR)) { if (set_monitor(dev, iface, fd) && dev->drivertype != DT_ORINOCO) { ifr.ifr_flags &= ~(IFF_UP | IFF_BROADCAST | IFF_RUNNING); if (ioctl(fd, SIOCSIFFLAGS, &ifr) < 0) { perror("ioctl(SIOCSIFFLAGS) failed"); return (1); } if (set_monitor(dev, iface, fd)) { printf("Error setting monitor mode on %s\n", iface); return (1); } } } /* Is interface st to up, broadcast & running ? */ if ((ifr.ifr_flags | IFF_UP | IFF_BROADCAST | IFF_RUNNING) != ifr.ifr_flags) { /* Bring interface up*/ ifr.ifr_flags |= IFF_UP | IFF_BROADCAST | IFF_RUNNING; if (ioctl(fd, SIOCSIFFLAGS, &ifr) < 0) { perror("ioctl(SIOCSIFFLAGS) failed"); return (1); } } /* bind the raw socket to the interface */ if (bind(fd, (struct sockaddr *) &sll, sizeof(sll)) < 0) //-V641 { printf("Interface %s: \n", iface); perror("bind(ETH_P_ALL) failed"); return (1); } /* lookup the hardware type */ if (ioctl(fd, SIOCGIFHWADDR, &ifr) < 0) { printf("Interface %s: \n", iface); perror("ioctl(SIOCGIFHWADDR) failed"); return (1); } memcpy(mac, (unsigned char *) ifr.ifr_hwaddr.sa_data, 6); //-V512 *arptype = ifr.ifr_hwaddr.sa_family; if (ifr.ifr_hwaddr.sa_family != ARPHRD_IEEE80211 && ifr.ifr_hwaddr.sa_family != ARPHRD_IEEE80211_PRISM && ifr.ifr_hwaddr.sa_family != ARPHRD_IEEE80211_FULL) { if (ifr.ifr_hwaddr.sa_family == ARPHRD_ETHERNET) fprintf(stderr, "\nARP linktype is set to 1 (Ethernet) "); else fprintf(stderr, "\nUnsupported hardware link type %4d ", ifr.ifr_hwaddr.sa_family); fprintf(stderr, "- expected ARPHRD_IEEE80211,\nARPHRD_IEEE80211_" "FULL or ARPHRD_IEEE80211_PRISM instead. Make\n" "sure RFMON is enabled: run 'airmon-ng start %s" " <#>'\nSysfs injection support was not found " "either.\n\n", iface); return (1); } /* enable promiscuous mode */ memset(&mr, 0, sizeof(mr)); mr.mr_ifindex = sll.sll_ifindex; mr.mr_type = PACKET_MR_PROMISC; if (setsockopt(fd, SOL_PACKET, PACKET_ADD_MEMBERSHIP, &mr, sizeof(mr)) < 0) { perror("setsockopt(PACKET_MR_PROMISC) failed"); return (1); } return (0); } /* * Open the interface and set mode monitor * Return 1 on failure and 0 on success */ static int do_linux_open(struct wif * wi, char * iface) { int kver; struct utsname checklinuxversion; struct priv_linux * dev = wi_priv(wi); char * iwpriv = NULL; char strbuf[512]; FILE * f; char athXraw[] = "athXraw"; pid_t pid; int n; DIR * net_ifaces; struct dirent * this_iface; FILE * acpi = NULL; char buf[128]; char * r_file = NULL; struct ifreq ifr; int iface_malloced = 0; if (iface == NULL || strlen(iface) >= IFNAMSIZ) { return (1); } dev->inject_wlanng = 1; dev->rate = 2; /* default to 1Mbps if nothing is set */ /* open raw socks */ if ((dev->fd_in = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL))) < 0) { perror("socket(PF_PACKET) failed"); if (getuid() != 0) fprintf(stderr, "This program requires root privileges.\n"); return (1); } if ((dev->fd_main = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL))) < 0) { perror("socket(PF_PACKET) failed"); if (getuid() != 0) fprintf(stderr, "This program requires root privileges.\n"); return (1); } /* Check iwpriv existence */ iwpriv = wiToolsPath("iwpriv"); #ifndef CONFIG_LIBNL dev->iwpriv = iwpriv; dev->iwconfig = wiToolsPath("iwconfig"); dev->ifconfig = wiToolsPath("ifconfig"); if (!iwpriv) { fprintf(stderr, "Required wireless tools when compiled without libnl " "could not be found, exiting.\n"); goto close_in; } #endif /* Exit if ndiswrapper : check iwpriv ndis_reset */ if (is_ndiswrapper(iface, iwpriv)) { fprintf(stderr, "Ndiswrapper doesn't support monitor mode.\n"); goto close_in; } if ((dev->fd_out = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL))) < 0) { perror("socket(PF_PACKET) failed"); goto close_in; } /* figure out device type */ /* mac80211 radiotap injection * detected based on interface called mon... * since mac80211 allows multiple virtual interfaces * * note though that the virtual interfaces are ultimately using a * single physical radio: that means for example they must all * operate on the same channel */ /* mac80211 stack detection */ memset(strbuf, 0, sizeof(strbuf)); snprintf(strbuf, sizeof(strbuf) - 1, "ls /sys/class/net/%s/phy80211/subsystem >/dev/null 2>/dev/null", iface); if (system(strbuf) == 0) dev->drivertype = DT_MAC80211_RT; /* IPW2200 detection */ memset(strbuf, 0, sizeof(strbuf)); snprintf(strbuf, sizeof(strbuf) - 1, "ls /sys/class/net/%s/device/inject >/dev/null 2>/dev/null", iface); if (system(strbuf) == 0) dev->drivertype = DT_IPW2200; /* BCM43XX detection */ memset(strbuf, 0, sizeof(strbuf)); snprintf(strbuf, sizeof(strbuf) - 1, "ls /sys/class/net/%s/device/inject_nofcs >/dev/null 2>/dev/null", iface); if (system(strbuf) == 0) dev->drivertype = DT_BCM43XX; /* check if wlan-ng or hostap or r8180 */ if (strlen(iface) == 5 && memcmp(iface, "wlan", 4) == 0) { memset(strbuf, 0, sizeof(strbuf)); snprintf(strbuf, sizeof(strbuf) - 1, "wlancfg show %s 2>/dev/null | " "grep p2CnfWEPFlags >/dev/null", iface); if (system(strbuf) == 0) { if (uname(&checklinuxversion) >= 0) { /* uname succeeded */ if (strncmp(checklinuxversion.release, "2.6.", 4) == 0 && strncasecmp(checklinuxversion.sysname, "linux", 5) == 0) { /* Linux kernel 2.6 */ kver = atoi(checklinuxversion.release + 4); if (kver > 11) { /* That's a kernel > 2.6.11, cannot inject */ dev->inject_wlanng = 0; } } } dev->drivertype = DT_WLANNG; dev->wlanctlng = wiToolsPath("wlanctl-ng"); } memset(strbuf, 0, sizeof(strbuf)); snprintf(strbuf, sizeof(strbuf) - 1, "iwpriv %s 2>/dev/null | " "grep antsel_rx >/dev/null", iface); if (system(strbuf) == 0) dev->drivertype = DT_HOSTAP; memset(strbuf, 0, sizeof(strbuf)); snprintf(strbuf, sizeof(strbuf) - 1, "iwpriv %s 2>/dev/null | " "grep GetAcx111Info >/dev/null", iface); if (system(strbuf) == 0) dev->drivertype = DT_ACX; } /* enable injection on ralink */ if (strcmp(iface, "ra0") == 0 || strcmp(iface, "ra1") == 0 || strcmp(iface, "rausb0") == 0 || strcmp(iface, "rausb1") == 0) { memset(strbuf, 0, sizeof(strbuf)); snprintf(strbuf, sizeof(strbuf) - 1, "iwpriv %s rfmontx 1 >/dev/null 2>/dev/null", iface); IGNORE_NZ(system(strbuf)); } /* check if newer athXraw interface available */ if ((strlen(iface) >= 4 && strlen(iface) <= 6) && memcmp(iface, "ath", 3) == 0) { dev->drivertype = DT_MADWIFI; memset(strbuf, 0, sizeof(strbuf)); snprintf( strbuf, sizeof(strbuf) - 1, "/proc/sys/net/%s/%%parent", iface); f = fopen(strbuf, "r"); if (f != NULL) { // It is madwifi-ng dev->drivertype = DT_MADWIFING; fclose(f); /* should we force prism2 header? */ sprintf((char *) strbuf, "/proc/sys/net/%s/dev_type", iface); f = fopen((char *) strbuf, "w"); if (f != NULL) { fprintf(f, "802\n"); fclose(f); } /* Force prism2 header on madwifi-ng */ } else { // Madwifi-old memset(strbuf, 0, sizeof(strbuf)); snprintf(strbuf, sizeof(strbuf) - 1, "sysctl -w dev.%s.rawdev=1 >/dev/null 2>/dev/null", iface); if (system(strbuf) == 0) { athXraw[3] = iface[3]; memset(strbuf, 0, sizeof(strbuf)); snprintf(strbuf, sizeof(strbuf) - 1, "ifconfig %s up", athXraw); IGNORE_NZ(system(strbuf)); #if 0 /* some people reported problems when prismheader is enabled */ memset( strbuf, 0, sizeof( strbuf ) ); snprintf( strbuf, sizeof( strbuf ) - 1, "sysctl -w dev.%s.rawdev_type=1 >/dev/null 2>/dev/null", iface ); IGNORE_NZ(system( strbuf )); #endif iface = athXraw; } } } /* test if orinoco */ if (memcmp(iface, "eth", 3) == 0) { if ((pid = fork()) == 0) { close(0); close(1); close(2); IGNORE_NZ(chdir("/")); execlp("iwpriv", "iwpriv", iface, "get_port3", NULL); exit(1); } waitpid(pid, &n, 0); if (WIFEXITED(n) && WEXITSTATUS(n) == 0) dev->drivertype = DT_ORINOCO; memset(strbuf, 0, sizeof(strbuf)); snprintf(strbuf, sizeof(strbuf) - 1, "iwpriv %s 2>/dev/null | " "grep get_scan_times >/dev/null", iface); if (system(strbuf) == 0) dev->drivertype = DT_AT76USB; } /* test if zd1211rw */ if (memcmp(iface, "eth", 3) == 0) { if ((pid = fork()) == 0) { close(0); close(1); close(2); IGNORE_NZ(chdir("/")); execlp("iwpriv", "iwpriv", iface, "get_regdomain", NULL); exit(1); } waitpid(pid, &n, 0); if (WIFEXITED(n) && WEXITSTATUS(n) == 0) dev->drivertype = DT_ZD1211RW; } if (dev->drivertype == DT_IPW2200) { r_file = (char *) calloc(33 + strlen(iface) + 1, sizeof(char)); if (!r_file) { goto close_out; } snprintf(r_file, 33 + strlen(iface) + 1, "/sys/class/net/%s/device/rtap_iface", iface); if ((acpi = fopen(r_file, "r")) == NULL) goto close_out; memset(buf, 0, 128); IGNORE_ZERO(fgets(buf, 128, acpi)); buf[127] = '\x00'; // rtap iface doesn't exist if (strncmp(buf, "-1", 2) == 0) { // repoen for writing fclose(acpi); if ((acpi = fopen(r_file, "w")) == NULL) goto close_out; fputs("1", acpi); // reopen for reading fclose(acpi); if ((acpi = fopen(r_file, "r")) == NULL) goto close_out; IGNORE_ZERO(fgets(buf, 128, acpi)); } fclose(acpi); acpi = NULL; // use name in buf as new iface and set original iface as main iface dev->main_if = (char *) malloc(strlen(iface) + 1); if (dev->main_if == NULL) goto close_out; memset(dev->main_if, 0, strlen(iface) + 1); strncpy(dev->main_if, iface, strlen(iface)); iface = (char *) malloc(strlen(buf) + 1); if (iface == NULL) goto close_out; iface_malloced = 1; memset(iface, 0, strlen(buf) + 1); strncpy(iface, buf, strlen(buf)); } /* test if rtap interface and try to find real interface */ if (memcmp(iface, "rtap", 4) == 0 && dev->main_if == NULL) { memset(&ifr, 0, sizeof(ifr)); strncpy(ifr.ifr_name, iface, sizeof(ifr.ifr_name) - 1); n = 0; if (ioctl(dev->fd_out, SIOCGIFINDEX, &ifr) < 0) { // create rtap interface n = 1; } net_ifaces = opendir("/sys/class/net"); while (net_ifaces != NULL && (this_iface = readdir(net_ifaces)) != NULL) { if (this_iface->d_name[0] == '.') continue; char * new_r_file = (char *) realloc( r_file, (33 + strlen(this_iface->d_name) + 1) * sizeof(char)); if (!new_r_file) { continue; } r_file = new_r_file; snprintf(r_file, 33 + strlen(this_iface->d_name) + 1, "/sys/class/net/%s/device/rtap_iface", this_iface->d_name); if ((acpi = fopen(r_file, "r")) == NULL) continue; dev->drivertype = DT_IPW2200; memset(buf, 0, 128); IGNORE_ZERO(fgets(buf, 128, acpi)); if (n == 0) // interface exists { if (strncmp(buf, iface, 5) == 0) { fclose(acpi); acpi = NULL; closedir(net_ifaces); net_ifaces = NULL; dev->main_if = (char *) malloc(strlen(this_iface->d_name) + 1); if (dev->main_if == NULL) continue; strcpy(dev->main_if, this_iface->d_name); break; } } else // need to create interface { if (strncmp(buf, "-1", 2) == 0) { // repoen for writing fclose(acpi); if ((acpi = fopen(r_file, "w")) == NULL) continue; fputs("1", acpi); // reopen for reading fclose(acpi); if ((acpi = fopen(r_file, "r")) == NULL) continue; IGNORE_ZERO(fgets(buf, 128, acpi)); if (strncmp(buf, iface, 5) == 0) { closedir(net_ifaces); net_ifaces = NULL; dev->main_if = (char *) malloc(strlen(this_iface->d_name) + 1); if (dev->main_if == NULL) continue; strcpy(dev->main_if, this_iface->d_name); fclose(acpi); acpi = NULL; break; } } } fclose(acpi); acpi = NULL; } if (net_ifaces != NULL) closedir(net_ifaces); } if (openraw(dev, iface, dev->fd_out, &dev->arptype_out, dev->pl_mac) != 0) { goto close_out; } /* don't use the same file descriptor for in and out on bcm43xx, as you read from the interface, but write into a file in /sys/... */ if (!(dev->drivertype == DT_BCM43XX) && !(dev->drivertype == DT_IPW2200)) { close(dev->fd_in); dev->fd_in = dev->fd_out; } else { /* if bcm43xx or ipw2200, swap both fds */ n = dev->fd_out; dev->fd_out = dev->fd_in; dev->fd_in = n; } dev->arptype_in = dev->arptype_out; if (iface_malloced) free(iface); if (iwpriv) free(iwpriv); if (r_file) { free(r_file); } return 0; close_out: close(dev->fd_out); if (r_file) { free(r_file); } close_in: close(dev->fd_in); if (acpi) fclose(acpi); if (iface_malloced) free(iface); if (iwpriv) free(iwpriv); return 1; } static void do_free(struct wif * wi) { struct priv_linux * pl = wi_priv(wi); if (pl->wlanctlng) free(pl->wlanctlng); if (pl->iwpriv) free(pl->iwpriv); if (pl->iwconfig) free(pl->iwconfig); if (pl->ifconfig) free(pl->ifconfig); if (pl->wl) free(pl->wl); if (pl->main_if) free(pl->main_if); free(pl); free(wi); } #ifndef CONFIG_LIBNL static void linux_close(struct wif * wi) { struct priv_linux * pl = wi_priv(wi); if (pl->fd_in && pl->fd_out && pl->fd_in == pl->fd_out) { // Only close one if both are the same close(pl->fd_in); } else { if (pl->fd_in) close(pl->fd_in); if (pl->fd_out) close(pl->fd_out); } if (pl->fd_main) close(pl->fd_main); do_free(wi); } #else static void linux_close_nl80211(struct wif * wi) { struct priv_linux * pl = wi_priv(wi); nl80211_cleanup(&state); if (pl->fd_in) close(pl->fd_in); if (pl->fd_out) close(pl->fd_out); do_free(wi); } #endif static int linux_fd(struct wif * wi) { struct priv_linux * pl = wi_priv(wi); return pl->fd_in; } static int linux_get_mac(struct wif * wi, unsigned char * mac) { struct priv_linux * pl = wi_priv(wi); struct ifreq ifr; int fd; fd = wi_fd(wi); /* find the interface index */ /* ipw2200 got a file opened as fd */ if (pl->drivertype == DT_IPW2200) { memcpy(mac, pl->pl_mac, 6); return 0; } memset(&ifr, 0, sizeof(ifr)); strncpy(ifr.ifr_name, wi_get_ifname(wi), sizeof(ifr.ifr_name) - 1); if (ioctl(fd, SIOCGIFINDEX, &ifr) < 0) { printf("Interface %s: \n", wi_get_ifname(wi)); perror("ioctl(SIOCGIFINDEX) failed"); return (1); } if (ioctl(fd, SIOCGIFHWADDR, &ifr) < 0) { printf("Interface %s: \n", wi_get_ifname(wi)); perror("ioctl(SIOCGIFHWADDR) failed"); return (1); } memcpy(pl->pl_mac, (unsigned char *) ifr.ifr_hwaddr.sa_data, 6); /* XXX */ memcpy(mac, pl->pl_mac, 6); return 0; } static int linux_set_mac(struct wif * wi, unsigned char * mac) { struct priv_linux * pl = wi_priv(wi); struct ifreq ifr; int fd, ret; fd = wi_fd(wi); /* find the interface index */ memset(&ifr, 0, sizeof(ifr)); strncpy(ifr.ifr_name, wi_get_ifname(wi), sizeof(ifr.ifr_name) - 1); if (ioctl(fd, SIOCGIFHWADDR, &ifr) < 0) { printf("Interface %s: \n", wi_get_ifname(wi)); perror("ioctl(SIOCGIFHWADDR) failed"); return (1); } // if down ifr.ifr_flags &= ~(IFF_UP | IFF_BROADCAST | IFF_RUNNING); if (ioctl(fd, SIOCSIFFLAGS, &ifr) < 0) { perror("ioctl(SIOCSIFFLAGS) failed"); return (1); } ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER; memcpy(ifr.ifr_hwaddr.sa_data, mac, 6); //-V512 memcpy(pl->pl_mac, mac, 6); // set mac ret = ioctl(fd, SIOCSIFHWADDR, &ifr); // if up ifr.ifr_flags |= IFF_UP | IFF_BROADCAST | IFF_RUNNING; if (ioctl(fd, SIOCSIFFLAGS, &ifr) < 0) { perror("ioctl(SIOCSIFFLAGS) failed"); return (1); } return ret; } static struct wif * linux_open(char * iface) { struct wif * wi; struct priv_linux * pl; if (iface == NULL || strlen(iface) >= IFNAMSIZ) { return NULL; } wi = wi_alloc(sizeof(*pl)); if (!wi) return NULL; wi->wi_read = linux_read; wi->wi_write = linux_write; #ifdef CONFIG_LIBNL linux_nl80211_init(&state); wi->wi_set_ht_channel = linux_set_ht_channel_nl80211; wi->wi_set_channel = linux_set_channel_nl80211; #else wi->wi_set_channel = linux_set_channel; #endif // CONFIG_LIBNL wi->wi_get_channel = linux_get_channel; wi->wi_set_freq = linux_set_freq; wi->wi_get_freq = linux_get_freq; #ifdef CONFIG_LIBNL wi->wi_close = linux_close_nl80211; #else wi->wi_close = linux_close; #endif wi->wi_fd = linux_fd; wi->wi_get_mac = linux_get_mac; wi->wi_set_mac = linux_set_mac; wi->wi_get_monitor = linux_get_monitor; wi->wi_get_rate = linux_get_rate; wi->wi_set_rate = linux_set_rate; wi->wi_get_mtu = linux_get_mtu; wi->wi_set_mtu = linux_set_mtu; if (do_linux_open(wi, iface)) { do_free(wi); return NULL; } return wi; } struct wif * wi_open_osdep(char * iface) { return linux_open(iface); } EXPORT int get_battery_state(void) { char buf[128]; int batteryTime = 0; FILE * apm; unsigned flag; char units[32]; int ret; static int linux_apm = 1; static int linux_acpi = 1; if (linux_apm == 1) { char * battery_data = NULL; if ((apm = fopen("/proc/apm", "r")) != NULL) { battery_data = fgets(buf, 128, apm); fclose(apm); } if (battery_data != NULL) { unsigned charging, ac; ret = sscanf(battery_data, "%*s %*d.%*d %*x %x %x %x %*d%% %d %31s\n", &ac, &charging, &flag, &batteryTime, units); if (!ret) return 0; if ((flag & 0x80) == 0 && charging != 0xFF && ac != 1 && batteryTime == -1) { if (!strncmp(units, "min", 3)) batteryTime *= 60; } else return 0; linux_acpi = 0; return batteryTime; } linux_apm = 0; } if (linux_acpi && !linux_apm) { DIR *batteries, *ac_adapters; struct dirent *this_battery, *this_adapter; FILE *acpi, *info; char battery_state[28 + sizeof(this_adapter->d_name) + 1]; char battery_info[24 + sizeof(this_battery->d_name) + 1]; int rate = 1, remain = 0; static int total_remain = 0, total_cap = 0; int batno = 0; static int info_timer = 0; int batt_full_capacity[3]; linux_apm = 0; linux_acpi = 1; ac_adapters = opendir("/proc/acpi/ac_adapter"); if (ac_adapters == NULL) return 0; while ((this_adapter = readdir(ac_adapters)) != NULL) { if (this_adapter->d_name[0] == '.') { continue; } /* safe overloaded use of battery_state path var */ snprintf(battery_state, sizeof(battery_state), "/proc/acpi/ac_adapter/%s/state", this_adapter->d_name); if ((acpi = fopen(battery_state, "r")) == NULL) { continue; } while (fgets(buf, 128, acpi)) { if (strstr(buf, "on-line") != NULL) { fclose(acpi); closedir(ac_adapters); return 0; } } fclose(acpi); } closedir(ac_adapters); batteries = opendir("/proc/acpi/battery"); if (batteries == NULL) { return 0; } while ((this_battery = readdir(batteries)) != NULL) { if (this_battery->d_name[0] == '.') continue; snprintf(battery_info, sizeof(battery_info), "/proc/acpi/battery/%s/info", this_battery->d_name); info = fopen(battery_info, "r"); batt_full_capacity[batno] = 0; if (info != NULL) { while (fgets(buf, sizeof(buf), info) != NULL) if (sscanf(buf, "last full capacity: %d mWh", &batt_full_capacity[batno]) == 1) continue; fclose(info); } snprintf(battery_state, sizeof(battery_state), "/proc/acpi/battery/%s/state", this_battery->d_name); if ((acpi = fopen(battery_state, "r")) == NULL) continue; while (fgets(buf, 128, acpi)) { if (strncmp(buf, "present:", 8) == 0) { /* No information for this battery */ if (strstr(buf, "no")) continue; } else if (strncmp(buf, "charging state:", 15) == 0) { /* the space makes it different than discharging */ if (strstr(buf, " charging")) { closedir(batteries); fclose(acpi); return 0; } } else if (strncmp(buf, "present rate:", 13) == 0) rate = atoi(buf + 25); else if (strncmp(buf, "remaining capacity:", 19) == 0) { remain = atoi(buf + 25); total_remain += remain; } } total_cap += batt_full_capacity[batno]; fclose(acpi); batteryTime += (int) ((((float) remain) / rate) * 3600); batno++; } info_timer++; closedir(batteries); } return batteryTime; } aircrack-ng-1.6/lib/osdep/linux_tap.c000066400000000000000000000112411361312141100175600ustar00rootroot00000000000000/* * Copyright (c) 2007, 2008, Andrea Bittau * * OS dependent API for Linux. TAP routines * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "osdep.h" struct tip_linux { int tl_fd; struct ifreq tl_ifr; int tl_ioctls; char tl_name[MAX_IFACE_NAME]; }; static int ti_do_open_linux(struct tif * ti, char * name) { int fd_tap; struct ifreq if_request; struct tip_linux * priv = ti_priv(ti); fd_tap = open(name ? name : "/dev/net/tun", O_RDWR); if (fd_tap < 0) { printf("error opening tap device: %s\n", strerror(errno)); printf("try \"modprobe tun\"\n"); return -1; } memset(&if_request, 0, sizeof(if_request)); if_request.ifr_flags = IFF_TAP | IFF_NO_PI; strncpy(if_request.ifr_name, "at%d", IFNAMSIZ); if (ioctl(fd_tap, TUNSETIFF, (void *) &if_request) < 0) { printf("error creating tap interface: %s\n", strerror(errno)); close(fd_tap); return -1; } strncpy(priv->tl_name, if_request.ifr_name, MAX_IFACE_NAME); strncpy(priv->tl_ifr.ifr_name, priv->tl_name, sizeof(priv->tl_ifr.ifr_name) - 1); if ((priv->tl_ioctls = socket(PF_INET, SOCK_DGRAM, 0)) == -1) { priv->tl_ioctls = 0; close(fd_tap); return -1; } return fd_tap; } static void ti_do_free(struct tif * ti) { struct tip_fbsd * priv = ti_priv(ti); free(priv); free(ti); } static void ti_close_linux(struct tif * ti) { struct tip_linux * priv = ti_priv(ti); close(priv->tl_fd); close(priv->tl_ioctls); ti_do_free(ti); } static char * ti_name_linux(struct tif * ti) { struct tip_linux * priv = ti_priv(ti); return priv->tl_name; } static int ti_set_mtu_linux(struct tif * ti, int mtu) { struct tip_linux * priv = ti_priv(ti); priv->tl_ifr.ifr_mtu = mtu; return ioctl(priv->tl_ioctls, SIOCSIFMTU, &priv->tl_ifr); } static int ti_get_mtu_linux(struct tif * ti) { int mtu; struct tip_linux * priv = ti_priv(ti); if (ioctl(priv->tl_ioctls, SIOCSIFMTU, &priv->tl_ifr) != -1) { mtu = priv->tl_ifr.ifr_mtu; } else { mtu = 1500; } return mtu; } static int ti_set_mac_linux(struct tif * ti, unsigned char * mac) { struct tip_linux * priv = ti_priv(ti); memcpy(priv->tl_ifr.ifr_hwaddr.sa_data, mac, 6); //-V512 priv->tl_ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER; return ioctl(priv->tl_ioctls, SIOCSIFHWADDR, &priv->tl_ifr); } static int ti_set_ip_linux(struct tif * ti, struct in_addr * ip) { struct tip_linux * priv = ti_priv(ti); struct sockaddr_in * s_in; s_in = (struct sockaddr_in *) &priv->tl_ifr.ifr_addr; s_in->sin_family = AF_INET; s_in->sin_addr = *ip; return ioctl(priv->tl_ioctls, SIOCSIFADDR, &priv->tl_ifr); } static int ti_fd_linux(struct tif * ti) { struct tip_linux * priv = ti_priv(ti); return priv->tl_fd; } static int ti_read_linux(struct tif * ti, void * buf, int len) { return read(ti_fd(ti), buf, len); } static int ti_write_linux(struct tif * ti, void * buf, int len) { return write(ti_fd(ti), buf, len); } static struct tif * ti_open_linux(char * iface) { struct tif * ti; struct tip_linux * priv; int fd; /* setup ti struct */ ti = ti_alloc(sizeof(*priv)); if (!ti) return NULL; ti->ti_name = ti_name_linux; ti->ti_set_mtu = ti_set_mtu_linux; ti->ti_get_mtu = ti_get_mtu_linux; ti->ti_close = ti_close_linux; ti->ti_fd = ti_fd_linux; ti->ti_read = ti_read_linux; ti->ti_write = ti_write_linux; ti->ti_set_mac = ti_set_mac_linux; ti->ti_set_ip = ti_set_ip_linux; /* setup iface */ fd = ti_do_open_linux(ti, iface); if (fd == -1) { ti_do_free(ti); return NULL; } /* setup private state */ priv = ti_priv(ti); priv->tl_fd = fd; return ti; } EXPORT struct tif * ti_open(char * iface) { return ti_open_linux(iface); } aircrack-ng-1.6/lib/osdep/netbsd.c000066400000000000000000000273521361312141100170460ustar00rootroot00000000000000/* * Copyright (c) 2007, 2008, Andrea Bittau * * OS dependent API for NetBSD. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "osdep.h" #ifndef LINKTYPE_IEEE802_11 #define LINKTYPE_IEEE802_11 105 #endif #ifndef IEEE80211_RADIOTAP_F_FCS #define IEEE80211_RADIOTAP_F_FCS 0x10 /* Frame includes FCS */ #endif #ifndef IEEE80211_IOC_CHANNEL #define IEEE80211_IOC_CHANNEL 0 #endif #ifndef le32toh #define le32toh(x) htole32(x) #endif struct priv_nbsd { /* iface */ int pn_fd; /* rx */ int pn_nocrc; /* tx */ unsigned char pn_buf[4096]; unsigned char * pn_next; int pn_totlen; /* setchan */ int pn_s; struct ifreq pn_ifr; struct ieee80211chanreq pn_ireq; int pn_chan; }; static void get_radiotap_info(struct priv_nbsd * pn, struct ieee80211_radiotap_header * rth, int * plen, struct rx_info * ri) { uint32_t present; uint8_t rflags = 0; int i; unsigned char * body = (unsigned char *) (rth + 1); int dbm_power = 0, db_power = 0; /* reset control info */ if (ri) memset(ri, 0, sizeof(*ri)); /* get info */ present = le32toh(rth->it_present); for (i = IEEE80211_RADIOTAP_TSFT; i <= IEEE80211_RADIOTAP_EXT; i++) { if (!(present & (1 << i))) continue; switch (i) { case IEEE80211_RADIOTAP_TSFT: body += sizeof(uint64_t); break; case IEEE80211_RADIOTAP_FLAGS: rflags = *((uint8_t *) body); /* fall through */ case IEEE80211_RADIOTAP_RATE: body += sizeof(uint8_t); break; case IEEE80211_RADIOTAP_CHANNEL: if (ri) { ri->ri_channel = 1; } body += sizeof(uint16_t) * 2; break; case IEEE80211_RADIOTAP_FHSS: body += sizeof(uint16_t); break; case IEEE80211_RADIOTAP_DBM_ANTSIGNAL: dbm_power = *body++; break; case IEEE80211_RADIOTAP_DBM_ANTNOISE: dbm_power -= *body++; break; case IEEE80211_RADIOTAP_DB_ANTSIGNAL: db_power = *body++; break; case IEEE80211_RADIOTAP_DB_ANTNOISE: db_power -= *body++; break; default: i = IEEE80211_RADIOTAP_EXT + 1; break; } } /* set power */ if (ri) { if (dbm_power) ri->ri_power = dbm_power; else ri->ri_power = db_power; } /* XXX cache; drivers won't change this per-packet */ /* check if FCS/CRC is included in packet */ if (pn->pn_nocrc || (rflags & IEEE80211_RADIOTAP_F_FCS)) { *plen -= IEEE80211_CRC_LEN; pn->pn_nocrc = 1; } } static unsigned char * get_80211(struct priv_nbsd * pn, int * plen, struct rx_info * ri) { struct bpf_hdr * bpfh; struct ieee80211_radiotap_header * rth; void * ptr; unsigned char ** data; int * totlen; data = &pn->pn_next; totlen = &pn->pn_totlen; assert(*totlen); /* bpf hdr */ bpfh = (struct bpf_hdr *) (*data); assert(bpfh->bh_caplen == bpfh->bh_datalen); /* XXX */ *totlen -= bpfh->bh_hdrlen; /* check if more packets */ if ((int) bpfh->bh_caplen < *totlen) { int tot = bpfh->bh_hdrlen + bpfh->bh_caplen; int offset = BPF_WORDALIGN(tot); *data = (unsigned char *) bpfh + offset; *totlen -= offset - tot; /* take into account align bytes */ } else if ((int) bpfh->bh_caplen > *totlen) abort(); *plen = bpfh->bh_caplen; *totlen -= bpfh->bh_caplen; assert(*totlen >= 0); /* radiotap */ rth = (struct ieee80211_radiotap_header *) ((char *) bpfh + bpfh->bh_hdrlen); get_radiotap_info(pn, rth, plen, ri); *plen -= rth->it_len; assert(*plen > 0); /* data */ ptr = (char *) rth + rth->it_len; return ptr; } static int nbsd_get_channel(struct wif * wi) { struct priv_nbsd * pn = wi_priv(wi); struct ieee80211chanreq channel; memset(&channel, 0, sizeof(channel)); strlcpy(channel.i_name, wi_get_ifname(wi), sizeof(channel.i_name)); if (ioctl(pn->pn_s, SIOCG80211CHANNEL, (caddr_t) &channel) < 0) return -1; return channel.i_channel; } static int nbsd_set_channel(struct wif * wi, int chan) { struct priv_nbsd * pn = wi_priv(wi); struct ieee80211chanreq channel; memset(&channel, 0, sizeof(channel)); strlcpy(channel.i_name, wi_get_ifname(wi), sizeof(channel.i_name)); channel.i_channel = chan; if (ioctl(pn->pn_s, SIOCS80211CHANNEL, (caddr_t) &channel) < 0) return -1; pn->pn_chan = chan; return 0; } static int nbsd_read(struct wif * wi, struct timespec * ts, int * dlt, unsigned char * h80211, int len, struct rx_info * ri) { struct priv_nbsd * pn = wi_priv(wi); unsigned char * wh; int plen; assert(len > 0); /* need to read more */ if (pn->pn_totlen == 0) { pn->pn_totlen = read(pn->pn_fd, pn->pn_buf, sizeof(pn->pn_buf)); if (pn->pn_totlen == -1) { pn->pn_totlen = 0; return -1; } pn->pn_next = pn->pn_buf; } /* read 802.11 packet */ wh = get_80211(pn, &plen, ri); if (plen > len) plen = len; assert(plen > 0); memcpy(h80211, wh, plen); if (dlt) { *dlt = LINKTYPE_IEEE802_11; } if (ts) { clock_gettime(CLOCK_REALTIME, ts); } if (ri && !ri->ri_channel) ri->ri_channel = wi_get_channel(wi); return plen; } static int nbsd_write(struct wif * wi, struct timespec * ts, int dlt, unsigned char * h80211, int len, struct tx_info * ti) { struct priv_nbsd * pn = wi_priv(wi); int rc; (void) ts; (void) dlt; /* XXX make use of ti */ if (ti) { } rc = write(pn->pn_fd, h80211, len); if (rc == -1) return rc; return 0; } static void do_free(struct wif * wi) { assert(wi->wi_priv); free(wi->wi_priv); wi->wi_priv = 0; free(wi); } static void nbsd_close(struct wif * wi) { struct priv_nbsd * pn = wi_priv(wi); close(pn->pn_fd); close(pn->pn_s); do_free(wi); } static int do_nbsd_open(struct wif * wi, char * iface) { int i; char buf[64]; int fd = -1; struct ifreq ifr; unsigned int dlt = DLT_IEEE802_11_RADIO; int s; unsigned int flags; struct ifmediareq ifmr; int * mwords; struct priv_nbsd * pn = wi_priv(wi); unsigned int size = sizeof(pn->pn_buf); /* basic sanity check */ if (strlen(iface) >= sizeof(ifr.ifr_name)) return -1; /* open wifi */ s = socket(PF_INET, SOCK_DGRAM, 0); if (s == -1) return -1; pn->pn_s = s; /* set iface up and promisc */ memset(&ifr, 0, sizeof(ifr)); strncpy(ifr.ifr_name, iface, IFNAMSIZ); if (ioctl(s, SIOCGIFFLAGS, &ifr) == -1) goto close_sock; flags = ifr.ifr_flags; flags |= IFF_UP | IFF_PROMISC; memset(&ifr, 0, sizeof(ifr)); strncpy(ifr.ifr_name, iface, IFNAMSIZ); ifr.ifr_flags = flags & 0xffff; if (ioctl(s, SIOCSIFFLAGS, &ifr) == -1) goto close_sock; /* monitor mode */ memset(&ifmr, 0, sizeof(ifmr)); strncpy(ifmr.ifm_name, iface, IFNAMSIZ); if (ioctl(s, SIOCGIFMEDIA, &ifmr) == -1) goto close_sock; assert(ifmr.ifm_count != 0); mwords = (int *) malloc(ifmr.ifm_count * sizeof(int)); if (!mwords) goto close_sock; ifmr.ifm_ulist = mwords; if (ioctl(s, SIOCGIFMEDIA, &ifmr) == -1) { free(mwords); goto close_sock; } free(mwords); memset(&ifr, 0, sizeof(ifr)); strncpy(ifr.ifr_name, iface, IFNAMSIZ); ifr.ifr_media = ifmr.ifm_current | IFM_IEEE80211_MONITOR; if (ioctl(s, SIOCSIFMEDIA, &ifr) == -1) goto close_sock; /* setup ifreq for chan that may be used in future */ strncpy(pn->pn_ireq.i_name, iface, IFNAMSIZ); /* same for ifreq [mac addr] */ strncpy(pn->pn_ifr.ifr_name, iface, IFNAMSIZ); /* open bpf */ for (i = 0; i < 256; i++) { snprintf(buf, sizeof(buf), "/dev/bpf%d", i); fd = open(buf, O_RDWR); if (fd < 0) { if (errno != EBUSY) return -1; continue; } else break; } if (fd < 0) goto close_sock; if (ioctl(fd, BIOCSBLEN, &size) < 0) goto close_bpf; strncpy(ifr.ifr_name, iface, IFNAMSIZ); if (ioctl(fd, BIOCSETIF, &ifr) < 0) goto close_bpf; if (ioctl(fd, BIOCSDLT, &dlt) < 0) goto close_bpf; if (ioctl(fd, BIOCPROMISC, NULL) < 0) goto close_bpf; dlt = 1; if (ioctl(fd, BIOCIMMEDIATE, &dlt) == -1) goto close_bpf; return fd; close_sock: close(s); return -1; close_bpf: close(fd); goto close_sock; } static int nbsd_fd(struct wif * wi) { struct priv_nbsd * pn = wi_priv(wi); return pn->pn_fd; } static int nbsd_get_mac(struct wif * wi, unsigned char * mac) { struct ifaddrs *ifa, *p; char * name = wi_get_ifname(wi); int rc = -1; struct sockaddr_dl * sdp; if (getifaddrs(&ifa) == -1) return -1; p = ifa; while (p) { if (p->ifa_addr->sa_family == AF_LINK && strcmp(name, p->ifa_name) == 0) { sdp = (struct sockaddr_dl *) p->ifa_addr; memcpy(mac, sdp->sdl_data + sdp->sdl_nlen, 6); rc = 0; break; } p = p->ifa_next; } freeifaddrs(ifa); return rc; } static int nbsd_get_monitor(struct wif * wi) { if (wi) { } /* XXX unused */ /* XXX */ return 0; } static int nbsd_get_rate(struct wif * wi) { if (wi) { } /* XXX unused */ /* XXX */ return 1000000; } static int nbsd_set_rate(struct wif * wi, int rate) { if (wi || rate) { } /* XXX unused */ /* XXX */ return 0; } static int nbsd_set_mac(struct wif * wi, unsigned char * mac) { struct priv_nbsd * pn = wi_priv(wi); struct ifreq * ifr = &pn->pn_ifr; ifr->ifr_addr.sa_family = AF_LINK; ifr->ifr_addr.sa_len = 6; memcpy(ifr->ifr_addr.sa_data, mac, 6); return ioctl(pn->pn_s, SIOCSIFADDR, ifr); } static struct wif * nbsd_open(char * iface) { struct wif * wi; struct priv_nbsd * pn; int fd; /* setup wi struct */ wi = wi_alloc(sizeof(*pn)); if (!wi) return NULL; wi->wi_read = nbsd_read; wi->wi_write = nbsd_write; wi->wi_set_channel = nbsd_set_channel; wi->wi_get_channel = nbsd_get_channel; wi->wi_close = nbsd_close; wi->wi_fd = nbsd_fd; wi->wi_get_mac = nbsd_get_mac; wi->wi_set_mac = nbsd_set_mac; wi->wi_get_rate = nbsd_get_rate; wi->wi_set_rate = nbsd_set_rate; wi->wi_get_monitor = nbsd_get_monitor; /* setup iface */ fd = do_nbsd_open(wi, iface); if (fd == -1) { do_free(wi); return NULL; } /* setup private state */ pn = wi_priv(wi); pn->pn_fd = fd; return wi; } struct wif * wi_open_osdep(char * iface) { return nbsd_open(iface); } EXPORT int get_battery_state(void) { #if defined(__FreeBSD__) int value; size_t len; len = 1; value = 0; sysctlbyname("hw.acpi.acline", &value, &len, NULL, 0); if (value == 0) { sysctlbyname("hw.acpi.battery.time", &value, &len, NULL, 0); value = value * 60; } else { value = 0; } return (value); #elif defined(_BSD_SOURCE) struct apm_power_info api; int apmfd; if ((apmfd = open("/dev/apm", O_RDONLY)) < 0) return 0; if (ioctl(apmfd, APM_IOC_GETPOWER, &api) < 0) { close(apmfd); return 0; } close(apmfd); if (api.battery_state == APM_BATT_UNKNOWN || api.battery_state == APM_BATTERY_ABSENT || api.battery_state == APM_BATT_CHARGING || api.ac_state == APM_AC_ON) { return 0; } return ((int) (api.minutes_left)) * 60; #else return 0; #endif } aircrack-ng-1.6/lib/osdep/netbsd_tap.c000066400000000000000000000113261361312141100177040ustar00rootroot00000000000000/* * Copyright (c) 2007, 2008, Andrea Bittau * * OS dependent API for NetBSD. TAP routines * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include #include #include #include #include #include "osdep.h" struct tip_nbsd { int tn_fd; int tn_ioctls; struct ifreq tn_ifr; char tn_name[MAX_IFACE_NAME]; int tn_destroy; }; static int ti_do_open_nbsd(struct tif * ti, char * name) { int fd; char * iface = "/dev/tap"; struct stat st; struct tip_nbsd * priv = ti_priv(ti); int s; unsigned int flags; struct ifreq * ifr; /* open tap */ if (name) iface = name; else priv->tn_destroy = 1; /* we create, we destroy */ fd = open(iface, O_RDWR); if (fd == -1) return -1; /* get name */ if (fstat(fd, &st) == -1) goto err; snprintf(priv->tn_name, sizeof(priv->tn_name) - 1, "%s", devname(st.st_rdev, S_IFCHR)); /* bring iface up */ s = socket(PF_INET, SOCK_DGRAM, 0); if (s == -1) goto err; priv->tn_ioctls = s; /* get flags */ ifr = &priv->tn_ifr; memset(ifr, 0, sizeof(*ifr)); snprintf(ifr->ifr_name, sizeof(ifr->ifr_name) - 1, "%s", priv->tn_name); if (ioctl(s, SIOCGIFFLAGS, ifr) == -1) goto err2; flags = ifr->ifr_flags; /* set flags */ flags |= IFF_UP; ifr->ifr_flags = flags & 0xffff; if (ioctl(s, SIOCSIFFLAGS, ifr) == -1) goto err2; return fd; err: /* XXX destroy */ close(fd); return -1; err2: close(s); goto err; } static void ti_do_free(struct tif * ti) { struct tip_nbsd * priv = ti_priv(ti); free(priv); free(ti); } static void ti_destroy(struct tip_nbsd * priv) { ioctl(priv->tn_ioctls, SIOCIFDESTROY, &priv->tn_ifr); } static void ti_close_nbsd(struct tif * ti) { struct tip_nbsd * priv = ti_priv(ti); if (priv->tn_destroy) ti_destroy(priv); close(priv->tn_fd); close(priv->tn_ioctls); ti_do_free(ti); } static char * ti_name_nbsd(struct tif * ti) { struct tip_nbsd * priv = ti_priv(ti); return priv->tn_name; } static int ti_set_mtu_nbsd(struct tif * ti, int mtu) { struct tip_nbsd * priv = ti_priv(ti); priv->tn_ifr.ifr_mtu = mtu; return ioctl(priv->tn_ioctls, SIOCSIFMTU, &priv->tn_ifr); } static int ti_set_mac_nbsd(struct tif * ti, unsigned char * mac) { struct tip_nbsd * priv = ti_priv(ti); struct ifreq * ifr = &priv->tn_ifr; ifr->ifr_addr.sa_family = AF_LINK; ifr->ifr_addr.sa_len = 6; memcpy(ifr->ifr_addr.sa_data, mac, 6); return ioctl(priv->tn_ioctls, SIOCSIFADDR, ifr); } static int ti_set_ip_nbsd(struct tif * ti, struct in_addr * ip) { struct tip_nbsd * priv = ti_priv(ti); struct ifaliasreq ifra; struct sockaddr_in * s_in; /* assume same size */ memset(&ifra, 0, sizeof(ifra)); strncpy(ifra.ifra_name, priv->tn_ifr.ifr_name, IFNAMSIZ); s_in = (struct sockaddr_in *) &ifra.ifra_addr; s_in->sin_family = PF_INET; s_in->sin_addr = *ip; s_in->sin_len = sizeof(*s_in); return ioctl(priv->tn_ioctls, SIOCAIFADDR, &ifra); } static int ti_fd_nbsd(struct tif * ti) { struct tip_nbsd * priv = ti_priv(ti); return priv->tn_fd; } static int ti_read_nbsd(struct tif * ti, void * buf, int len) { return read(ti_fd(ti), buf, len); } static int ti_write_nbsd(struct tif * ti, void * buf, int len) { return write(ti_fd(ti), buf, len); } static struct tif * ti_open_nbsd(char * iface) { struct tif * ti; struct tip_nbsd * priv; int fd; /* setup ti struct */ ti = ti_alloc(sizeof(*priv)); if (!ti) return NULL; ti->ti_name = ti_name_nbsd; ti->ti_set_mtu = ti_set_mtu_nbsd; ti->ti_close = ti_close_nbsd; ti->ti_fd = ti_fd_nbsd; ti->ti_read = ti_read_nbsd; ti->ti_write = ti_write_nbsd; ti->ti_set_mac = ti_set_mac_nbsd; ti->ti_set_ip = ti_set_ip_nbsd; /* setup iface */ fd = ti_do_open_nbsd(ti, iface); if (fd == -1) { ti_do_free(ti); return NULL; } /* setup private state */ priv = ti_priv(ti); priv->tn_fd = fd; return ti; } EXPORT struct tif * ti_open(char * iface) { return ti_open_nbsd(iface); } aircrack-ng-1.6/lib/osdep/network.c000066400000000000000000000232451361312141100172550ustar00rootroot00000000000000/* * Copyright (c) 2007, 2008, Andrea Bittau * * OS dependent API for using card via network. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include #include #include #include #include #include "aircrack-ng/support/communications.h" #include "osdep.h" #include "network.h" #define QUEUE_MAX 666 struct netqueue { unsigned char q_buf[2048]; int q_len; struct netqueue * q_next; struct netqueue * q_prev; }; struct priv_net { int pn_s; struct netqueue pn_queue; struct netqueue pn_queue_free; int pn_queue_len; }; EXPORT int net_send(int s, int command, void * arg, int len) { struct net_hdr * pnh; char * pktbuf; size_t pktlen; // Validate command value assert(command >= NET_RC && command <= HIGHEST_NET_COMMAND); if (command < NET_RC || command > HIGHEST_NET_COMMAND) { return -1; } pktlen = sizeof(struct net_hdr) + len; pktbuf = (char *) calloc(sizeof(char), pktlen); if (pktbuf == NULL) { perror("calloc"); goto net_send_error; } pnh = (struct net_hdr *) pktbuf; pnh->nh_type = command; pnh->nh_len = htonl(len); assert(arg != NULL); memcpy(pktbuf + sizeof(struct net_hdr), arg, len); for (;;) { ssize_t rc = send(s, pktbuf, pktlen, 0); if ((size_t) rc == pktlen) break; if (rc == EAGAIN || rc == EWOULDBLOCK || rc == EINTR) continue; if (rc == ECONNRESET) printf("Connection reset while sending packet!\n"); goto net_send_error; } free(pktbuf); return 0; net_send_error: free(pktbuf); return -1; } EXPORT int net_read_exact(int s, void * arg, int len) { ssize_t rc; int rlen = 0; char * buf = (char *) arg; while (rlen < len) { rc = recv(s, buf, (len - rlen), 0); if (rc < 1) { if (rc == -1 && (errno == EAGAIN || errno == EINTR)) { usleep(100); continue; } return -1; } buf += rc; rlen += rc; } return 0; } EXPORT int net_get(int s, void * arg, int * len) { struct net_hdr nh; int plen; if (net_read_exact(s, &nh, sizeof(nh)) == -1) { return -1; } plen = ntohl(nh.nh_len); assert(plen <= *len && plen >= 0); *len = plen; if ((*len) && (net_read_exact(s, arg, *len) == -1)) { return -1; } return nh.nh_type; } static void queue_del(struct netqueue * q) { q->q_prev->q_next = q->q_next; q->q_next->q_prev = q->q_prev; } static void queue_add(struct netqueue * head, struct netqueue * q) { struct netqueue * pos = head->q_prev; q->q_prev = pos; q->q_next = pos->q_next; q->q_next->q_prev = q; pos->q_next = q; } #if 0 static int queue_len(struct netqueue *head) { struct netqueue *q = head->q_next; int i = 0; while (q != head) { i++; q = q->q_next; } return i; } #endif static struct netqueue * queue_get_slot(struct priv_net * pn) { struct netqueue * q = pn->pn_queue_free.q_next; if (q != &pn->pn_queue_free) { queue_del(q); return q; } if (pn->pn_queue_len++ > QUEUE_MAX) return NULL; return malloc(sizeof(*q)); } static void net_enque(struct priv_net * pn, void * buf, int len) { struct netqueue * q; q = queue_get_slot(pn); if (!q) return; q->q_len = len; assert((int) sizeof(q->q_buf) >= q->q_len); memcpy(q->q_buf, buf, q->q_len); queue_add(&pn->pn_queue, q); } static int net_get_nopacket(struct priv_net * pn, void * arg, int * len) { unsigned char buf[2048]; int l = sizeof(buf); int c; while (1) { l = sizeof(buf); c = net_get(pn->pn_s, buf, &l); if (c < 0) return c; if (c != NET_PACKET && c > 0) break; if (c > 0) net_enque(pn, buf, l); } assert(l <= *len); memcpy(arg, buf, l); *len = l; return c; } static int net_cmd(struct priv_net * pn, int command, void * arg, int alen) { uint32_t rc; int len; int cmd; if (net_send(pn->pn_s, command, arg, alen) == -1) { return -1; } len = sizeof(rc); cmd = net_get_nopacket(pn, &rc, &len); if (cmd == -1) { return -1; } assert(cmd == NET_RC); assert(len == sizeof(rc)); return ntohl(rc); } static int queue_get(struct priv_net * pn, void * buf, int len) { struct netqueue * head = &pn->pn_queue; struct netqueue * q = head->q_next; if (q == head) return 0; assert(q->q_len <= len); memcpy(buf, q->q_buf, q->q_len); queue_del(q); queue_add(&pn->pn_queue_free, q); return q->q_len; } static int net_read(struct wif * wi, struct timespec * ts, int * dlt, unsigned char * h80211, int len, struct rx_info * ri) { struct priv_net * pn = wi_priv(wi); uint32_t buf[512]; // 512 * 4 = 2048 unsigned char * bufc = (unsigned char *) buf; int cmd; int sz = sizeof(*ri); int l; int ret; /* try queue */ l = queue_get(pn, buf, sizeof(buf)); if (!l) { /* try reading form net */ l = sizeof(buf); cmd = net_get(pn->pn_s, buf, &l); if (cmd == -1) return -1; if (cmd == NET_RC) { ret = ntohl((buf[0])); return ret; } assert(cmd == NET_PACKET); } /* XXX */ if (ri) { // re-assemble 64-bit integer ri->ri_mactime = __be64_to_cpu((uint64_t) buf[0] << 32u | buf[1]); ri->ri_power = __be32_to_cpu(buf[2]); ri->ri_noise = __be32_to_cpu(buf[3]); ri->ri_channel = __be32_to_cpu(buf[4]); ri->ri_freq = __be32_to_cpu(buf[5]); ri->ri_rate = __be32_to_cpu(buf[6]); ri->ri_antenna = __be32_to_cpu(buf[7]); } l -= sz; assert(l > 0); if (l > len) l = len; memcpy(h80211, &bufc[sz], l); if (dlt) { *dlt = LINKTYPE_IEEE802_11; } if (ts) { clock_gettime(CLOCK_REALTIME, ts); } return l; } static int net_get_mac(struct wif * wi, unsigned char * mac) { struct priv_net * pn = wi_priv(wi); uint32_t buf[2]; // only need 6 bytes, this provides 8 int cmd; int sz = 6; if (net_send(pn->pn_s, NET_GET_MAC, NULL, 0) == -1) return -1; cmd = net_get_nopacket(pn, buf, &sz); if (cmd == -1) return -1; if (cmd == NET_RC) return ntohl(buf[0]); assert(cmd == NET_MAC); assert(sz == 6); memcpy(mac, buf, 6); //-V512 return 0; } static int net_write(struct wif * wi, struct timespec * ts, int dlt, unsigned char * h80211, int len, struct tx_info * ti) { struct priv_net * pn = wi_priv(wi); int sz = sizeof(*ti); unsigned char buf[2048]; unsigned char * ptr = buf; (void) ts; (void) dlt; /* XXX */ if (ti) memcpy(ptr, ti, sz); //-V512 else memset(ptr, 0, sizeof(*ti)); //-V512 ptr += sz; memcpy(ptr, h80211, len); sz += len; return net_cmd(pn, NET_WRITE, buf, sz); } static int net_set_channel(struct wif * wi, int chan) { uint32_t c = htonl(chan); return net_cmd(wi_priv(wi), NET_SET_CHAN, &c, sizeof(c)); } static int net_get_channel(struct wif * wi) { struct priv_net * pn = wi_priv(wi); return net_cmd(pn, NET_GET_CHAN, NULL, 0); } static int net_set_rate(struct wif * wi, int rate) { uint32_t c = htonl(rate); return net_cmd(wi_priv(wi), NET_SET_RATE, &c, sizeof(c)); } static int net_get_rate(struct wif * wi) { struct priv_net * pn = wi_priv(wi); return net_cmd(pn, NET_GET_RATE, NULL, 0); } static int net_get_monitor(struct wif * wi) { return net_cmd(wi_priv(wi), NET_GET_MONITOR, NULL, 0); } static void do_net_free(struct wif * wi) { assert(wi->wi_priv); free(wi->wi_priv); wi->wi_priv = 0; free(wi); } static void net_close(struct wif * wi) { struct priv_net * pn = wi_priv(wi); close(pn->pn_s); do_net_free(wi); } static int handshake(int s) { if (s) { } /* XXX unused */ /* XXX do a handshake */ return 0; } static int do_net_open(char * iface) { int s, port; char ip[16]; struct sockaddr_in s_in; port = get_ip_port(iface, ip, sizeof(ip) - 1); if (port == -1) return -1; memset(&s_in, 0, sizeof(struct sockaddr_in)); s_in.sin_family = PF_INET; s_in.sin_port = htons(port); if (!inet_aton(ip, &s_in.sin_addr)) return -1; if ((s = socket(s_in.sin_family, SOCK_STREAM, IPPROTO_TCP)) == -1) return -1; printf("Connecting to %s port %d...\n", ip, port); if (connect(s, (struct sockaddr *) &s_in, sizeof(s_in)) == -1) { close(s); printf("Failed to connect\n"); return -1; } if (handshake(s) == -1) { close(s); printf("Failed to connect - handshake failed\n"); return -1; } printf("Connection successful\n"); return s; } static int net_fd(struct wif * wi) { struct priv_net * pn = wi_priv(wi); return pn->pn_s; } EXPORT struct wif * net_open(char * iface) { struct wif * wi; struct priv_net * pn; int s; /* setup wi struct */ wi = wi_alloc(sizeof(*pn)); if (!wi) return NULL; wi->wi_read = net_read; wi->wi_write = net_write; wi->wi_set_channel = net_set_channel; wi->wi_get_channel = net_get_channel; wi->wi_set_rate = net_set_rate; wi->wi_get_rate = net_get_rate; wi->wi_close = net_close; wi->wi_fd = net_fd; wi->wi_get_mac = net_get_mac; wi->wi_get_monitor = net_get_monitor; /* setup iface */ s = do_net_open(iface); if (s == -1) { do_net_free(wi); return NULL; } /* setup private state */ pn = wi_priv(wi); pn->pn_s = s; pn->pn_queue.q_next = pn->pn_queue.q_prev = &pn->pn_queue; pn->pn_queue_free.q_next = pn->pn_queue_free.q_prev = &pn->pn_queue_free; return wi; } aircrack-ng-1.6/lib/osdep/openbsd.c000066400000000000000000000277161361312141100172250ustar00rootroot00000000000000/* * Copyright (c) 2007, 2008, Andrea Bittau * * OS dependent API for OpenBSD. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define _KERNEL #include #include #include #include #include #undef _KERNEL #include #include #include #include #include #include #include #include #include #include #include #include "osdep.h" #ifndef LINKTYPE_IEEE802_11 #define LINKTYPE_IEEE802_11 105 #endif #ifndef IEEE80211_RADIOTAP_F_FCS #define IEEE80211_RADIOTAP_F_FCS 0x10 /* Frame includes FCS */ #endif #ifndef IEEE80211_IOC_CHANNEL #define IEEE80211_IOC_CHANNEL 0 #endif #ifndef le32toh #define le32toh(x) htole32(x) #endif struct priv_obsd { /* iface */ int po_fd; /* rx */ int po_nocrc; /* tx */ unsigned char po_buf[4096]; unsigned char * po_next; int po_totlen; /* setchan */ int po_s; struct ifreq po_ifr; struct ieee80211chanreq po_ireq; int po_chan; }; static void get_radiotap_info(struct priv_obsd * po, struct ieee80211_radiotap_header * rth, int * plen, struct rx_info * ri) { uint32_t present; uint8_t rflags = 0; int i; unsigned char * body = (unsigned char *) (rth + 1); int dbm_power = 0, db_power = 0; /* reset control info */ if (ri) memset(ri, 0, sizeof(*ri)); /* get info */ present = le32toh(rth->it_present); for (i = IEEE80211_RADIOTAP_TSFT; i <= IEEE80211_RADIOTAP_EXT; i++) { if (!(present & (1 << i))) continue; switch (i) { case IEEE80211_RADIOTAP_TSFT: body += sizeof(uint64_t); break; case IEEE80211_RADIOTAP_FLAGS: rflags = *((uint8_t *) body); /* fall through */ case IEEE80211_RADIOTAP_RATE: body += sizeof(uint8_t); break; case IEEE80211_RADIOTAP_CHANNEL: if (ri) { ri->ri_channel = 1; } body += sizeof(uint16_t) * 2; break; case IEEE80211_RADIOTAP_FHSS: body += sizeof(uint16_t); break; case IEEE80211_RADIOTAP_DBM_ANTSIGNAL: dbm_power = *body++; break; case IEEE80211_RADIOTAP_DBM_ANTNOISE: dbm_power -= *body++; break; case IEEE80211_RADIOTAP_DB_ANTSIGNAL: db_power = *body++; break; case IEEE80211_RADIOTAP_DB_ANTNOISE: db_power -= *body++; break; default: i = IEEE80211_RADIOTAP_EXT + 1; break; } } /* set power */ if (ri) { if (dbm_power) ri->ri_power = dbm_power; else ri->ri_power = db_power; } /* XXX cache; drivers won't change this per-packet */ /* check if FCS/CRC is included in packet */ if (po->po_nocrc || (rflags & IEEE80211_RADIOTAP_F_FCS)) { *plen -= IEEE80211_CRC_LEN; po->po_nocrc = 1; } } static unsigned char * get_80211(struct priv_obsd * po, int * plen, struct rx_info * ri) { struct bpf_hdr * bpfh; struct ieee80211_radiotap_header * rth; void * ptr; unsigned char ** data; int * totlen; data = &po->po_next; totlen = &po->po_totlen; assert(*totlen); /* bpf hdr */ bpfh = (struct bpf_hdr *) (*data); assert(bpfh->bh_caplen == bpfh->bh_datalen); /* XXX */ *totlen -= bpfh->bh_hdrlen; /* check if more packets */ if ((int) bpfh->bh_caplen < *totlen) { int tot = bpfh->bh_hdrlen + bpfh->bh_caplen; int offset = BPF_WORDALIGN(tot); *data = (unsigned char *) bpfh + offset; *totlen -= offset - tot; /* take into account align bytes */ } else if ((int) bpfh->bh_caplen > *totlen) abort(); *plen = bpfh->bh_caplen; *totlen -= bpfh->bh_caplen; assert(*totlen >= 0); /* radiotap */ rth = (struct ieee80211_radiotap_header *) ((char *) bpfh + bpfh->bh_hdrlen); get_radiotap_info(po, rth, plen, ri); *plen -= rth->it_len; assert(*plen > 0); /* data */ ptr = (char *) rth + rth->it_len; return ptr; } static int obsd_get_channel(struct wif * wi) { struct priv_obsd * po = wi_priv(wi); struct ieee80211chanreq channel; memset(&channel, 0, sizeof(channel)); strlcpy(channel.i_name, wi_get_ifname(wi), sizeof(channel.i_name)); if (ioctl(po->po_s, SIOCG80211CHANNEL, (caddr_t) &channel) < 0) return -1; return channel.i_channel; } static int obsd_set_channel(struct wif * wi, int chan) { struct priv_obsd * po = wi_priv(wi); struct ieee80211chanreq channel; memset(&channel, 0, sizeof(channel)); strlcpy(channel.i_name, wi_get_ifname(wi), sizeof(channel.i_name)); channel.i_channel = chan; if (ioctl(po->po_s, SIOCS80211CHANNEL, (caddr_t) &channel) < 0) return -1; po->po_chan = chan; return 0; } static int obsd_read(struct wif * wi, struct timespec * ts, int * dlt, unsigned char * h80211, int len, struct rx_info * ri) { struct priv_obsd * po = wi_priv(wi); unsigned char * wh; int plen; assert(len > 0); /* need to read more */ while (po->po_totlen == 0) { po->po_totlen = read(po->po_fd, po->po_buf, sizeof(po->po_buf)); if (po->po_totlen == -1) { po->po_totlen = 0; return -1; } po->po_next = po->po_buf; } /* read 802.11 packet */ wh = get_80211(po, &plen, ri); if (plen > len) plen = len; assert(plen > 0); memcpy(h80211, wh, plen); if (dlt) { *dlt = LINKTYPE_IEEE802_11; } if (ts) { clock_gettime(CLOCK_REALTIME, ts); } if (ri && !ri->ri_channel) ri->ri_channel = wi_get_channel(wi); return plen; } static int obsd_write(struct wif * wi, struct timespec * ts, int dlt, unsigned char * h80211, int len, struct tx_info * ti) { struct priv_obsd * po = wi_priv(wi); int rc; (void) ts; (void) dlt; /* XXX make use of ti */ if (ti) { } rc = write(po->po_fd, h80211, len); if (rc == -1) return rc; return 0; } static void do_free(struct wif * wi) { assert(wi->wi_priv); free(wi->wi_priv); wi->wi_priv = 0; free(wi); } static void obsd_close(struct wif * wi) { struct priv_obsd * po = wi_priv(wi); close(po->po_fd); close(po->po_s); do_free(wi); } static int do_obsd_open(struct wif * wi, char * iface) { int i; char buf[64]; int fd = -1; struct ifreq ifr; unsigned int dlt = DLT_IEEE802_11_RADIO; int s; unsigned int flags; struct ifmediareq ifmr; uint64_t * mwords; struct priv_obsd * po = wi_priv(wi); unsigned int size = sizeof(po->po_buf); /* basic sanity check */ if (strlen(iface) >= sizeof(ifr.ifr_name)) return -1; /* open wifi */ s = socket(PF_INET, SOCK_DGRAM, 0); if (s == -1) return -1; po->po_s = s; /* set iface up and promisc */ memset(&ifr, 0, sizeof(ifr)); strncpy(ifr.ifr_name, iface, IFNAMSIZ); if (ioctl(s, SIOCGIFFLAGS, &ifr) == -1) goto close_sock; flags = ifr.ifr_flags; flags |= IFF_UP | IFF_PROMISC; memset(&ifr, 0, sizeof(ifr)); strncpy(ifr.ifr_name, iface, IFNAMSIZ); ifr.ifr_flags = flags & 0xffff; if (ioctl(s, SIOCSIFFLAGS, &ifr) == -1) goto close_sock; /* monitor mode */ memset(&ifmr, 0, sizeof(ifmr)); strncpy(ifmr.ifm_name, iface, IFNAMSIZ); if (ioctl(s, SIOCGIFMEDIA, &ifmr) == -1) goto close_sock; assert(ifmr.ifm_count != 0); mwords = (uint64_t *) malloc(ifmr.ifm_count * sizeof(uint64_t)); if (!mwords) goto close_sock; ifmr.ifm_ulist = mwords; if (ioctl(s, SIOCGIFMEDIA, &ifmr) == -1) { free(mwords); goto close_sock; } free(mwords); memset(&ifr, 0, sizeof(ifr)); strncpy(ifr.ifr_name, iface, IFNAMSIZ); ifr.ifr_media = ifmr.ifm_current | IFM_IEEE80211_MONITOR; if (ioctl(s, SIOCSIFMEDIA, &ifr) == -1) goto close_sock; /* setup ifreq for chan that may be used in future */ strncpy(po->po_ireq.i_name, iface, IFNAMSIZ); /* same for ifreq [mac addr] */ strncpy(po->po_ifr.ifr_name, iface, IFNAMSIZ); /* open bpf */ for (i = 0; i < 256; i++) { snprintf(buf, sizeof(buf), "/dev/bpf%d", i); fd = open(buf, O_RDWR); if (fd < 0) { if (errno != EBUSY) return -1; continue; } else break; } if (fd < 0) goto close_sock; if (ioctl(fd, BIOCSBLEN, &size) < 0) goto close_bpf; strncpy(ifr.ifr_name, iface, IFNAMSIZ); if (ioctl(fd, BIOCSETIF, &ifr) < 0) goto close_bpf; if (ioctl(fd, BIOCSDLT, &dlt) < 0) goto close_bpf; if (ioctl(fd, BIOCPROMISC, NULL) < 0) goto close_bpf; dlt = 1; if (ioctl(fd, BIOCIMMEDIATE, &dlt) == -1) goto close_bpf; return fd; close_sock: close(s); return -1; close_bpf: close(fd); goto close_sock; } static int obsd_fd(struct wif * wi) { struct priv_obsd * po = wi_priv(wi); return po->po_fd; } static int obsd_get_mac(struct wif * wi, unsigned char * mac) { struct ifaddrs *ifa, *p; char * name = wi_get_ifname(wi); int rc = -1; struct sockaddr_dl * sdp; if (getifaddrs(&ifa) == -1) return -1; p = ifa; while (p) { if (p->ifa_addr->sa_family == AF_LINK && strcmp(name, p->ifa_name) == 0) { sdp = (struct sockaddr_dl *) p->ifa_addr; memcpy(mac, sdp->sdl_data + sdp->sdl_nlen, 6); rc = 0; break; } p = p->ifa_next; } freeifaddrs(ifa); return rc; } static int obsd_get_monitor(struct wif * wi) { if (wi) { } /* XXX unused */ /* XXX */ return 0; } static int obsd_get_rate(struct wif * wi) { if (wi) { } /* XXX unused */ /* XXX */ return 1000000; } static int obsd_set_rate(struct wif * wi, int rate) { if (wi || rate) { } /* XXX unused */ /* XXX */ return 0; } static int obsd_set_mac(struct wif * wi, unsigned char * mac) { struct priv_obsd * po = wi_priv(wi); struct ifreq * ifr = &po->po_ifr; ifr->ifr_addr.sa_family = AF_LINK; ifr->ifr_addr.sa_len = 6; memcpy(ifr->ifr_addr.sa_data, mac, 6); return ioctl(po->po_s, SIOCSIFLLADDR, ifr); } static struct wif * obsd_open(char * iface) { struct wif * wi; struct priv_obsd * po; int fd; /* setup wi struct */ wi = wi_alloc(sizeof(*po)); if (!wi) return NULL; wi->wi_read = obsd_read; wi->wi_write = obsd_write; wi->wi_set_channel = obsd_set_channel; wi->wi_get_channel = obsd_get_channel; wi->wi_close = obsd_close; wi->wi_fd = obsd_fd; wi->wi_get_mac = obsd_get_mac; wi->wi_set_mac = obsd_set_mac; wi->wi_get_rate = obsd_get_rate; wi->wi_set_rate = obsd_set_rate; wi->wi_get_monitor = obsd_get_monitor; /* setup iface */ fd = do_obsd_open(wi, iface); if (fd == -1) { do_free(wi); return NULL; } /* setup private state */ po = wi_priv(wi); po->po_fd = fd; return wi; } struct wif * wi_open_osdep(char * iface) { return obsd_open(iface); } EXPORT int get_battery_state(void) { #if defined(__FreeBSD__) int value; size_t len; len = 1; value = 0; sysctlbyname("hw.acpi.acline", &value, &len, NULL, 0); if (value == 0) { sysctlbyname("hw.acpi.battery.time", &value, &len, NULL, 0); value = value * 60; } else { value = 0; } return (value); #elif defined(_BSD_SOURCE) struct apm_power_info api; int apmfd; if ((apmfd = open("/dev/apm", O_RDONLY)) < 0) return 0; if (ioctl(apmfd, APM_IOC_GETPOWER, &api) < 0) { close(apmfd); return 0; } close(apmfd); if (api.battery_state == APM_BATT_UNKNOWN || api.battery_state == APM_BATTERY_ABSENT || api.battery_state == APM_BATT_CHARGING || api.ac_state == APM_AC_ON) { return 0; } return ((int) (api.minutes_left)) * 60; #else return 0; #endif } aircrack-ng-1.6/lib/osdep/openbsd_tap.c000066400000000000000000000113311361312141100200530ustar00rootroot00000000000000/* * Copyright (c) 2007, 2008, Andrea Bittau * * OS dependent API for OpenBSD. TAP routines * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include #include #include #include #include #include "osdep.h" struct tip_obsd { int to_fd; int to_ioctls; struct ifreq to_ifr; char to_name[MAX_IFACE_NAME]; int to_destroy; }; static int ti_do_open_obsd(struct tif * ti, char * name) { int fd; char * iface = "/dev/tap"; struct stat st; struct tip_obsd * priv = ti_priv(ti); int s; unsigned int flags; struct ifreq * ifr; /* open tap */ if (name) iface = name; else priv->to_destroy = 1; /* we create, we destroy */ fd = open(iface, O_RDWR); if (fd == -1) return -1; /* get name */ if (fstat(fd, &st) == -1) goto err; snprintf(priv->to_name, sizeof(priv->to_name) - 1, "%s", devname(st.st_rdev, S_IFCHR)); /* bring iface up */ s = socket(PF_INET, SOCK_DGRAM, 0); if (s == -1) goto err; priv->to_ioctls = s; /* get flags */ ifr = &priv->to_ifr; memset(ifr, 0, sizeof(*ifr)); snprintf(ifr->ifr_name, sizeof(ifr->ifr_name) - 1, "%s", priv->to_name); if (ioctl(s, SIOCGIFFLAGS, ifr) == -1) goto err2; flags = ifr->ifr_flags; /* set flags */ flags |= IFF_UP; ifr->ifr_flags = flags & 0xffff; if (ioctl(s, SIOCSIFFLAGS, ifr) == -1) goto err2; return fd; err: /* XXX destroy */ close(fd); return -1; err2: close(s); goto err; } static void ti_do_free(struct tif * ti) { struct tip_obsd * priv = ti_priv(ti); free(priv); free(ti); } static void ti_destroy(struct tip_obsd * priv) { ioctl(priv->to_ioctls, SIOCIFDESTROY, &priv->to_ifr); } static void ti_close_obsd(struct tif * ti) { struct tip_obsd * priv = ti_priv(ti); if (priv->to_destroy) ti_destroy(priv); close(priv->to_fd); close(priv->to_ioctls); ti_do_free(ti); } static char * ti_name_obsd(struct tif * ti) { struct tip_obsd * priv = ti_priv(ti); return priv->to_name; } static int ti_set_mtu_obsd(struct tif * ti, int mtu) { struct tip_obsd * priv = ti_priv(ti); priv->to_ifr.ifr_mtu = mtu; return ioctl(priv->to_ioctls, SIOCSIFMTU, &priv->to_ifr); } static int ti_set_mac_obsd(struct tif * ti, unsigned char * mac) { struct tip_obsd * priv = ti_priv(ti); struct ifreq * ifr = &priv->to_ifr; ifr->ifr_addr.sa_family = AF_LINK; ifr->ifr_addr.sa_len = 6; memcpy(ifr->ifr_addr.sa_data, mac, 6); return ioctl(priv->to_ioctls, SIOCSIFLLADDR, ifr); } static int ti_set_ip_obsd(struct tif * ti, struct in_addr * ip) { struct tip_obsd * priv = ti_priv(ti); struct ifaliasreq ifra; struct sockaddr_in * s_in; /* assume same size */ memset(&ifra, 0, sizeof(ifra)); strncpy(ifra.ifra_name, priv->to_ifr.ifr_name, IFNAMSIZ); s_in = (struct sockaddr_in *) &ifra.ifra_addr; s_in->sin_family = PF_INET; s_in->sin_addr = *ip; s_in->sin_len = sizeof(*s_in); return ioctl(priv->to_ioctls, SIOCAIFADDR, &ifra); } static int ti_fd_obsd(struct tif * ti) { struct tip_obsd * priv = ti_priv(ti); return priv->to_fd; } static int ti_read_obsd(struct tif * ti, void * buf, int len) { return read(ti_fd(ti), buf, len); } static int ti_write_obsd(struct tif * ti, void * buf, int len) { return write(ti_fd(ti), buf, len); } static struct tif * ti_open_obsd(char * iface) { struct tif * ti; struct tip_obsd * priv; int fd; /* setup ti struct */ ti = ti_alloc(sizeof(*priv)); if (!ti) return NULL; ti->ti_name = ti_name_obsd; ti->ti_set_mtu = ti_set_mtu_obsd; ti->ti_close = ti_close_obsd; ti->ti_fd = ti_fd_obsd; ti->ti_read = ti_read_obsd; ti->ti_write = ti_write_obsd; ti->ti_set_mac = ti_set_mac_obsd; ti->ti_set_ip = ti_set_ip_obsd; /* setup iface */ fd = ti_do_open_obsd(ti, iface); if (fd == -1) { ti_do_free(ti); return NULL; } /* setup private state */ priv = ti_priv(ti); priv->to_fd = fd; return ti; } EXPORT struct tif * ti_open(char * iface) { return ti_open_obsd(iface); } aircrack-ng-1.6/lib/osdep/osdep.c000066400000000000000000000121721361312141100166730ustar00rootroot00000000000000/* * Copyright (c) 2007, 2008, Andrea Bittau * * OS dependent API. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include "osdep.h" #include "network.h" extern struct wif * file_open(char * iface); EXPORT int wi_read(struct wif * wi, struct timespec * ts, int * dlt, unsigned char * h80211, int len, struct rx_info * ri) { assert(wi->wi_read); return wi->wi_read(wi, ts, dlt, h80211, len, ri); } EXPORT int wi_write(struct wif * wi, struct timespec * ts, int dlt, unsigned char * h80211, int len, struct tx_info * ti) { assert(wi->wi_write); return wi->wi_write(wi, ts, dlt, h80211, len, ti); } EXPORT int wi_set_ht_channel(struct wif * wi, int chan, unsigned int htval) { assert(wi->wi_set_ht_channel); return wi->wi_set_ht_channel(wi, chan, htval); } EXPORT int wi_set_channel(struct wif * wi, int chan) { assert(wi->wi_set_channel); return wi->wi_set_channel(wi, chan); } EXPORT int wi_get_channel(struct wif * wi) { assert(wi->wi_get_channel); return wi->wi_get_channel(wi); } EXPORT int wi_set_freq(struct wif * wi, int freq) { assert(wi->wi_set_freq); return wi->wi_set_freq(wi, freq); } EXPORT int wi_get_freq(struct wif * wi) { assert(wi->wi_get_freq); return wi->wi_get_freq(wi); } EXPORT int wi_get_monitor(struct wif * wi) { assert(wi->wi_get_monitor); return wi->wi_get_monitor(wi); } EXPORT char * wi_get_ifname(struct wif * wi) { return wi->wi_interface; } EXPORT void wi_close(struct wif * wi) { assert(wi->wi_close); wi->wi_close(wi); } EXPORT int wi_fd(struct wif * wi) { assert(wi->wi_fd); return wi->wi_fd(wi); } struct wif * wi_alloc(int sz) { struct wif * wi; void * priv; /* Allocate wif & private state */ wi = malloc(sizeof(*wi)); if (!wi) return NULL; memset(wi, 0, sizeof(*wi)); priv = malloc(sz); if (!priv) { free(wi); return NULL; } memset(priv, 0, sz); wi->wi_priv = priv; return wi; } void * wi_priv(struct wif * wi) { return wi->wi_priv; } EXPORT int wi_get_mac(struct wif * wi, unsigned char * mac) { assert(wi->wi_get_mac); return wi->wi_get_mac(wi, mac); } EXPORT int wi_set_mac(struct wif * wi, unsigned char * mac) { assert(wi->wi_set_mac); return wi->wi_set_mac(wi, mac); } EXPORT int wi_get_rate(struct wif * wi) { assert(wi->wi_get_rate); return wi->wi_get_rate(wi); } EXPORT int wi_set_rate(struct wif * wi, int rate) { assert(wi->wi_set_rate); return wi->wi_set_rate(wi, rate); } EXPORT int wi_get_mtu(struct wif * wi) { assert(wi->wi_get_mtu); return wi->wi_get_mtu(wi); } EXPORT int wi_set_mtu(struct wif * wi, int mtu) { assert(wi->wi_set_mtu); return wi->wi_set_mtu(wi, mtu); } EXPORT struct wif * wi_open(char * iface) { struct wif * wi; if (iface == NULL || iface[0] == 0) { return NULL; } wi = file_open(iface); if (wi == (struct wif *) -1) return NULL; if (!wi) wi = net_open(iface); if (!wi) wi = wi_open_osdep(iface); if (!wi) return NULL; strncpy(wi->wi_interface, iface, sizeof(wi->wi_interface) - 1); wi->wi_interface[sizeof(wi->wi_interface) - 1] = 0; return wi; } /* tap stuff */ EXPORT char * ti_name(struct tif * ti) { assert(ti->ti_name); return ti->ti_name(ti); } EXPORT int ti_set_mtu(struct tif * ti, int mtu) { assert(ti->ti_set_mtu); return ti->ti_set_mtu(ti, mtu); } EXPORT int ti_get_mtu(struct tif * ti) { assert(ti->ti_get_mtu); return ti->ti_get_mtu(ti); } EXPORT void ti_close(struct tif * ti) { assert(ti->ti_close); ti->ti_close(ti); } EXPORT int ti_fd(struct tif * ti) { assert(ti->ti_fd); return ti->ti_fd(ti); } EXPORT int ti_read(struct tif * ti, void * buf, int len) { assert(ti->ti_read); return ti->ti_read(ti, buf, len); } EXPORT int ti_write(struct tif * ti, void * buf, int len) { assert(ti->ti_write); return ti->ti_write(ti, buf, len); } EXPORT int ti_set_mac(struct tif * ti, unsigned char * mac) { assert(ti->ti_set_mac); return ti->ti_set_mac(ti, mac); } EXPORT int ti_set_ip(struct tif * ti, struct in_addr * ip) { assert(ti->ti_set_ip); return ti->ti_set_ip(ti, ip); } struct tif * ti_alloc(int sz) { struct tif * ti; void * priv; /* Allocate tif & private state */ ti = malloc(sizeof(*ti)); if (!ti) return NULL; memset(ti, 0, sizeof(*ti)); priv = malloc(sz); if (!priv) { free(ti); return NULL; } memset(priv, 0, sz); ti->ti_priv = priv; return ti; } void * ti_priv(struct tif * ti) { return ti->ti_priv; } aircrack-ng-1.6/lib/osdep/tap-win32/000077500000000000000000000000001361312141100171365ustar00rootroot00000000000000aircrack-ng-1.6/lib/osdep/tap-win32/common.h000066400000000000000000000065051361312141100206050ustar00rootroot00000000000000/* * TAP-Win32 -- A kernel driver to provide virtual tap device functionality * on Windows. Originally derived from the CIPE-Win32 * project by Damion K. Wilson, with extensive modifications by * James Yonan. * * All source code which derives from the CIPE-Win32 project is * Copyright (C) Damion K. Wilson, 2003, and is released under the * GPL version 2 (see below). * * All other source code is Copyright (C) 2002-2005 OpenVPN Solutions LLC, * and is released under the GPL version 2 (see below). * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program (see the file COPYING included with this * distribution); if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ //=============================================== // This file is included both by OpenVPN and // the TAP-Win32 driver and contains definitions // common to both. //=============================================== //============= // TAP IOCTLs //============= #define TAP_CONTROL_CODE(request, method) \ CTL_CODE(FILE_DEVICE_UNKNOWN, request, method, FILE_ANY_ACCESS) // Present in 8.1 #define TAP_IOCTL_GET_MAC TAP_CONTROL_CODE(1, METHOD_BUFFERED) #define TAP_IOCTL_GET_VERSION TAP_CONTROL_CODE(2, METHOD_BUFFERED) #define TAP_IOCTL_GET_MTU TAP_CONTROL_CODE(3, METHOD_BUFFERED) #define TAP_IOCTL_GET_INFO TAP_CONTROL_CODE(4, METHOD_BUFFERED) #define TAP_IOCTL_CONFIG_POINT_TO_POINT TAP_CONTROL_CODE(5, METHOD_BUFFERED) #define TAP_IOCTL_SET_MEDIA_STATUS TAP_CONTROL_CODE(6, METHOD_BUFFERED) #define TAP_IOCTL_CONFIG_DHCP_MASQ TAP_CONTROL_CODE(7, METHOD_BUFFERED) #define TAP_IOCTL_GET_LOG_LINE TAP_CONTROL_CODE(8, METHOD_BUFFERED) #define TAP_IOCTL_CONFIG_DHCP_SET_OPT TAP_CONTROL_CODE(9, METHOD_BUFFERED) // Added in 8.2 /* obsoletes TAP_IOCTL_CONFIG_POINT_TO_POINT */ #define TAP_IOCTL_CONFIG_TUN TAP_CONTROL_CODE(10, METHOD_BUFFERED) //================= // Registry keys //================= #define ADAPTER_KEY \ "SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-" \ "08002BE10318}" #define NETWORK_CONNECTIONS_KEY \ "SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-" \ "08002BE10318}" //====================== // Filesystem prefixes //====================== #define USERMODEDEVICEDIR "\\\\.\\Global\\" #define SYSDEVICEDIR "\\Device\\" #define USERDEVICEDIR "\\DosDevices\\Global\\" #define TAPSUFFIX ".tap" //========================================================= // TAP_COMPONENT_ID -- This string defines the TAP driver // type -- different component IDs can reside in the system // simultaneously. //========================================================= #define TAP_COMPONENT_ID "tap0801" aircrack-ng-1.6/lib/ptw/000077500000000000000000000000001361312141100151125ustar00rootroot00000000000000aircrack-ng-1.6/lib/ptw/aircrack-ptw-lib.c000066400000000000000000000607761361312141100204310ustar00rootroot00000000000000/* * Copyright (c) 2007-2009 Erik Tews, Andrei Pychkine and Ralf-Philipp * Weinmann. * 2013 Ramiro Polla * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU General Public License in all respects * for all of the code used other than OpenSSL. * If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. * If you * do not wish to do so, delete this exception statement from your * version. * If you delete this exception statement from all source * files in the program, then also delete it here. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #ifdef HAVE_SYS_TYPES_H #include #endif #if defined(__sun__) #include #endif #include #include #include #include "aircrack-ng/support/pcap_local.h" #include "aircrack-ng/defs.h" #include "aircrack-ng/ptw/aircrack-ptw-lib.h" #include "aircrack-ng/aircrack-ng.h" #define n PTW_n #define CONTROLSESSIONS PTW_CONTROLSESSIONS #define KSBYTES PTW_KSBYTES #define IVBYTES PTW_IVBYTES #define TESTBYTES 6 static struct options opt; // Internal state of rc4 typedef struct { uint32_t s[n]; uint8_t i; uint8_t j; } rc4state; // Helper structures for sorting typedef struct { int keybyte; uint8_t value; int distance; } sorthelper; typedef struct { int keybyte; double difference; } doublesorthelper; // The rc4 initial state, the idendity permutation static const uint32_t rc4initial[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255}; // Values for p_correct_i static const double eval[] = {0.00534392069257663, 0.00531787585068872, 0.00531345769225911, 0.00528812219217898, 0.00525997750378221, 0.00522647312237696, 0.00519132541143668, 0.0051477139367225, 0.00510438884847959, 0.00505484662057323, 0.00500502783556246, 0.00495094196451801, 0.0048983441590402}; static int tried, max_tries; static int depth[KEYHSBYTES]; static PTW_tableentry keytable[KEYHSBYTES][n]; // Check if optmizied RC4 for AMD64 has to be compiled #if defined(__amd64) && defined(__SSE2__) \ && (!defined(__clang__) \ || (defined(__clang__) \ && (__clang_major__ >= 4 \ || (__clang_major__ == 3 && __clang_minor__ >= 9)))) #define USE_AMD64_RC4_OPTIMIZED #endif // For sorting static int compare(const void * ina, const void * inb) { REQUIRE(ina != NULL); REQUIRE(inb != NULL); PTW_tableentry * a = (PTW_tableentry *) ina; PTW_tableentry * b = (PTW_tableentry *) inb; return b->votes - a->votes; } // For sorting static int comparedoublesorthelper(const void * ina, const void * inb) { REQUIRE(ina != NULL); REQUIRE(inb != NULL); doublesorthelper * a = (doublesorthelper *) ina; doublesorthelper * b = (doublesorthelper *) inb; if (a->difference > b->difference) { return 1; } else if (fabs(a->difference - b->difference) < FLT_EPSILON) { return 0; } else { return -1; } } #ifdef USE_AMD64_RC4_OPTIMIZED static const uint32_t __attribute__((used)) __attribute__((aligned(16))) x0123[4] = {0, 1, 2, 3}; static const uint32_t __attribute__((used)) __attribute__((aligned(16))) x4444[4] = {4, 4, 4, 4}; static int rc4test_amd64_sse2(uint8_t * key, int keylen, uint8_t * iv, uint8_t * keystream) { int idx, i, j; int scratch1, scratch2; __asm__ volatile( #define state "%%rsp" #define keybuf "0x400(%%rsp)" #define keystream_ "0x428(%%rsp)" // setup stack "movq %%rsp, %q0 \n\t" "subq $0x430, %%rsp \n\t" "andq $-16, %%rsp \n\t" "movq %q0, -8(%%rsp) \n\t" // save keystream variable "movq %q6, " keystream_ " \n\t" // keylen += IVBYTES "addl $3, %k4 \n\t" // memcpy(keybuf, iv, IVBYTES); "movl (%q5), %k1 \n\t" "movl %k1 , " keybuf " \n\t" // memcpy(&keybuf[IVBYTES], key, keylen); "movdqa (%q3), %%xmm0 \n\t" "cmpl $16, %k4 \n\t" "movdqu %%xmm0, 3+" keybuf " \n\t" "jng .Lsmall_key1 \n\t" "movdqa 16(%q3), %%xmm1 \n\t" "movdqu %%xmm1,19+" keybuf " \n\t" ".Lsmall_key1: \n\t" // key = keybuf "lea " keybuf ", %q3 \n\t" // load xmm registers "movdqa %q9, %%xmm0 \n\t" "movdqa %q10, %%xmm1 \n\t" // clear some registers "xorq %q0, %q0 \n\t" // idx "xorq %q1, %q1 \n\t" // i "xorq %q2, %q2 \n\t" // j // build identity array ".p2align 4 \n\t" ".Lidentity_loop: \n\t" "movdqa %%xmm0, (" state ",%q1,4)\n\t" "addb $4, %b1 \n\t" "paddd %%xmm1, %%xmm0 \n\t" "jnc .Lidentity_loop \n\t" // load state into register "movq " state ", %q1 \n\t" // %q4 = and mask for idx "movq %q4, %q8 \n\t" "cmpq $16, %q8 \n\t" "movq $15, %q4 \n\t" "je .Lsmall_key2 \n\t" "shrq $1, %q4 \n\t" ".Lsmall_key2: \n\t" // init array with key ".p2align 4 \n\t" ".init_loop: \n\t" "movl %k0, %k8 \n\t" /* scratch2 = idx */ "movl (%q1), %k5 \n\t" /* s1 = state[i] */ "leal 1(%q0,1), %k0 \n\t" /* idx++ */ "movzbl (%q3,%q8,1), %k6 \n\t" /* key_n = key[scratch2] */ "leal (%q5,%q6,1), %k8 \n\t" /* scratch2 = s1 + key_n */ "addl %k8, %k2 \n\t" /* j += scratch2 */ "andl %k4, %k0 \n\t" /* idx &= mask */ "movzbl %b2, %k8 \n\t" /* scratch2 = j */ "movl (" state ",%q8,4), %k7 \n\t" /* s2 = state[scratch2] */ "movl %k7, (%q1) \n\t" /* state[i] = s2 */ "addq $4, %q1 \n\t" /* i++ */ "movl %k5, (" state ",%q8,4) \n\t" /* state[scratch2] = s1 */ "cmpq %q1, %q3 \n\t" /* state == &state[0x100] */ "jne .init_loop \n\t" // restore keystream variable "movq " keystream_ ", %q6 \n\t" // clear some registers "xorq %q2, %q2 \n\t" // j = 0 "xorq %q0, %q0 \n\t" // result #define RC4TEST_LOOP(offset) \ "movl 4*" offset "(" state "), %k5\n\t" /* s1 = state[i] */ \ "leal (%q5,%q2,1), %k4 \n\t" /* */ \ "movzbl %b4, %k2 \n\t" /* j += s1 */ \ "movl (" state ",%q2,4), %k1 \n\t" /* s2 = state[j] */ \ "movl %k1, 4*" offset "(" state ")\n\t" /* state[i] = s2 */ \ "movl %k5, (" state ",%q2,4) \n\t" /* state[j] = s1 */ \ "addb %b1, %b5 \n\t" /* s1 += s2; */ \ "movb (" state ",%q5,4), %b3 \n\t" /* ret = state[s1] */ \ "cmpb %b3, " offset "-1(%q6) \n\t" /* ret == keystream[i-1] */ \ "jne .ret \n\t" RC4TEST_LOOP("1") RC4TEST_LOOP("2") RC4TEST_LOOP("3") RC4TEST_LOOP("4") RC4TEST_LOOP("5") RC4TEST_LOOP("6") #undef RC4TEST_LOOP "addb $1, %b0 \n\t" ".ret: \n\t" // restore stack "movq -8(%%rsp), %%rsp \n\t" : "=&r"(idx), "=&r"(i), "=&r"(j), "+r"(key), "+r"(keylen), "+r"(iv), "+r"(keystream), "=&r"(scratch1), "=&r"(scratch2) : "m"(x0123[0]), "m"(x4444[0]) : "xmm0", "xmm1"); #undef state #undef keybuf #undef keystream_ return idx; } #endif // RC4 key setup static void rc4init(uint8_t * key, int keylen, rc4state * state) { REQUIRE(key != NULL); REQUIRE(keylen > 0 && keylen < INT_MAX); REQUIRE(state != NULL); int i; unsigned char j; uint8_t tmp; int idx = 0; memcpy(state->s, &rc4initial, sizeof(rc4initial)); j = 0; for (i = 0; i < n; i++) { /* this should be: j = (j + state->s[i] + key[i % keylen]) % n; but as "j" is declared as unsigned char and n equals 256, we can "optimize" it */ j = (j + state->s[i] + key[idx]); if (++idx == keylen) idx = 0; tmp = state->s[i]; state->s[i] = state->s[j]; state->s[j] = tmp; } state->i = 0; state->j = 0; } // RC4 key stream generation static uint8_t rc4update(rc4state * state) { REQUIRE(state != NULL); uint8_t tmp; uint8_t k; state->i++; state->j += state->s[state->i]; tmp = state->s[state->i]; state->s[state->i] = state->s[state->j]; state->s[state->j] = tmp; k = state->s[state->i] + state->s[state->j]; return state->s[k]; } static int rc4test(uint8_t * key, int keylen, uint8_t * iv, uint8_t * keystream) { REQUIRE(key != NULL); REQUIRE(keylen > 0); REQUIRE(iv != NULL); REQUIRE(keystream != NULL); uint8_t keybuf[PTW_KSBYTES]; rc4state rc4state; int j; memcpy(&keybuf[IVBYTES], key, keylen); memcpy(keybuf, iv, IVBYTES); //-V512 rc4init(keybuf, keylen + IVBYTES, &rc4state); for (j = 0; j < TESTBYTES; j++) { if ((rc4update(&rc4state) ^ keystream[j]) != 0) { return 0; } } return 1; } // For sorting static int comparesorthelper(const void * ina, const void * inb) { REQUIRE(ina != NULL); REQUIRE(inb != NULL); sorthelper * a = (sorthelper *) ina; sorthelper * b = (sorthelper *) inb; return a->distance - b->distance; } /* * Guess the values for sigma_i * ivlen - how long was the iv (is used differently in original klein attack) * iv - IV which was used for this packet * keystream - keystream recovered * result - buffer for the values of sigma_i * kb - how many keybytes should be guessed */ static void guesskeybytes( int ivlen, uint8_t * iv, uint8_t * keystream, uint8_t * result, int kb) { REQUIRE(iv != NULL); REQUIRE(keystream != NULL); REQUIRE(result != NULL); uint32_t state[n]; uint8_t j = 0; uint8_t tmp; int i; int jj = ivlen; uint8_t ii; uint8_t s = 0; memcpy(state, &rc4initial, sizeof(rc4initial)); for (i = 0; i < ivlen; i++) { j += state[i] + iv[i]; tmp = state[i]; state[i] = state[j]; state[j] = tmp; } for (i = 0; i < kb; i++) { tmp = jj - keystream[jj - 1]; ii = 0; while (tmp != state[ii]) { ii++; } s += state[jj]; ii -= (j + s); result[i] = ii; jj++; } return; } /* * Is a guessed key correct? */ static int correct(PTW_attackstate * state, uint8_t * key, int keylen) { REQUIRE(state != NULL); REQUIRE(key != NULL && keylen > 0); int i; int k; // We need at least 3 sessions to be somehow certain if (state->sessions_collected < 3) { return 0; } tried++; k = rand() % (state->sessions_collected - 10); for (i = k; i < k + 10; i++) { if (!state->rc4test(key, keylen, state->sessions[i].iv, state->sessions[i].keystream)) return 0; } return 1; } /* * Calculate the squaresum of the errors for both distributions */ static void getdrv(PTW_tableentry orgtable[][n], int keylen, double * normal, double * ausreiser) { int i, j; int numvotes = 0; double e; double e2; double emax; double help = 0.0; double maxhelp = 0; double maxi = 0; for (i = 0; i < n; i++) { numvotes += orgtable[0][i].votes; } e = (double) (numvotes) / n; for (i = 0; i < keylen; i++) { emax = eval[i] * numvotes; e2 = ((1.0 - eval[i]) / 255.0) * numvotes; normal[i] = 0; ausreiser[i] = 0; maxhelp = 0; maxi = 0; for (j = 0; j < n; j++) { if (orgtable[i][j].votes > maxhelp) { maxhelp = orgtable[i][j].votes; maxi = j; } } for (j = 0; j < n; j++) { if (fabs(maxi - j) < FLT_EPSILON) { help = (1.0 - orgtable[i][j].votes / emax); } else { help = (1.0 - orgtable[i][j].votes / e2); } help = help * help; ausreiser[i] += help; help = (1.0 - orgtable[i][j].votes / e); help = help * help; normal[i] += help; } } } /* * Guess a single keybyte */ static int doRound(PTW_tableentry sortedtable[][n], int keybyte, int fixat, uint8_t fixvalue, int * searchborders, uint8_t * key, int keylen, PTW_attackstate * state, uint8_t sum, int * strongbytes, int * bf, int validchars[][n]) { int i; uint8_t tmp; if (!opt.is_quiet && keybyte < 4) show_wep_stats(keylen - 1, 0, keytable, searchborders, depth, tried); if (keybyte > 0) { if (!validchars[keybyte - 1][key[keybyte - 1]]) { return 0; } } if (keybyte == keylen) { return correct(state, key, keylen); } else if (bf[keybyte] == 1) { for (i = 0; i < n; i++) { key[keybyte] = i; if (doRound(sortedtable, keybyte + 1, fixat, fixvalue, searchborders, key, keylen, state, sum + i % n, strongbytes, bf, validchars)) { return 1; } } return 0; } else if (keybyte == fixat) { key[keybyte] = fixvalue - sum; return doRound(sortedtable, keybyte + 1, fixat, fixvalue, searchborders, key, keylen, state, fixvalue, strongbytes, bf, validchars); } else if (strongbytes[keybyte] == 1) { // printf("assuming byte %d to be strong\n", keybyte); tmp = 3 + keybyte; for (i = keybyte - 1; i >= 1; i--) { tmp += 3 + key[i] + i; key[keybyte] = n - tmp; if (doRound(sortedtable, keybyte + 1, fixat, fixvalue, searchborders, key, keylen, state, (n - tmp + sum) % n, strongbytes, bf, validchars) == 1) { printf("hit with strongbyte for keybyte %d\n", keybyte); return 1; } } return 0; } else { REQUIRE(searchborders != NULL); REQUIRE(keybyte >= 0); for (i = 0; i < searchborders[keybyte]; i++) { key[keybyte] = sortedtable[keybyte][i].b - sum; if (!opt.is_quiet) { depth[keybyte] = i; keytable[keybyte][i].b = key[keybyte]; } if (doRound(sortedtable, keybyte + 1, fixat, fixvalue, searchborders, key, keylen, state, sortedtable[keybyte][i].b, strongbytes, bf, validchars)) { return 1; } } return 0; } } /* * Do the actual computation of the key */ static int doComputation(PTW_attackstate * state, uint8_t * key, int keylen, PTW_tableentry table[][n], sorthelper * sh2, int * strongbytes, int keylimit, int * bf, int validchars[][n]) { int i, j; int choices[KEYHSBYTES]; int prod; int fixat; int fixvalue; if (!opt.is_quiet) memcpy(keytable, table, sizeof(PTW_tableentry) * n * keylen); for (i = 0; i < keylen; i++) { if (strongbytes[i] == 1) { choices[i] = i; } else { choices[i] = 1; } } i = 0; prod = 0; fixat = -1; fixvalue = 0; max_tries = keylimit; while (prod < keylimit) { if (doRound(table, 0, fixat, fixvalue, choices, key, keylen, state, 0, strongbytes, bf, validchars) == 1) { // printf("hit with %d choices\n", prod); if (!opt.is_quiet) show_wep_stats(keylen - 1, 1, keytable, choices, depth, tried); return 1; } while ((i < keylen * (n - 1)) && ((strongbytes[sh2[i].keybyte] == 1) || (bf[sh2[i].keybyte] == 1))) { i++; } if (i >= (keylen * (n - 1))) { break; } choices[sh2[i].keybyte]++; fixat = sh2[i].keybyte; // printf("choices[%d] is now %d\n", sh2[i].keybyte, // choices[sh2[i].keybyte]); fixvalue = sh2[i].value; prod = 1; for (j = 0; j < keylen; j++) { prod *= choices[j]; if (bf[j] == 1) { prod *= n; } } /* do { i++; } while (strongbytes[sh2[i].keybyte] == 1); */ i++; if (!opt.is_quiet) show_wep_stats(keylen - 1, 0, keytable, choices, depth, tried); } if (!opt.is_quiet) show_wep_stats(keylen - 1, 1, keytable, choices, depth, tried); return 0; } /* * Guess which key bytes could be strong and start actual computation of the key */ int PTW_computeKey(PTW_attackstate * state, uint8_t * keybuf, int keylen, int testlimit, int * bf, int validchars[][n], int attacks) { REQUIRE(state != NULL); int strongbytes[KEYHSBYTES]; double normal[KEYHSBYTES]; double ausreisser[KEYHSBYTES]; doublesorthelper helper[KEYHSBYTES]; int simple, onestrong, twostrong; int i, j; #ifdef USE_AMD64_RC4_OPTIMIZED /* * The 64-bit SSE2-optimized rc4test() requires this buffer to be * aligned at 3 bytes. */ uint8_t fullkeybuf_unaligned[PTW_KSBYTES + 13] __attribute__((aligned(16))); uint8_t * fullkeybuf = &fullkeybuf_unaligned[13]; #else uint8_t fullkeybuf[PTW_KSBYTES]; #endif uint8_t guessbuf[PTW_KSBYTES]; sorthelper(*sh)[n - 1]; PTW_tableentry(*table)[n] = alloca(sizeof(PTW_tableentry) * n * keylen); ALLEGE(table != NULL); #ifdef USE_AMD64_RC4_OPTIMIZED /* * sse2-optimized rc4test() function for amd64 only works * for keylen == 5 or keylen == 13 */ if (keylen == 5 || keylen == 13) state->rc4test = rc4test_amd64_sse2; else #endif state->rc4test = rc4test; tried = 0; sh = NULL; if (!(attacks & NO_KLEIN)) { // Try the original klein attack first for (i = 0; i < keylen; i++) { memset(&table[i][0], 0, sizeof(PTW_tableentry) * n); for (j = 0; j < n; j++) { table[i][j].b = j; } for (j = 0; j < state->packets_collected; j++) { // fullkeybuf[0] = state->allsessions[j].iv[0]; memcpy( fullkeybuf, state->allsessions[j].iv, 3 * sizeof(uint8_t)); guesskeybytes(i + 3, fullkeybuf, state->allsessions[j].keystream, guessbuf, 1); table[i][guessbuf[0]].votes += state->allsessions[j].weight; } qsort(&table[i][0], n, sizeof(PTW_tableentry), &compare); j = 0; while (!validchars[i][table[i][j].b]) { j++; } // printf("guessing i = %d, b = %d\n", i, table[0][0].b); fullkeybuf[i + 3] = table[i][j].b; } if (correct(state, &fullkeybuf[3], keylen)) { memcpy(keybuf, &fullkeybuf[3], keylen * sizeof(uint8_t)); // printf("hit without correction\n"); return (FAILURE); } } if (!(attacks & NO_PTW)) { memcpy(table, state->table, sizeof(PTW_tableentry) * n * keylen); onestrong = (testlimit / 10) * 2; twostrong = (testlimit / 10) * 1; simple = testlimit - onestrong - twostrong; // now, sort the table for (i = 0; i < keylen; i++) { qsort(&table[i][0], n, sizeof(PTW_tableentry), &compare); strongbytes[i] = 0; } sh = alloca(sizeof(sorthelper) * (n - 1) * keylen); ALLEGE(sh != NULL); for (i = 0; i < keylen; i++) { for (j = 1; j < n; j++) { sh[i][j - 1].distance = table[i][0].votes - table[i][j].votes; sh[i][j - 1].value = table[i][j].b; sh[i][j - 1].keybyte = i; } } qsort(sh, (n - 1) * keylen, sizeof(sorthelper), &comparesorthelper); if (doComputation(state, keybuf, keylen, table, (sorthelper *) sh, strongbytes, simple, bf, validchars)) { return (FAILURE); } // Now one strong byte getdrv(state->table, keylen, normal, ausreisser); for (i = 0; i < keylen - 1; i++) { helper[i].keybyte = i + 1; helper[i].difference = normal[i + 1] - ausreisser[i + 1]; } qsort(helper, keylen - 1, sizeof(doublesorthelper), &comparedoublesorthelper); // do not use bf-bytes as strongbytes i = 0; while (bf[helper[i].keybyte] == 1) { i++; } strongbytes[helper[i].keybyte] = 1; if (doComputation(state, keybuf, keylen, table, (sorthelper *) sh, strongbytes, onestrong, bf, validchars)) { return (FAILURE); } // two strong bytes i++; while (bf[helper[i].keybyte] == 1) { i++; } strongbytes[helper[i].keybyte] = 1; if (doComputation(state, keybuf, keylen, table, (sorthelper *) sh, strongbytes, twostrong, bf, validchars)) { return (FAILURE); } } return (SUCCESS); } /* * Add a new session to the attack * state - state of attack * iv - IV used in the session * keystream - recovered keystream from the session */ int PTW_addsession(PTW_attackstate * state, uint8_t * iv, uint8_t * keystream, int * weight, int total) { REQUIRE(state != NULL); REQUIRE(iv != NULL); REQUIRE(keystream != NULL); REQUIRE(weight != NULL); int i, j; int il; int ir; uint8_t buf[PTW_KEYHSBYTES]; i = (iv[0] << 16) | (iv[1] << 8) | (iv[2]); il = i / 8; ir = 1 << (i % 8); if ((state->seen_iv[il] & ir) == 0) { state->seen_iv[il] |= ir; for (j = 0; j < total; j++) { state->packets_collected++; guesskeybytes( IVBYTES, iv, &keystream[KSBYTES * j], buf, PTW_KEYHSBYTES); for (i = 0; i < KEYHSBYTES; i++) { state->table[i][buf[i]].votes += weight[j]; } if (state->allsessions_size < state->packets_collected) { state->allsessions_size = state->allsessions_size << 1; PTW_session * tmp_allsessions = realloc(state->allsessions, state->allsessions_size * sizeof(PTW_session)); ALLEGE(tmp_allsessions != NULL); state->allsessions = tmp_allsessions; } memcpy(state->allsessions[state->packets_collected - 1].iv, iv, IVBYTES); memcpy(state->allsessions[state->packets_collected - 1].keystream, &keystream[KSBYTES * j], KSBYTES); state->allsessions[state->packets_collected - 1].weight = weight[j]; } if ((state->sessions_collected < CONTROLSESSIONS)) { memcpy(state->sessions[state->sessions_collected].iv, iv, IVBYTES); memcpy(state->sessions[state->sessions_collected].keystream, keystream, KSBYTES); state->sessions_collected++; } return (FAILURE); } else { return (SUCCESS); } } /* * Allocate a new attackstate */ PTW_attackstate * PTW_newattackstate(void) { int i, k; PTW_attackstate * state = NULL; state = malloc(sizeof(PTW_attackstate)); ALLEGE(state != NULL); memset(state, 0, sizeof(PTW_attackstate)); for (i = 0; i < PTW_KEYHSBYTES; i++) { for (k = 0; k < n; k++) { state->table[i][k].b = k; } } state->allsessions = malloc(4096 * sizeof(PTW_session)); ALLEGE(state->allsessions != NULL); state->allsessions_size = 4096; return state; } /* * Free an allocated attackstate */ void PTW_freeattackstate(PTW_attackstate * state) { free(state->allsessions); free(state); return; } aircrack-ng-1.6/lib/radiotap/000077500000000000000000000000001361312141100161035ustar00rootroot00000000000000aircrack-ng-1.6/lib/radiotap/.gitignore000066400000000000000000000001061361312141100200700ustar00rootroot00000000000000*.o *~ parse build *.so CMakeCache.txt CMakeFiles cmake_install.cmake aircrack-ng-1.6/lib/radiotap/CMakeLists.txt000066400000000000000000000013631361312141100206460ustar00rootroot00000000000000cmake_minimum_required(VERSION 2.6) project(radiotap) add_definitions("-D_BSD_SOURCE -DRADIOTAP_SUPPORT_OVERRIDES") add_library(radiotap SHARED radiotap.c) set_target_properties(radiotap PROPERTIES COMPILE_FLAGS "-Wall -Wextra") install(TARGETS radiotap DESTINATION lib) install(FILES radiotap.h radiotap_iter.h DESTINATION include) add_executable(parse parse.c) set_target_properties(parse PROPERTIES COMPILE_FLAGS "-Wall -Wextra") target_link_libraries(parse radiotap) add_custom_target(radiotap_check ALL COMMAND ${CMAKE_SOURCE_DIR}/check/check.sh ${CMAKE_BINARY_DIR} DEPENDS ${CMAKE_SOURCE_DIR}/check/* WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/check/ COMMENT "Check examples") add_dependencies(radiotap_check parse) aircrack-ng-1.6/lib/radiotap/COPYING000066400000000000000000000014641361312141100171430ustar00rootroot00000000000000Copyright (c) 2007-2009 Andy Green Copyright (c) 2007-2009 Johannes Berg Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. aircrack-ng-1.6/lib/radiotap/check/000077500000000000000000000000001361312141100171605ustar00rootroot00000000000000aircrack-ng-1.6/lib/radiotap/check/0.bin000066400000000000000000000000201361312141100200010ustar00rootroot00000000000000"3DUfwaircrack-ng-1.6/lib/radiotap/check/0.out000066400000000000000000000000331361312141100200440ustar00rootroot00000000000000 TSFT: 9833440827789222417 aircrack-ng-1.6/lib/radiotap/check/00.bin000066400000000000000000000000401361312141100200630ustar00rootroot00000000000000 "3DUfwaircrack-ng-1.6/lib/radiotap/check/00.out000066400000000000000000000000661361312141100201320ustar00rootroot00000000000000 TSFT: 9833440827789222417 TSFT: 1225260500033256362 aircrack-ng-1.6/lib/radiotap/check/0fcs.args000066400000000000000000000000111361312141100206610ustar00rootroot00000000000000--fcshdr aircrack-ng-1.6/lib/radiotap/check/0fcs.bin000066400000000000000000000000241361312141100205010ustar00rootroot00000000000000@"3DUfwaircrack-ng-1.6/lib/radiotap/check/0fcs.out000066400000000000000000000000641361312141100205440ustar00rootroot00000000000000 TSFT: 9833440827789222417 FCS in header: ddccbbaa aircrack-ng-1.6/lib/radiotap/check/0v0-2.bin000066400000000000000000000000601361312141100204120ustar00rootroot000000000000000"3DUfwaircrack-ng-1.6/lib/radiotap/check/0v0-2.out000066400000000000000000000000661361312141100204570ustar00rootroot00000000000000 TSFT: 9833440827789222417 TSFT: 1225260500033256362 aircrack-ng-1.6/lib/radiotap/check/0v0-3.bin000066400000000000000000000000601361312141100204130ustar00rootroot000000000000000"3DUfwaircrack-ng-1.6/lib/radiotap/check/0v0-3.out000066400000000000000000000001451361312141100204560ustar00rootroot00000000000000 TSFT: 9833440827789222417 vendor NS (00-00-00:1, 4 bytes) ff ee dd cc TSFT: 1225260500033256362 aircrack-ng-1.6/lib/radiotap/check/0v0-4.bin000066400000000000000000000000701361312141100204150ustar00rootroot000000000000008"3DUfwaircrack-ng-1.6/lib/radiotap/check/0v0-4.out000066400000000000000000000001231361312141100204530ustar00rootroot00000000000000 TSFT: 9833440827789222417 00:00:00-00|52: ff/ee/dd/cc TSFT: 1225260500033256362 aircrack-ng-1.6/lib/radiotap/check/0v0.bin000066400000000000000000000000601361312141100202530ustar00rootroot000000000000000"3DUfwaircrack-ng-1.6/lib/radiotap/check/0v0.out000066400000000000000000000001221361312141100203110ustar00rootroot00000000000000 TSFT: 9833440827789222417 00:00:00-00|0: ff/ee/dd/cc TSFT: 1225260500033256362 aircrack-ng-1.6/lib/radiotap/check/1.bin000066400000000000000000000000111361312141100200020ustar00rootroot00000000000000 3aircrack-ng-1.6/lib/radiotap/check/1.out000066400000000000000000000000131361312141100200430ustar00rootroot00000000000000 flags: 33 aircrack-ng-1.6/lib/radiotap/check/check.sh000077500000000000000000000003661361312141100206010ustar00rootroot00000000000000#!/bin/sh bin="$1/parse" for t in *.bin ; do echo -n "Checking $t: " args="" base="$(basename "$t" .bin)" if [ -f "$base.args" ] ; then args="$(cat "$base.args")" fi "$bin" $args $t | diff "$base.out" - && echo "OK" || echo "FAIL" done aircrack-ng-1.6/lib/radiotap/check/malformed-vendor.bin000066400000000000000000000000421361312141100231070ustar00rootroot00000000000000".H aircrack-ng-1.6/lib/radiotap/check/malformed-vendor.out000066400000000000000000000001031361312141100231440ustar00rootroot00000000000000 flags: 10 rate: 1.000000 RX flags: 0000 malformed radiotap data aircrack-ng-1.6/lib/radiotap/check/unparsed-vendor.bin000066400000000000000000000000471361312141100227670ustar00rootroot00000000000000'.H ޭaircrack-ng-1.6/lib/radiotap/check/unparsed-vendor.out000066400000000000000000000001461361312141100230260ustar00rootroot00000000000000 flags: 10 rate: 1.000000 RX flags: 0000 vendor NS (ff-ff-ff:255, 2 bytes) de ad rate: 2.000000 aircrack-ng-1.6/lib/radiotap/parse.c000066400000000000000000000100321361312141100173550ustar00rootroot00000000000000#include #include #include #include #include #include #include #include #if defined(__APPLE__) #include #else #include #endif #include "radiotap_iter.h" static int fcshdr = 0; static const struct radiotap_align_size align_size_000000_00[] = { [0] = { .align = 1, .size = 4, }, [52] = { .align = 1, .size = 4, }, }; static const struct ieee80211_radiotap_namespace vns_array[] = { { .oui = 0x000000, .subns = 0, .n_bits = sizeof(align_size_000000_00), .align_size = align_size_000000_00, }, }; static const struct ieee80211_radiotap_vendor_namespaces vns = { .ns = vns_array, .n_ns = sizeof(vns_array)/sizeof(vns_array[0]), }; static void print_radiotap_namespace(struct ieee80211_radiotap_iterator *iter) { switch (iter->this_arg_index) { case IEEE80211_RADIOTAP_TSFT: printf("\tTSFT: %llu\n", le64toh(*(unsigned long long *)iter->this_arg)); break; case IEEE80211_RADIOTAP_FLAGS: printf("\tflags: %02x\n", *iter->this_arg); break; case IEEE80211_RADIOTAP_RATE: printf("\trate: %lf\n", (double)*iter->this_arg/2); break; case IEEE80211_RADIOTAP_CHANNEL: case IEEE80211_RADIOTAP_FHSS: case IEEE80211_RADIOTAP_DBM_ANTSIGNAL: case IEEE80211_RADIOTAP_DBM_ANTNOISE: case IEEE80211_RADIOTAP_LOCK_QUALITY: case IEEE80211_RADIOTAP_TX_ATTENUATION: case IEEE80211_RADIOTAP_DB_TX_ATTENUATION: case IEEE80211_RADIOTAP_DBM_TX_POWER: case IEEE80211_RADIOTAP_ANTENNA: case IEEE80211_RADIOTAP_DB_ANTSIGNAL: case IEEE80211_RADIOTAP_DB_ANTNOISE: case IEEE80211_RADIOTAP_TX_FLAGS: break; case IEEE80211_RADIOTAP_RX_FLAGS: if (fcshdr) { printf("\tFCS in header: %.8x\n", le32toh(*(uint32_t *)iter->this_arg)); break; } printf("\tRX flags: %#.4x\n", le16toh(*(uint16_t *)iter->this_arg)); break; case IEEE80211_RADIOTAP_RTS_RETRIES: case IEEE80211_RADIOTAP_DATA_RETRIES: break; default: printf("\tBOGUS DATA\n"); break; } } static void print_test_namespace(struct ieee80211_radiotap_iterator *iter) { switch (iter->this_arg_index) { case 0: case 52: printf("\t00:00:00-00|%d: %.2x/%.2x/%.2x/%.2x\n", iter->this_arg_index, *iter->this_arg, *(iter->this_arg + 1), *(iter->this_arg + 2), *(iter->this_arg + 3)); break; default: printf("\tBOGUS DATA - vendor ns %d\n", iter->this_arg_index); break; } } static const struct radiotap_override overrides[] = { { .field = 14, .align = 4, .size = 4, } }; int main(int argc, char *argv[]) { struct ieee80211_radiotap_iterator iter; struct stat statbuf; int fd, err, fnidx = 1, i; void *data; if (argc != 2 && argc != 3) { fprintf(stderr, "usage: parse [--fcshdr] \n"); fprintf(stderr, " --fcshdr: read bit 14 as FCS\n"); return 2; } if (strcmp(argv[1], "--fcshdr") == 0) { fcshdr = 1; fnidx++; } fd = open(argv[fnidx], O_RDONLY); if (fd < 0) { fprintf(stderr, "cannot open file %s\n", argv[fnidx]); return 2; } if (fstat(fd, &statbuf)) { perror("fstat"); return 2; } data = mmap(NULL, statbuf.st_size, PROT_READ, MAP_SHARED, fd, 0); err = ieee80211_radiotap_iterator_init(&iter, data, statbuf.st_size, &vns); if (err) { printf("malformed radiotap header (init returns %d)\n", err); return 3; } if (fcshdr) { iter.overrides = overrides; iter.n_overrides = sizeof(overrides)/sizeof(overrides[0]); } while (!(err = ieee80211_radiotap_iterator_next(&iter))) { if (iter.this_arg_index == IEEE80211_RADIOTAP_VENDOR_NAMESPACE) { printf("\tvendor NS (%.2x-%.2x-%.2x:%d, %d bytes)\n", iter.this_arg[0], iter.this_arg[1], iter.this_arg[2], iter.this_arg[3], iter.this_arg_size - 6); for (i = 6; i < iter.this_arg_size; i++) { if (i % 8 == 6) printf("\t\t"); else printf(" "); printf("%.2x", iter.this_arg[i]); } printf("\n"); } else if (iter.is_radiotap_ns) print_radiotap_namespace(&iter); else if (iter.current_namespace == &vns_array[0]) print_test_namespace(&iter); } if (err != -ENOENT) { printf("malformed radiotap data\n"); return 3; } return 0; } aircrack-ng-1.6/lib/radiotap/platform.h000066400000000000000000000033241361312141100201020ustar00rootroot00000000000000#include #include #include #if defined(linux) || defined(Linux) || defined(__linux__) || defined(__linux) \ || defined(__gnu_linux__) #include #endif #if defined(__CYGWIN32__) || defined(CYGWIN) #include #include #endif #if defined(__APPLE__) #include #endif #if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) || defined(__MidnightBSD__) || defined(__NetBSD__) #include #include #endif #if defined(__SVR4) && defined(__sun__) #include #include #endif #ifndef le16_to_cpu #define le16_to_cpu le16toh #endif #ifndef le32_to_cpu #define le32_to_cpu le32toh #endif #if defined(_MSC_VER) // Microsoft #define EXPORT __declspec(dllexport) #define IMPORT __declspec(dllimport) #elif defined(__GNUC__) || defined(__llvm__) || defined(__clang__) || defined(__INTEL_COMPILER) #define EXPORT __attribute__((visibility("default"))) #define IMPORT #else // do nothing and hope for the best? #define EXPORT #define IMPORT #pragma warning Unknown dynamic link import/export semantics. #endif #if defined(RADIOTAP_FAST_UNALIGNED_ACCESS) #define get_unaligned(p) \ ({ \ struct packed_dummy_struct { \ typeof(*(p)) __val; \ } __attribute__((packed)) *__ptr = (void *) (p); \ \ __ptr->__val; \ }) #else #define get_unaligned(p) \ ({ \ typeof(*(p)) __tmp; \ memmove(&__tmp, (p), sizeof(*(p))); \ __tmp; \ }) #endif #define get_unaligned_le16(p) le16_to_cpu(get_unaligned((uint16_t *)(p))) #define get_unaligned_le32(p) le32_to_cpu(get_unaligned((uint32_t *)(p))) #define UNALIGNED_ADDRESS(x) ((void*)(x)) aircrack-ng-1.6/lib/radiotap/radiotap.c000066400000000000000000000305521361312141100200570ustar00rootroot00000000000000/* * Radiotap parser * * Copyright 2007 Andy Green * Copyright 2009 Johannes Berg * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * Alternatively, this software may be distributed under the terms of ISC * license, see COPYING for more details. */ #include "radiotap_iter.h" #include "platform.h" /* function prototypes and related defs are in radiotap_iter.h */ static const struct radiotap_align_size rtap_namespace_sizes[] = { [IEEE80211_RADIOTAP_TSFT] = { .align = 8, .size = 8, }, [IEEE80211_RADIOTAP_FLAGS] = { .align = 1, .size = 1, }, [IEEE80211_RADIOTAP_RATE] = { .align = 1, .size = 1, }, [IEEE80211_RADIOTAP_CHANNEL] = { .align = 2, .size = 4, }, [IEEE80211_RADIOTAP_FHSS] = { .align = 2, .size = 2, }, [IEEE80211_RADIOTAP_DBM_ANTSIGNAL] = { .align = 1, .size = 1, }, [IEEE80211_RADIOTAP_DBM_ANTNOISE] = { .align = 1, .size = 1, }, [IEEE80211_RADIOTAP_LOCK_QUALITY] = { .align = 2, .size = 2, }, [IEEE80211_RADIOTAP_TX_ATTENUATION] = { .align = 2, .size = 2, }, [IEEE80211_RADIOTAP_DB_TX_ATTENUATION] = { .align = 2, .size = 2, }, [IEEE80211_RADIOTAP_DBM_TX_POWER] = { .align = 1, .size = 1, }, [IEEE80211_RADIOTAP_ANTENNA] = { .align = 1, .size = 1, }, [IEEE80211_RADIOTAP_DB_ANTSIGNAL] = { .align = 1, .size = 1, }, [IEEE80211_RADIOTAP_DB_ANTNOISE] = { .align = 1, .size = 1, }, [IEEE80211_RADIOTAP_RX_FLAGS] = { .align = 2, .size = 2, }, [IEEE80211_RADIOTAP_TX_FLAGS] = { .align = 2, .size = 2, }, [IEEE80211_RADIOTAP_RTS_RETRIES] = { .align = 1, .size = 1, }, [IEEE80211_RADIOTAP_DATA_RETRIES] = { .align = 1, .size = 1, }, [IEEE80211_RADIOTAP_MCS] = { .align = 1, .size = 3, }, [IEEE80211_RADIOTAP_AMPDU_STATUS] = { .align = 4, .size = 8, }, [IEEE80211_RADIOTAP_VHT] = { .align = 2, .size = 12, }, [IEEE80211_RADIOTAP_TIMESTAMP] = { .align = 8, .size = 12, }, /* * add more here as they are defined in radiotap.h */ }; static const struct ieee80211_radiotap_namespace radiotap_ns = { .n_bits = sizeof(rtap_namespace_sizes) / sizeof(rtap_namespace_sizes[0]), .align_size = rtap_namespace_sizes, }; /** * ieee80211_radiotap_iterator_init - radiotap parser iterator initialization * @iterator: radiotap_iterator to initialize * @radiotap_header: radiotap header to parse * @max_length: total length we can parse into (eg, whole packet length) * * Returns: 0 or a negative error code if there is a problem. * * This function initializes an opaque iterator struct which can then * be passed to ieee80211_radiotap_iterator_next() to visit every radiotap * argument which is present in the header. It knows about extended * present headers and handles them. * * How to use: * call __ieee80211_radiotap_iterator_init() to init a semi-opaque iterator * struct ieee80211_radiotap_iterator (no need to init the struct beforehand) * checking for a good 0 return code. Then loop calling * __ieee80211_radiotap_iterator_next()... it returns either 0, * -ENOENT if there are no more args to parse, or -EINVAL if there is a problem. * The iterator's @this_arg member points to the start of the argument * associated with the current argument index that is present, which can be * found in the iterator's @this_arg_index member. This arg index corresponds * to the IEEE80211_RADIOTAP_... defines. * * Radiotap header length: * You can find the CPU-endian total radiotap header length in * iterator->max_length after executing ieee80211_radiotap_iterator_init() * successfully. * * Alignment Gotcha: * You must take care when dereferencing iterator.this_arg * for multibyte types... the pointer is not aligned. Use * get_unaligned((type *)iterator.this_arg) to dereference * iterator.this_arg for type "type" safely on all arches. * * Example code: parse.c */ EXPORT int ieee80211_radiotap_iterator_init( struct ieee80211_radiotap_iterator *iterator, struct ieee80211_radiotap_header *radiotap_header, int max_length, const struct ieee80211_radiotap_vendor_namespaces *vns) { /* must at least have the radiotap header */ if (max_length < (int)sizeof(struct ieee80211_radiotap_header)) return -EINVAL; /* Linux only supports version 0 radiotap format */ if (radiotap_header->it_version) return -EINVAL; /* sanity check for allowed length and radiotap length field */ if (max_length < get_unaligned_le16(UNALIGNED_ADDRESS(&radiotap_header->it_len))) return -EINVAL; iterator->_rtheader = radiotap_header; iterator->_max_length = get_unaligned_le16(UNALIGNED_ADDRESS(&radiotap_header->it_len)); iterator->_arg_index = 0; iterator->_bitmap_shifter = get_unaligned_le32(UNALIGNED_ADDRESS(&radiotap_header->it_present)); iterator->_arg = (uint8_t *)radiotap_header + sizeof(*radiotap_header); iterator->_reset_on_ext = 0; iterator->_next_bitmap = UNALIGNED_ADDRESS(&radiotap_header->it_present); iterator->_next_bitmap++; iterator->_vns = vns; iterator->current_namespace = &radiotap_ns; iterator->is_radiotap_ns = 1; #ifdef RADIOTAP_SUPPORT_OVERRIDES iterator->n_overrides = 0; iterator->overrides = NULL; #endif /* find payload start allowing for extended bitmap(s) */ if (iterator->_bitmap_shifter & (1<_arg - (unsigned long)iterator->_rtheader + sizeof(uint32_t) > (unsigned long)iterator->_max_length) return -EINVAL; while (get_unaligned_le32(iterator->_arg) & (1 << IEEE80211_RADIOTAP_EXT)) { iterator->_arg += sizeof(uint32_t); /* * check for insanity where the present bitmaps * keep claiming to extend up to or even beyond the * stated radiotap header length */ if ((unsigned long)iterator->_arg - (unsigned long)iterator->_rtheader + sizeof(uint32_t) > (unsigned long)iterator->_max_length) return -EINVAL; } iterator->_arg += sizeof(uint32_t); /* * no need to check again for blowing past stated radiotap * header length, because ieee80211_radiotap_iterator_next * checks it before it is dereferenced */ } iterator->this_arg = iterator->_arg; /* we are all initialized happily */ return 0; } static void find_ns(struct ieee80211_radiotap_iterator *iterator, uint32_t oui, uint8_t subns) { int i; iterator->current_namespace = NULL; if (!iterator->_vns) return; for (i = 0; i < iterator->_vns->n_ns; i++) { if (iterator->_vns->ns[i].oui != oui) continue; if (iterator->_vns->ns[i].subns != subns) continue; iterator->current_namespace = &iterator->_vns->ns[i]; break; } } #ifdef RADIOTAP_SUPPORT_OVERRIDES static int find_override(struct ieee80211_radiotap_iterator *iterator, int *align, int *size) { int i; if (!iterator->overrides) return 0; for (i = 0; i < iterator->n_overrides; i++) { if (iterator->_arg_index == iterator->overrides[i].field) { *align = iterator->overrides[i].align; *size = iterator->overrides[i].size; if (!*align) /* erroneous override */ return 0; return 1; } } return 0; } #endif /** * ieee80211_radiotap_iterator_next - return next radiotap parser iterator arg * @iterator: radiotap_iterator to move to next arg (if any) * * Returns: 0 if there is an argument to handle, * -ENOENT if there are no more args or -EINVAL * if there is something else wrong. * * This function provides the next radiotap arg index (IEEE80211_RADIOTAP_*) * in @this_arg_index and sets @this_arg to point to the * payload for the field. It takes care of alignment handling and extended * present fields. @this_arg can be changed by the caller (eg, * incremented to move inside a compound argument like * IEEE80211_RADIOTAP_CHANNEL). The args pointed to are in * little-endian format whatever the endianness of your CPU. * * Alignment Gotcha: * You must take care when dereferencing iterator.this_arg * for multibyte types... the pointer is not aligned. Use * get_unaligned((type *)iterator.this_arg) to dereference * iterator.this_arg for type "type" safely on all arches. */ EXPORT int ieee80211_radiotap_iterator_next( struct ieee80211_radiotap_iterator *iterator) { while (1) { int hit = 0; int pad, align, size, subns; uint32_t oui; /* if no more EXT bits, that's it */ if ((iterator->_arg_index % 32) == IEEE80211_RADIOTAP_EXT && !(iterator->_bitmap_shifter & 1)) return -ENOENT; if (!(iterator->_bitmap_shifter & 1)) goto next_entry; /* arg not present */ /* get alignment/size of data */ switch (iterator->_arg_index % 32) { case IEEE80211_RADIOTAP_RADIOTAP_NAMESPACE: case IEEE80211_RADIOTAP_EXT: align = 1; size = 0; break; case IEEE80211_RADIOTAP_VENDOR_NAMESPACE: align = 2; size = 6; break; default: #ifdef RADIOTAP_SUPPORT_OVERRIDES if (find_override(iterator, &align, &size)) { /* all set */ } else #endif if (!iterator->current_namespace || iterator->_arg_index >= iterator->current_namespace->n_bits) { if (iterator->current_namespace == &radiotap_ns) return -ENOENT; align = 0; } else { align = iterator->current_namespace->align_size[iterator->_arg_index].align; size = iterator->current_namespace->align_size[iterator->_arg_index].size; } if (!align) { /* skip all subsequent data */ iterator->_arg = iterator->_next_ns_data; /* give up on this namespace */ iterator->current_namespace = NULL; goto next_entry; } break; } /* * arg is present, account for alignment padding * * Note that these alignments are relative to the start * of the radiotap header. There is no guarantee * that the radiotap header itself is aligned on any * kind of boundary. * * The above is why get_unaligned() is used to dereference * multibyte elements from the radiotap area. */ pad = ((unsigned long)iterator->_arg - (unsigned long)iterator->_rtheader) & (align - 1); if (pad) iterator->_arg += align - pad; if (iterator->_arg_index % 32 == IEEE80211_RADIOTAP_VENDOR_NAMESPACE) { int vnslen; if ((unsigned long)iterator->_arg + size - (unsigned long)iterator->_rtheader > (unsigned long)iterator->_max_length) return -EINVAL; oui = (*iterator->_arg << 16) | (*(iterator->_arg + 1) << 8) | *(iterator->_arg + 2); subns = *(iterator->_arg + 3); find_ns(iterator, oui, subns); vnslen = get_unaligned_le16(iterator->_arg + 4); iterator->_next_ns_data = iterator->_arg + size + vnslen; if (!iterator->current_namespace) size += vnslen; } /* * this is what we will return to user, but we need to * move on first so next call has something fresh to test */ iterator->this_arg_index = iterator->_arg_index; iterator->this_arg = iterator->_arg; iterator->this_arg_size = size; /* internally move on the size of this arg */ iterator->_arg += size; /* * check for insanity where we are given a bitmap that * claims to have more arg content than the length of the * radiotap section. We will normally end up equalling this * max_length on the last arg, never exceeding it. */ if ((unsigned long)iterator->_arg - (unsigned long)iterator->_rtheader > (unsigned long)iterator->_max_length) return -EINVAL; /* these special ones are valid in each bitmap word */ switch (iterator->_arg_index % 32) { case IEEE80211_RADIOTAP_VENDOR_NAMESPACE: iterator->_reset_on_ext = 1; iterator->is_radiotap_ns = 0; /* * If parser didn't register this vendor * namespace with us, allow it to show it * as 'raw. Do do that, set argument index * to vendor namespace. */ iterator->this_arg_index = IEEE80211_RADIOTAP_VENDOR_NAMESPACE; if (!iterator->current_namespace) hit = 1; goto next_entry; case IEEE80211_RADIOTAP_RADIOTAP_NAMESPACE: iterator->_reset_on_ext = 1; iterator->current_namespace = &radiotap_ns; iterator->is_radiotap_ns = 1; goto next_entry; case IEEE80211_RADIOTAP_EXT: /* * bit 31 was set, there is more * -- move to next u32 bitmap */ iterator->_bitmap_shifter = get_unaligned_le32(iterator->_next_bitmap); iterator->_next_bitmap++; if (iterator->_reset_on_ext) iterator->_arg_index = 0; else iterator->_arg_index++; iterator->_reset_on_ext = 0; break; default: /* we've got a hit! */ hit = 1; next_entry: iterator->_bitmap_shifter >>= 1; iterator->_arg_index++; } /* if we found a valid arg earlier, return it now */ if (hit) return 0; } } aircrack-ng-1.6/lib/radiotap/radiotap.h000066400000000000000000000153611361312141100200650ustar00rootroot00000000000000/* * Copyright (c) 2017 Intel Deutschland GmbH * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef __RADIOTAP_H #define __RADIOTAP_H #if defined(__APPLE__) #include #define bswap_16 OSSwapInt16 #define bswap_32 OSSwapInt32 #define bswap_64 OSSwapInt64 #include #ifndef le16toh #define le16toh(x) OSSwapLittleToHostInt16(x) #endif #ifndef le32toh #define le32toh(x) OSSwapLittleToHostInt32(x) #endif #ifndef le64toh #define le64toh(x) OSSwapLittleToHostInt64(x) #endif #endif /** * struct ieee82011_radiotap_header - base radiotap header */ struct ieee80211_radiotap_header { /** * @it_version: radiotap version, always 0 */ uint8_t it_version; /** * @it_pad: padding (or alignment) */ uint8_t it_pad; /** * @it_len: overall radiotap header length */ uint16_t it_len; /** * @it_present: (first) present word */ uint32_t it_present; } __packed; /* version is always 0 */ #define PKTHDR_RADIOTAP_VERSION 0 /* see the radiotap website for the descriptions */ enum ieee80211_radiotap_presence { IEEE80211_RADIOTAP_TSFT = 0, IEEE80211_RADIOTAP_FLAGS = 1, IEEE80211_RADIOTAP_RATE = 2, IEEE80211_RADIOTAP_CHANNEL = 3, IEEE80211_RADIOTAP_FHSS = 4, IEEE80211_RADIOTAP_DBM_ANTSIGNAL = 5, IEEE80211_RADIOTAP_DBM_ANTNOISE = 6, IEEE80211_RADIOTAP_LOCK_QUALITY = 7, IEEE80211_RADIOTAP_TX_ATTENUATION = 8, IEEE80211_RADIOTAP_DB_TX_ATTENUATION = 9, IEEE80211_RADIOTAP_DBM_TX_POWER = 10, IEEE80211_RADIOTAP_ANTENNA = 11, IEEE80211_RADIOTAP_DB_ANTSIGNAL = 12, IEEE80211_RADIOTAP_DB_ANTNOISE = 13, IEEE80211_RADIOTAP_RX_FLAGS = 14, IEEE80211_RADIOTAP_TX_FLAGS = 15, IEEE80211_RADIOTAP_RTS_RETRIES = 16, IEEE80211_RADIOTAP_DATA_RETRIES = 17, /* 18 is XChannel, but it's not defined yet */ IEEE80211_RADIOTAP_MCS = 19, IEEE80211_RADIOTAP_AMPDU_STATUS = 20, IEEE80211_RADIOTAP_VHT = 21, IEEE80211_RADIOTAP_TIMESTAMP = 22, /* valid in every it_present bitmap, even vendor namespaces */ IEEE80211_RADIOTAP_RADIOTAP_NAMESPACE = 29, IEEE80211_RADIOTAP_VENDOR_NAMESPACE = 30, IEEE80211_RADIOTAP_EXT = 31 }; /* for IEEE80211_RADIOTAP_FLAGS */ enum ieee80211_radiotap_flags { IEEE80211_RADIOTAP_F_CFP = 0x01, IEEE80211_RADIOTAP_F_SHORTPRE = 0x02, IEEE80211_RADIOTAP_F_WEP = 0x04, IEEE80211_RADIOTAP_F_FRAG = 0x08, IEEE80211_RADIOTAP_F_FCS = 0x10, IEEE80211_RADIOTAP_F_DATAPAD = 0x20, IEEE80211_RADIOTAP_F_BADFCS = 0x40, }; /* for IEEE80211_RADIOTAP_CHANNEL */ enum ieee80211_radiotap_channel_flags { IEEE80211_CHAN_CCK = 0x0020, IEEE80211_CHAN_OFDM = 0x0040, IEEE80211_CHAN_2GHZ = 0x0080, IEEE80211_CHAN_5GHZ = 0x0100, IEEE80211_CHAN_DYN = 0x0400, IEEE80211_CHAN_HALF = 0x4000, IEEE80211_CHAN_QUARTER = 0x8000, }; /* for IEEE80211_RADIOTAP_RX_FLAGS */ enum ieee80211_radiotap_rx_flags { IEEE80211_RADIOTAP_F_RX_BADPLCP = 0x0002, }; /* for IEEE80211_RADIOTAP_TX_FLAGS */ enum ieee80211_radiotap_tx_flags { IEEE80211_RADIOTAP_F_TX_FAIL = 0x0001, IEEE80211_RADIOTAP_F_TX_CTS = 0x0002, IEEE80211_RADIOTAP_F_TX_RTS = 0x0004, IEEE80211_RADIOTAP_F_TX_NOACK = 0x0008, }; /* for IEEE80211_RADIOTAP_MCS "have" flags */ enum ieee80211_radiotap_mcs_have { IEEE80211_RADIOTAP_MCS_HAVE_BW = 0x01, IEEE80211_RADIOTAP_MCS_HAVE_MCS = 0x02, IEEE80211_RADIOTAP_MCS_HAVE_GI = 0x04, IEEE80211_RADIOTAP_MCS_HAVE_FMT = 0x08, IEEE80211_RADIOTAP_MCS_HAVE_FEC = 0x10, IEEE80211_RADIOTAP_MCS_HAVE_STBC = 0x20, }; enum ieee80211_radiotap_mcs_flags { IEEE80211_RADIOTAP_MCS_BW_MASK = 0x03, IEEE80211_RADIOTAP_MCS_BW_20 = 0, IEEE80211_RADIOTAP_MCS_BW_40 = 1, IEEE80211_RADIOTAP_MCS_BW_20L = 2, IEEE80211_RADIOTAP_MCS_BW_20U = 3, IEEE80211_RADIOTAP_MCS_SGI = 0x04, IEEE80211_RADIOTAP_MCS_FMT_GF = 0x08, IEEE80211_RADIOTAP_MCS_FEC_LDPC = 0x10, IEEE80211_RADIOTAP_MCS_STBC_MASK = 0x60, IEEE80211_RADIOTAP_MCS_STBC_1 = 1, IEEE80211_RADIOTAP_MCS_STBC_2 = 2, IEEE80211_RADIOTAP_MCS_STBC_3 = 3, IEEE80211_RADIOTAP_MCS_STBC_SHIFT = 5, }; /* for IEEE80211_RADIOTAP_AMPDU_STATUS */ enum ieee80211_radiotap_ampdu_flags { IEEE80211_RADIOTAP_AMPDU_REPORT_ZEROLEN = 0x0001, IEEE80211_RADIOTAP_AMPDU_IS_ZEROLEN = 0x0002, IEEE80211_RADIOTAP_AMPDU_LAST_KNOWN = 0x0004, IEEE80211_RADIOTAP_AMPDU_IS_LAST = 0x0008, IEEE80211_RADIOTAP_AMPDU_DELIM_CRC_ERR = 0x0010, IEEE80211_RADIOTAP_AMPDU_DELIM_CRC_KNOWN = 0x0020, }; /* for IEEE80211_RADIOTAP_VHT */ enum ieee80211_radiotap_vht_known { IEEE80211_RADIOTAP_VHT_KNOWN_STBC = 0x0001, IEEE80211_RADIOTAP_VHT_KNOWN_TXOP_PS_NA = 0x0002, IEEE80211_RADIOTAP_VHT_KNOWN_GI = 0x0004, IEEE80211_RADIOTAP_VHT_KNOWN_SGI_NSYM_DIS = 0x0008, IEEE80211_RADIOTAP_VHT_KNOWN_LDPC_EXTRA_OFDM_SYM = 0x0010, IEEE80211_RADIOTAP_VHT_KNOWN_BEAMFORMED = 0x0020, IEEE80211_RADIOTAP_VHT_KNOWN_BANDWIDTH = 0x0040, IEEE80211_RADIOTAP_VHT_KNOWN_GROUP_ID = 0x0080, IEEE80211_RADIOTAP_VHT_KNOWN_PARTIAL_AID = 0x0100, }; enum ieee80211_radiotap_vht_flags { IEEE80211_RADIOTAP_VHT_FLAG_STBC = 0x01, IEEE80211_RADIOTAP_VHT_FLAG_TXOP_PS_NA = 0x02, IEEE80211_RADIOTAP_VHT_FLAG_SGI = 0x04, IEEE80211_RADIOTAP_VHT_FLAG_SGI_NSYM_M10_9 = 0x08, IEEE80211_RADIOTAP_VHT_FLAG_LDPC_EXTRA_OFDM_SYM = 0x10, IEEE80211_RADIOTAP_VHT_FLAG_BEAMFORMED = 0x20, }; enum ieee80211_radiotap_vht_coding { IEEE80211_RADIOTAP_CODING_LDPC_USER0 = 0x01, IEEE80211_RADIOTAP_CODING_LDPC_USER1 = 0x02, IEEE80211_RADIOTAP_CODING_LDPC_USER2 = 0x04, IEEE80211_RADIOTAP_CODING_LDPC_USER3 = 0x08, }; /* for IEEE80211_RADIOTAP_TIMESTAMP */ enum ieee80211_radiotap_timestamp_unit_spos { IEEE80211_RADIOTAP_TIMESTAMP_UNIT_MASK = 0x000F, IEEE80211_RADIOTAP_TIMESTAMP_UNIT_MS = 0x0000, IEEE80211_RADIOTAP_TIMESTAMP_UNIT_US = 0x0001, IEEE80211_RADIOTAP_TIMESTAMP_UNIT_NS = 0x0003, IEEE80211_RADIOTAP_TIMESTAMP_SPOS_MASK = 0x00F0, IEEE80211_RADIOTAP_TIMESTAMP_SPOS_BEGIN_MDPU = 0x0000, IEEE80211_RADIOTAP_TIMESTAMP_SPOS_PLCP_SIG_ACQ = 0x0010, IEEE80211_RADIOTAP_TIMESTAMP_SPOS_EO_PPDU = 0x0020, IEEE80211_RADIOTAP_TIMESTAMP_SPOS_EO_MPDU = 0x0030, IEEE80211_RADIOTAP_TIMESTAMP_SPOS_UNKNOWN = 0x00F0, }; enum ieee80211_radiotap_timestamp_flags { IEEE80211_RADIOTAP_TIMESTAMP_FLAG_64BIT = 0x00, IEEE80211_RADIOTAP_TIMESTAMP_FLAG_32BIT = 0x01, IEEE80211_RADIOTAP_TIMESTAMP_FLAG_ACCURACY = 0x02, }; #endif /* __RADIOTAP_H */ aircrack-ng-1.6/lib/radiotap/radiotap_iter.h000066400000000000000000000061071361312141100211060ustar00rootroot00000000000000#ifndef __RADIOTAP_ITER_H #define __RADIOTAP_ITER_H #include #include "radiotap.h" #include "platform.h" /* Radiotap header iteration * implemented in radiotap.c */ struct radiotap_override { uint8_t field; uint8_t align:4, size:4; }; struct radiotap_align_size { uint8_t align:4, size:4; }; struct ieee80211_radiotap_namespace { const struct radiotap_align_size *align_size; int n_bits; uint32_t oui; uint8_t subns; }; struct ieee80211_radiotap_vendor_namespaces { const struct ieee80211_radiotap_namespace *ns; int n_ns; }; /** * struct ieee80211_radiotap_iterator - tracks walk thru present radiotap args * @this_arg_index: index of current arg, valid after each successful call * to ieee80211_radiotap_iterator_next() * @this_arg: pointer to current radiotap arg; it is valid after each * call to ieee80211_radiotap_iterator_next() but also after * ieee80211_radiotap_iterator_init() where it will point to * the beginning of the actual data portion * @this_arg_size: length of the current arg, for convenience * @current_namespace: pointer to the current namespace definition * (or internally %NULL if the current namespace is unknown) * @is_radiotap_ns: indicates whether the current namespace is the default * radiotap namespace or not * * @overrides: override standard radiotap fields * @n_overrides: number of overrides * * @_rtheader: pointer to the radiotap header we are walking through * @_max_length: length of radiotap header in cpu byte ordering * @_arg_index: next argument index * @_arg: next argument pointer * @_next_bitmap: internal pointer to next present u32 * @_bitmap_shifter: internal shifter for curr u32 bitmap, b0 set == arg present * @_vns: vendor namespace definitions * @_next_ns_data: beginning of the next namespace's data * @_reset_on_ext: internal; reset the arg index to 0 when going to the * next bitmap word * * Describes the radiotap parser state. Fields prefixed with an underscore * must not be used by users of the parser, only by the parser internally. */ struct ieee80211_radiotap_iterator { struct ieee80211_radiotap_header *_rtheader; const struct ieee80211_radiotap_vendor_namespaces *_vns; const struct ieee80211_radiotap_namespace *current_namespace; unsigned char *_arg, *_next_ns_data; uint32_t *_next_bitmap; unsigned char *this_arg; const struct radiotap_override *overrides; /* Only for RADIOTAP_SUPPORT_OVERRIDES */ int n_overrides; /* Only for RADIOTAP_SUPPORT_OVERRIDES */ int this_arg_index; int this_arg_size; int is_radiotap_ns; int _max_length; int _arg_index; uint32_t _bitmap_shifter; int _reset_on_ext; }; #ifdef __cplusplus #define CALLING_CONVENTION "C" #else #define CALLING_CONVENTION #endif IMPORT extern CALLING_CONVENTION int ieee80211_radiotap_iterator_init( struct ieee80211_radiotap_iterator *iterator, struct ieee80211_radiotap_header *radiotap_header, int max_length, const struct ieee80211_radiotap_vendor_namespaces *vns); IMPORT extern CALLING_CONVENTION int ieee80211_radiotap_iterator_next( struct ieee80211_radiotap_iterator *iterator); #endif /* __RADIOTAP_ITER_H */ aircrack-ng-1.6/manpages/000077500000000000000000000000001361312141100153255ustar00rootroot00000000000000aircrack-ng-1.6/manpages/Makefile.am000066400000000000000000000057071361312141100173720ustar00rootroot00000000000000# Aircrack-ng # # Copyright (C) 2017 Joseph Benden # # Autotool support was written by: Joseph Benden # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA # # In addition, as a special exception, the copyright holders give # permission to link the code of portions of this program with the # OpenSSL library under certain conditions as described in each # individual source file, and distribute linked combinations # including the two. # # You must obey the GNU General Public License in all respects # for all of the code used other than OpenSSL. # # If you modify file(s) with this exception, you may extend this # exception to your dnl version of the file(s), but you are not obligated # to do so. # # If you dnl do not wish to do so, delete this exception statement from your # version. # # If you delete this exception statement from all source files in the # program, then also delete it here. dist_man1_MANS = aircrack-ng.1 \ airdecap-ng.1 \ packetforge-ng.1 \ ivstools.1 \ kstats.1 \ makeivs-ng.1 \ airdecloak-ng.1 dist_man8_MANS = airodump-ng-oui-update.8 if LINUX dist_man8_MANS += airmon-ng.8 endif if FREEBSD dist_man8_MANS += airmon-ng.8 endif if HAVE_AIRPCAP_OR_PCAP if HAVE_PCAP dist_man1_MANS += besside-ng-crawler.1 endif dist_man1_MANS += wpaclean.1 dist_man8_MANS += airbase-ng.8 \ aireplay-ng.8 \ airodump-ng.8 \ airserv-ng.8 \ airtun-ng.8 endif if HAVE_SQLITE3 dist_man1_MANS += airolib-ng.1 endif if EXPERIMENTAL dist_man1_MANS += buddy-ng.1 if HAVE_AIRPCAP_OR_PCAP dist_man8_MANS += airventriloquist-ng.8 \ besside-ng.8 \ easside-ng.8 \ tkiptun-ng.8 \ wesside-ng.8 endif endif EXTRA_DIST = airmon-ng.8.in \ airolib-ng.1.in \ besside-ng-crawler.1.in \ buddy-ng.1.in \ airventriloquist-ng.8.in \ besside-ng.8.in \ easside-ng.8.in \ tkiptun-ng.8.in \ wesside-ng.8.in \ wpaclean.1.in \ airbase-ng.8.in \ aireplay-ng.8.in \ airodump-ng.8.in \ airserv-ng.8.in \ airtun-ng.8.in aircrack-ng-1.6/manpages/airbase-ng.8.in000066400000000000000000000266461361312141100200510ustar00rootroot00000000000000.TH AIRBASE-NG 8 "@MAN_RELEASE_DATE@" "@MAN_RELEASE_VERSION@" .SH NAME airbase-ng - multi-purpose tool aimed at attacking clients as opposed to the Access Point (AP) itself .SH SYNOPSIS .B airbase-ng [options] .SH DESCRIPTION .BI airbase-ng is multi-purpose tool aimed at attacking clients as opposed to the Access Point (AP) itself. Since it is so versatile and flexible, summarizing it is a challenge. Here are some of the feature highlights: .PP - Implements the Caffe Latte WEP client attack .br - Implements the Hirte WEP client attack .br - Ability to cause the WPA/WPA2 handshake to be captured .br - Ability to act as an ad-hoc Access Point .br - Ability to act as a full Access Point .br - Ability to filter by SSID or client MAC addresses .br - Ability to manipulate and resend packets .br - Ability to encrypt sent packets and decrypt received packets .PP The main idea is of the implementation is that it should encourage clients to associate with the fake AP, not prevent them from accessing the real AP. A tap interface (atX) is created when airbase-ng is run. This can be used to receive decrypted packets or to send encrypted packets. As real clients will most probably send probe requests for common/configured networks, these frames are important for binding a client to our softAP. In this case, the AP will respond to any probe request with a proper probe response, which tells the client to authenticate to the airbase-ng BSSID. That being said, this mode could possibly disrupt the correct functionality of many APs on the same channel. .SH OPTIONS .PP .TP .I -H, --help Shows the help screen. .TP .I -a If the BSSID is not explicitly specified by using "-a ", then the current MAC of the specified interface is used. .TP .I -i Also capture and process from this interface in addition to the replay interface. .TP .I -w If WEP should be used as encryption, then the parameter "-w " sets the en-/decryption key. This is sufficient to let airbase-ng set all the appropriate flags by itself. If the softAP operates with WEP encryption, the client can choose to use open system authentication or shared key authentication. Both authentication methods are supported by airbase-ng. But to get a keystream, the user can try to force the client to use shared key authentication. "-s" forces a shared key auth and "-S " sets the challenge length. .TP .I -h This is the source MAC for the man-in-the-middle attack. The "-M" must also be specified. .TP .I -f If this option is not specified, it defaults to "-f allow". This means the various client MAC filters (-d and -D) define which clients to accept. By using the "-f disallow" option, this reverses selection and causes airbase to ignore the clients specified by the filters. .TP .I -W <0|1> This sets the beacon WEP flag. Remember that clients will normally only connect to APs which are the same as themselves. Meaning WEP to WEP, open to open. The "auto" option is to allow airbase-ng to automatically set the flag based on context of the other options specified. For example, if you set a WEP key with -w, then the beacon flag would be set to WEP. One other use of "auto" is to deal with clients which can automatically adjust their connection type. However, these are few and far between. In practice, it is best to set the value to the type of clients you are dealing with. .TP .I -q This suppresses printing any statistics or status information. .TP .I -v This prints additional messages and details to assist in debugging. .TP .I -M This option is not implemented yet. It is a man-in-the-middle attack between specified clients and BSSIDs. .TP .I -A, --ad-hoc This causes airbase-ng to act as an ad-hoc client instead of a normal Access Point. In ad-hoc mode airbase-ng also sends beacons, but doesn\(aqt need any authentication/association. It can be activated by using "-A". The soft AP will adjust all flags needed to simulate a station in ad-hoc mode automatically and generate a random MAC, which is used as CELL MAC instead of the BSSID. This can be overwritten by the "-a " tag. The interface MAC will then be used as source mac, which can be changed with "-h ". .TP .I -Y The parameter "-Y" enables the "external processing" Mode. This creates a second interface "atX", which is used to replay/modify/drop or inject packets at will. This interface must also be brought up with ifconfig and an external tool is needed to create a loop on that interface. The packet structure is rather simple: the ethernet header (14 bytes) is ignored and right after that follows the complete ieee80211 frame the same way it is going to be processed by airbase-ng (for incoming packets) or before the packets will be sent out of the wireless card (outgoing packets). This mode intercepts all data packets and loops them through an external application, which decides what happens with them. The MAC and IP of the second tap interface doesn\(aqt matter, as real ethernet frames on this interface are dropped anyway. There are 3 arguments for "-Y": "in", "out" and "both", which specify the direction of frames to loop through the external application. Obviously "in" redirects only incoming (through the wireless NIC) frames, while outgoing frames aren\(aqt touched. "out" does the opposite, it only loops outgoing packets and "both" sends all both directions through the second tap interface. There is a small and simple example application to replay all frames on the second interface. The tool is called "replay.py" and is located in "./test". It\(aqs written in python, but the language doesn\(aqt matter. It uses pcapy to read the frames and scapy to possibly alter/show and reinject the frames. The tool as it is, simply replays all frames and prints a short summary of the received frames. The variable "packet" contains the complete ieee80211 packet, which can easily be dissected and modified using scapy. This can be compared to ettercap filters, but is more powerful, as a real programming language can be used to build complex logic for filtering and packet customization. The downside on using python is, that it adds a delay of around 100ms and the cpu utilizations is rather large on a high speed network, but its perfect for a demonstration with only a few lines of code. .TP .I -c This is used to specify the channel on which to run the Access Point. .TP .I -X, --hidden This causes the Access Point to hide the SSID and to not broadcast the value. .TP .I -s When specfiied, this forces shared key authentication for all clients. The soft AP will send an "authentication method unsupported" rejection to any open system authentication request if "-s" is specified. .TP .I -S It sets the shared key challenge length, which can be anything from 16 to 1480. The default is 128 bytes. It is the number of bytes used in the random challenge. Since one tag can contain a maximum size of 255 bytes, any value above 255 creates several challenge tags until all specified bytes are written. Many clients ignore values different than 128 bytes so this option may not always work. .TP .I -L, --caffe-latte Airbase-ng also contains the new caffe-latte attack, which is also implemented in aireplay-ng as attack "-6". It can be used with "-L" or "caffe-latte". This attack specifically works against clients, as it waits for a broadcast arp request, which happens to be a gratuitous arp. See this for an explanation of what a gratuitous arp is. It then flips a few bits in the sender MAC and IP, corrects the ICV (crc32) value and sends it back to the client, where it came from. The point why this attack works in practice is, that at least windows sends gratuitous arps after a connection on layer 2 is established and a static ip is set, or dhcp fails and windows assigned an IP out of 169.254.X.X. "-x " sets the number of packets per second to send when performing the caffe-latte attack. At the moment, this attack doesn\(aqt stop, it continuously sends arp requests. Airodump-ng is needed to capture the replies. .TP .I -N, --cfrag This attack listens for an ARP request or IP packet from the client. Once one is received, a small amount of PRGA is extracted and then used to create an ARP request packet targeted to the client. This ARP request is actually made of up of multiple packet fragments such that when received, the client will respond. This attack works especially well against ad-hoc networks. As well it can be used against softAP clients and normal AP clients. .TP .I -x This sets the number of packets per second that packets will be sent (default: 100). .TP .I -y When using this option, the fake AP will not respond to broadcast probes. A broadcast probe is where the specific AP is not identified uniquely. Typically, most APs will respond with probe responses to a broadcast probe. This flag will prevent this happening. It will only respond when the specific AP is uniquely requested. .TP .I -0 This enables all WPA/WPA2/WEP Tags to be enabled in the beacons sent. It cannot be specified when also using -z or -Z. .TP .I -z This specifies the WPA beacon tags. The valid values are: 1=WEP40 2=TKIP 3=WRAP 4=CCMP 5=WEP104. .TP .I -Z same as -z, but for WPA2 .TP .I -V This specifies the valid EAPOL types. The valid values are: 1=MD5 2=SHA1 3=auto .TP .I -F This option causes airbase-ng to write all sent and received packets to a pcap file on disk. This is the file prefix (like airodump-ng -w). .TP .I -P This causes the fake access point to respond to all probes regardless of the ESSIDs specified. .TP .I -I This sets the time in milliseconds between each beacon. .TP .I -C The wildcard ESSIDs will also be beaconed this number of seconds. A good typical value to use is "-C 60" (require -P). .TP .I -n ANonce (nonce from the AP) to use instead of a randomized one. It must be 64 hexadecimal characters. .PP .TP .B Filter options: .TP .I --bssid , -b BSSID to filter/use. .TP .I --bssids , -B Read a list of BSSIDs out of that file. .TP .I --client , -d MAC of client to accept. .TP .I --clients , -D Read a list of client\(aqs MACs out of that file. .TP .I --essid , -e Specify a single ESSID. For SSID containing special characters, see https://www.aircrack-ng.org/doku.php?id=faq#how_to_use_spaces_double_quote_and_single_quote_etc_in_ap_names .TP .I --essids , -E Read a list of ESSIDs out of that file. It will use the same BSSID for all AP which can generate some interesting output in Airodump-ng like: http://www.chimplabs.com/blog/2015/09/24/unintentional-fun-with-aircrack-ng-at-derbycon-5-0/ .SH AUTHOR This manual page was written by Thomas d\(aqOtreppe. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 2 or any later version published by the Free Software Foundation On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL. .PP .SH SEE ALSO .br .B aireplay-ng(8) .br .B airmon-ng(8) .br .B airodump-ng(8) .br .B airodump-ng-oui-update(8) .br .B airserv-ng(8) .br .B airtun-ng(8) .br .B besside-ng(8) .br .B easside-ng(8) .br .B tkiptun-ng(8) .br .B wesside-ng(8) .br .B aircrack-ng(1) .br .B airdecap-ng(1) .br .B airdecloak-ng(1) .br .B airolib-ng(1) .br .B besside-ng-crawler(1) .br .B buddy-ng(1) .br .B ivstools(1) .br .B kstats(1) .br .B makeivs-ng(1) .br .B packetforge-ng(1) .br .B wpaclean(1) .br .B airventriloquist(8) aircrack-ng-1.6/manpages/aircrack-ng.1.in000066400000000000000000000166061361312141100202060ustar00rootroot00000000000000.TH AIRCRACK-NG 1 "@MAN_RELEASE_DATE@" "@MAN_RELEASE_VERSION@" .SH NAME aircrack-ng - a 802.11 WEP / WPA-PSK key cracker .SH SYNOPSIS .B aircrack-ng [options] .SH DESCRIPTION .BI aircrack-ng is an 802.11 WEP, 802.11i WPA/WPA2, and 802.11w WPA2 key cracking program. .PP It can recover the WEP key once enough encrypted packets have been captured with airodump-ng. This part of the aircrack-ng suite determines the WEP key using two fundamental methods. The first method is via the PTW approach (Pyshkin, Tews, Weinmann). The main advantage of the PTW approach is that very few data packets are required to crack the WEP key. The second method is the FMS/KoreK method. The FMS/KoreK method incorporates various statistical attacks to discover the WEP key and uses these in combination with brute forcing. .PP Additionally, the program offers a dictionary method for determining the WEP key. For cracking WPA/WPA2 pre-shared keys, a wordlist (file or stdin) or an airolib-ng has to be used. .SH INPUT FILES .TP Capture files (.cap, .pcap), IVS (.ivs) or Hashcat HCCAPX files (.hccapx) .SH OPTIONS .TP .B Common options: .TP .I -a Force the attack mode: 1 or wep for WEP (802.11) and 2 or wpa for WPA/WPA2 PSK (802.11i and 802.11w). .TP .I -e Select the target network based on the ESSID. This option is also required for WPA cracking if the SSID is cloaked. For SSID containing special characters, see https://www.aircrack-ng.org/doku.php?id=faq#how_to_use_spaces_double_quote_and_single_quote_etc_in_ap_names .TP .I -b or --bssid Select the target network based on the access point MAC address. .TP .I -p Set this option to the number of CPUs to use (only available on SMP systems) for cracking the key/passphrase. By default, it uses all available CPUs .TP .I -q If set, no status information is displayed. .TP .I -C or --combine Merges all those APs MAC (separated by a comma) into a virtual one. .TP .I -l Write the key into a file. Overwrites the file if it already exists. .PP .TP .B Static WEP cracking options: .TP .I -c Search alpha-numeric characters only. .TP .I -t Search binary coded decimal characters only. .TP .I -h Search the numeric key for Fritz!BOX .TP .I -d or --debug Specify mask of the key. For example: A1:XX:CF .TP .I -m Only keep the IVs coming from packets that match this MAC address. Alternatively, use \-m ff:ff:ff:ff:ff:ff to use all and every IVs, regardless of the network (this disables ESSID and BSSID filtering). .TP .I -n Specify the length of the key: 64 for 40-bit WEP, 128 for 104-bit WEP, etc., until 512 bits of length. The default value is 128. .TP .I -i Only keep the IVs that have this key index (1 to 4). The default behavior is to ignore the key index in the packet, and use the IV regardless. .TP .I -f By default, this parameter is set to 2. Use a higher value to increase the bruteforce level: cracking will take more time, but with a higher likelihood of success. .TP .I -k There are 17 KoreK attacks. Sometimes one attack creates a huge false positive that prevents the key from being found, even with lots of IVs. Try \-k 1, \-k 2, ... \-k 17 to disable each attack selectively. .TP .I -x or -x0 Disable last keybytes bruteforce (not advised). .TP .I -x1 Enable last keybyte bruteforcing (default) .TP .I -x2 Enable last two keybytes bruteforcing. .TP .I -X Disable bruteforce multithreading (SMP only). .TP .I -s Shows ASCII version of the key at the right of the screen. .TP .I -y This is an experimental single brute-force attack which should only be used when the standard attack mode fails with more than one million IVs. .TP .I -z Uses PTW (Andrei Pyshkin, Erik Tews and Ralf-Philipp Weinmann) attack (default attack). .TP .I -P or --ptw-debug PTW debug: 1 Disable klein, 2 PTW. .TP .I -K Use KoreK attacks instead of PTW. .TP .I -D or --wep-decloak WEP decloak mode. .TP .I -1 or --oneshot Run only 1 try to crack key with PTW. .TP .I -M Specify maximum number of IVs to use. .TP .I -V or --visual-inspection Run in visual inspection mode. Can only be used when using KoreK. .PP .TP .B WEP and WPA-PSK cracking options .TP .I -w Path to a dictionary file for wpa cracking. Separate filenames with comma when using multiple dictionaries. Specify "-" to use stdin. Here is a list of wordlists: https://www.aircrack-ng.org/doku.php?id=faq#where_can_i_find_good_wordlists In order to use a dictionary with hexadecimal values, prefix the dictionary with "h:". Each byte in each key must be separated by ':'. When using with WEP, key length should be specified using -n. .TP .I -N or --new-session Create a new cracking session. It allows one to interrupt cracking session and restart at a later time (using -R or --restore-session). Status files are saved every 5 minutes. It does not overwrite existing session file. .TP .I -R or --restore-session Restore and continue a previously saved cracking session. This parameter is to be used alone, no other parameter should be specified when starting aircrack-ng (all the required information is in the session file). .PP .TP .B WPA-PSK options: .TP .I -E Create Elcomsoft Wireless Security Auditor (EWSA) Project file v3.02. .TP .I -j Create Hashcat v3.6+ Capture file (HCCAPX). .TP .I -J Create Hashcat Capture file (HCCAP). .TP .I -S WPA cracking speed test. .TP .I -Z WPA cracking speed test execution length in seconds. .TP .I -r Path to the airolib-ng database. Cannot be used with \(aq-w\(aq. .PP .TP .B SIMD selection: .TP .I --simd=