Repository: rfidtool/ESP-RFID-Tool Branch: master Commit: b0bb4cc692af Files: 25 Total size: 153.9 KB Directory structure: gitextract_t2rxqmyl/ ├── .gitignore ├── Connector-Adapter-Options/ │ ├── Punchdown-Adapter-1/ │ │ ├── BOM │ │ └── Image-Credits.txt │ ├── Punchdown-Adapter-2/ │ │ ├── BOM │ │ └── Image-Credits.txt │ └── README.md ├── Images/ │ └── README.md ├── Installation-Schematics/ │ └── README.md ├── Keypad/ │ └── README.md ├── LICENSE ├── Magstripe/ │ ├── README.md │ └── aba-decode.php ├── README.md └── Source Code/ └── esprfidtool/ ├── HelpText.h ├── LICENSE ├── License.h ├── WiegandNG.cpp ├── WiegandNG.h ├── aba2str.h ├── api.h ├── api_server.h ├── esprfidtool.ino ├── pinSEND.h ├── strrev.h └── version.h ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ *bin ================================================ FILE: Connector-Adapter-Options/Punchdown-Adapter-1/BOM ================================================ Choose the wire gauge, purchase (2) of the "2 WAY" terminals and purchase the appropriate punch down tool. The combination of parts below are currently untested. Tool Punch Down Tool Hand Tools ASSEMBLY BIT INSUL DIA 1.60; Mfr. #: 069176701602000 ; Mouser Part #: 581-069176701602000 Choose your targets wiring size below. * I found that you can abuse a 20AWG connector to accept from 24-20AWG wire, an 18AWG connector would not skin 24AWG wire in my tests. Research is still ongoing regarding an officially recommended connector. 18AWG IDC Punch Down Block (D0),(D1) IDC Terminal - 2 way Desc.: 2 WAY WIRE TO BD 18 AWG STRANDED ; Mfr. #: 009176002001006; Mouser Part #: 581-009176002001006 (+),(-) IDC Terminal - 2 way Desc.: 2 WAY WIRE TO BD 18 AWG STRANDED ; Mfr. #: 009176002001006; Mouser Part #: 581-009176002001006 20AWG IDC Punch Down Block * (D0),(D1) IDC Terminal - 2 way Desc.: 2 WAY WIRE TO BD 20 AWG STRANDED ; Mfr. #: 009176002011006; Mouser Part #: 581-009176002011006 (+),(-) IDC Terminal - 2 way Desc.: 2 WAY WIRE TO BD 20 AWG STRANDED ; Mfr. #: 009176002011006; Mouser Part #: 581-009176002011006 22AWG IDC Punch Down (D0),(D1) IDC Terminal - 2 way Desc.: 2 WAY WIRE TO BD 22 AWG STRANDED; Mfr. #: 009176002022006; Mouser Part #: 581-009176002022006 (+),(-) IDC Terminal - 2 way Desc.: 2 WAY WIRE TO BD 22 AWG STRANDED; Mfr. #: 009176002022006; Mouser Part #: 581-009176002022006 24AWG IDC Punch Down (D0),(D1) IDC Terminal - 2 way Desc.: 2 WAY WIRE TO BD 24 AWG STRANDED; Mfr. #: 009176002032006; Mouser Part #: 581-009176002032006 (+),(-) IDC Terminal - 2 way Desc.: 2 WAY WIRE TO BD 24 AWG STRANDED; Mfr. #: 009176002032006; Mouser Part #: 581-009176002032006 ================================================ FILE: Connector-Adapter-Options/Punchdown-Adapter-1/Image-Credits.txt ================================================ PCB renders generated using https://pcbs.io. ================================================ FILE: Connector-Adapter-Options/Punchdown-Adapter-2/BOM ================================================ Choose the wire gauge, purchase (2) of the "2 WAY" terminals and purchase the appropriate punch down tool. The combination of parts below are currently untested. Tool Punch Down Tool Hand Tools ASSEMBLY BIT INSUL DIA 1.60; Mfr. #: 069176701602000 ; Mouser Part #: 581-069176701602000 Choose your targets wiring size below. * I found that you can abuse a 20AWG connector to accept from 24-20AWG wire, an 18AWG connector would not skin 24AWG wire in my tests. Research is still ongoing regarding an officially recommended connector. 18AWG IDC Punch Down Block (D0),(D1) IDC Terminal - 2 way Desc.: 2 WAY WIRE TO BD 18 AWG STRANDED ; Mfr. #: 009176002001006; Mouser Part #: 581-009176002001006 (+),(-) IDC Terminal - 2 way Desc.: 2 WAY WIRE TO BD 18 AWG STRANDED ; Mfr. #: 009176002001006; Mouser Part #: 581-009176002001006 20AWG IDC Punch Down Block * (D0),(D1) IDC Terminal - 2 way Desc.: 2 WAY WIRE TO BD 20 AWG STRANDED ; Mfr. #: 009176002011006; Mouser Part #: 581-009176002011006 (+),(-) IDC Terminal - 2 way Desc.: 2 WAY WIRE TO BD 20 AWG STRANDED ; Mfr. #: 009176002011006; Mouser Part #: 581-009176002011006 22AWG IDC Punch Down (D0),(D1) IDC Terminal - 2 way Desc.: 2 WAY WIRE TO BD 22 AWG STRANDED; Mfr. #: 009176002022006; Mouser Part #: 581-009176002022006 (+),(-) IDC Terminal - 2 way Desc.: 2 WAY WIRE TO BD 22 AWG STRANDED; Mfr. #: 009176002022006; Mouser Part #: 581-009176002022006 24AWG IDC Punch Down (D0),(D1) IDC Terminal - 2 way Desc.: 2 WAY WIRE TO BD 24 AWG STRANDED; Mfr. #: 009176002032006; Mouser Part #: 581-009176002032006 (+),(-) IDC Terminal - 2 way Desc.: 2 WAY WIRE TO BD 24 AWG STRANDED; Mfr. #: 009176002032006; Mouser Part #: 581-009176002032006 ================================================ FILE: Connector-Adapter-Options/Punchdown-Adapter-2/Image-Credits.txt ================================================ PCB renders generated using https://pcbs.io. ================================================ FILE: Connector-Adapter-Options/README.md ================================================ ## Connector Options ### Standard Screwdown Connection ![ScrewDown](screwdown.jpg?raw=true) ![ScrewDown-Portable-5375](portable-5375.jpg?raw=true) ### Gray Wire Nuts 22-16AWG ![Wire-Nuts](wirenuts.jpg?raw=true) ##### Note: For 24AWG you need to twist the wires and fold them over once to obtain a secure connection or use smaller wire nuts(They make a 24-18AWG which is perfect but color varies). Gray Wire Nuts are common though and can be found in most hardware stores. ### Screwdown to T-Taps (Wire Splices) #### T-Tap Example 1 ![T-Tap1](tsplice1.jpg?raw=true) * Uxcell T-Tap Male Insulated Wire Terminal Quick Connector Combo Set 10 Piece, Red * by Uxcell [$6.82 on Amazon](http://a.co/6joYNzS) ##### Note: These may require a light squeeze on the connector with pliers to cut past the insulation properly. Links are not suggested brands but simply examples. #### T-Tap Example 2 * Brightfour Quick Wire Splice Connector-T type 1 Pin solderless- Compatible with 22 - 20 AWG Cable for Some Tight-fitting Automotive Uses * by Brightfour [$8.44 on Amazon](http://a.co/bAw7Fdw) ##### Note: These may require a light squeeze on the connector with pliers to cut past the insulation properly. Links are not suggested brands but simply examples. ### Screwdown to Punchdown Adapter ##### PCB renders generated using https://pcbs.io. #### Side by Side * [Gerber File](Punchdown-Adapter-1/punchdown-adapter-Gerber.zip) * [BOM File](Punchdown-Adapter-1/BOM) * [Order PCB](https://pcbs.io/share/4KXmA) ![Punchdown1](punchdown.jpg?raw=true) ![Punchdown1-top](Punchdown-Adapter-1/top-adapter.png?raw=true) ![Punchdown1-bottom](Punchdown-Adapter-1/bottom-adapter.png?raw=true) #### Perpendicular * [Gerber File](Punchdown-Adapter-2/punchdown-adapter2-Gerber.zip) * [BOM File](Punchdown-Adapter-2/BOM) * [Order PCB](https://pcbs.io/share/zy0jg) The image pictured below is a custom build with the programming header removed, and the screwdown block replaced by a 4 pin header which was soldered in place and then broken off once the adapter was added on. I easily performed all of these modifications by hand using both a soldering iron and hot air rework station. ![Punchdown2-Custom](pd2-custom.jpg?raw=true) ![Punchdown2-top](Punchdown-Adapter-2/top-adapter2.png?raw=true) ![Punchdown2-bottom](Punchdown-Adapter-2/bottom-adapter2.png?raw=true) ================================================ FILE: Images/README.md ================================================ ![Logo](logo.png?raw=true) ![Board](board.jpg?raw=true) ![Wiring](wiring.jpg?raw=true) ![Programmer](programmer.jpg?raw=true) ================================================ FILE: Installation-Schematics/README.md ================================================ ![Implant](implant.png?raw=true) ![Portable-Standalone](portable-standalone.png?raw=true) ![Benchtop-PSU-Standalone](benchtop-psu.png?raw=true) ![Unsupported-Voltages](unsupported-voltages.png?raw=true) ![2-RFID-Tool-Units](2-rfid-tool-units.png?raw=true) ================================================ FILE: Keypad/README.md ================================================ ![HID-5355-Bin2Pin-Reference](../Images/5355keypad-bin2pin.jpg?raw=true) ================================================ FILE: LICENSE ================================================ MIT License Copyright (c) [2018] [Corey Harding] 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. ================================================ FILE: Magstripe/README.md ================================================ ## ABA Encoding Wiegand Magstripe Readers Tested: * HID 3110-6445 Magstripe Pass-Through Reader * set to rotary position B (Raw Data - All Bits Wiegand) * HID multiCLASS RM40 iCLASS/Magstripe Reader 6220CKN000B * purchase a reader with the last digit B in item # (ex: 6220CKN000**B**) RFID-Tool Specific Settings * set buffer size to 256 bits or greater See [aba-decode.php](aba-decode.php) script for converting binary card data to ascii (Script by: AndrewMohawk) * Command Line: /usr/bin/php aba-decode.php 1101000001100000100011001001001010101101111000001010011101101111100010 * Web: https://www.LegacySecurityGroup.com/aba-decode.php Binary: 5 bits Little Endian Format LRC(Longitudinal Redundancy Check): Count # of set bits(1's) in column EVEN = 0 ODD = 1 Track 2 Debit/Credit Card Format(for example, as I could not find actual magstripe access control cards): ;1234567890123456=YYMMSSSDDDDDDDDDDDDDD?* ; = Start Sentinel 1234567890123456 = 16 Digit Card # = = End Card # YY = Expiration Year MM = Expiration Month SSS = Service Code (As Understood From Wikipedia: "201" means chip required, "101" means no chip, be sure to recalculate the LRC if changing, it is not advised to experiment here without knowing the laws involved) DDDDDDDDDDDDDD = Discretionary Data ? = End Sentinel *=LRC Binary Reference: 11010 ; - Start Sentinel 00001 0 10000 1 01000 2 11001 3 00100 4 10101 5 01101 6 11100 7 00010 8 10011 9 00111 < 01110 > 01011 : 10110 = - End Card Number 11111 ? - End Sentinel 00010 LRC ================================================ FILE: Magstripe/aba-decode.php ================================================ "); } if (empty($binary)) { $binary = "1101000001100000100011001001001010101101111000001010011101101111100010"; } echo "https://github.com/rfidtool/ESP-RFID-Tool/blob/master/Magstripe/aba-decode.php" . LINEBREAK; echo "For converting Track 2 Magstripe ABA Binary data to ASCII" . LINEBREAK . LINEBREAK; echo "Original script by: AndrewMohawk" . LINEBREAK; // andrew@andrewmohawk.com echo "http://www.andrewmohawk.com" . LINEBREAK . LINEBREAK; echo "Modified slightly by: Corey Harding" . LINEBREAK; echo "www.LegacySecurityGroup.com / www.Exploit.Agency" . LINEBREAK . LINEBREAK; if (!defined('STDIN')) { ?>
strlen($haystack)) trigger_error(sprintf("%s: length of argument 2 must be <= argument 1", __FUNCTION__), E_USER_WARNING); $seeks = array(); while($seek = strrpos($haystack, $needle)) { array_push($seeks, $seek); $haystack = substr($haystack, 0, $seek); } return $seeks; } function processBinary($binary) { $AsciiOutput = ""; //find start sentinel $start_sentinel = strpos($binary,"11010"); if($start_sentinel === false) { echo "Could not find start sentinel" . LINEBREAK; return false; } //find end sentinel $end_sentinel = false; $end_sentinel = strrpos($binary,"11111"); if(count($end_sentinel) == 0) { echo "Could not find end sentinel" . LINEBREAK; return false; } //Lets decode the data: $bit_length = 5; // 4 bits for data, 1 bit for odd-parity or LRC checking $data = substr($binary,$start_sentinel,($end_sentinel-$start_sentinel+5)); $currentBits = ""; $currentNum = 0; $finalString = ""; for($i=0;$i=1.1.0 are compiled with esp8266 board manager package 2.4.1 * Releases < 1.1.0 are compiled with esp8266 board manager package 2.3.0 * Unofficial * Port of Tastic RFID Thief: https://github.com/exploitagency/ESP-RFID-Thief/releases ## Intended use cases * Security researchers performing red team assessments. * Capturing card values to later be cloned. * Replaying raw binary captures.*(see note below) * Fuzzing access control systems.*(see note below) * Brute forcing PIN codes.*(see note below) * Denial of Service mode.*(see note below) * To create a standalone device for capturing credentials or testing badges and or card readers without the need for a Wiegand Controller. * Add a battery and a card reader to make the unit portable. * Add a benchtop power supply to use for testing hardware. * Installers troubleshooting issues with a card reader, the data lines, or even testing for a faulty card. * Useful for merchants or surplus resellers who are testing if access control equipment is functional. * Hobbyist experimenting with various systems that utilize a Wiegand Interface. * Simulating an access control system using multiple units of ESP-RFID-Tool. * RFID-Tool is not intended to be used in any unlawful manner. ## What is it? A universal data logger that captures the raw binary data from a standard 5V Wiegand Interface. The device is capable of logging the credentials for access control systems or nearly any device that utilizes a Wiegand Interface such as RFID card readers, pin pads, magnetic stripe systems, barcode, and even some biometric readers. Wiegand Interfaces also do not have to be limited to just access control systems. The main target group for this device is 26-37bit HID cards. For known card types both the binary and hexadecimal data is displayed directly in the log file for easy badge identification and also in case a clone of a card may be needed. For unknown card types only the raw binary data is shown. ## How do you install it? The device may be installed directly into an existing system drawing its power from the preexisting wiring or it can also be used to turn a reader into a standalone portable unit for data logging when a battery is added. Wiring is simple and consists of 4 wires, (+), (-), D0(Green), and D1(White). The device is capable of operating on voltages ranging from around 4.5V up to a maximum of 12v. Commonly found voltages are 12V and 5V. **(See Installation Notes Below) ## How do you access the logs? Access to the log files and various settings is provided via a web based interface. The device has WiFi capabilities and can be set up to spawn its own access point or set to connect to an existing network. In the event you get locked out of the web interface you can bridge the J3 jumper on power up or while resetting the device to regain access without losing your log files. ## I want to know a little more... The hardware is based on an ESP12 WiFi chip with a full TCP/IP stack and Microcontroller Unit. The software is open source licensed under the MIT License and will be released the day the product is launched. The software will reside in this GitHub repo so it may be reviewed by the community. We will accept various pull requests from the community after being reviewed if it improves the value of the device for others. The software was written in the Arduino IDE so both hobbyist and professionals will have no issue modifying the code if they so choose. A Wiegand Interface operates using 3 wires, a ground, Data0, and Data1. A zero is sent when D0 goes low and a one is sent when D1 goes low, the other line remains high during this time. The timing is 40uS from low to high on a line with 2mS between bits. The software logs this binary output to a file and if the device thinks it is a known card format the preamble is guessed(not sent by card reader but it is the same for all cards of a specific format, our primary target is 26-37bit HID cards) and both the raw binary and hexadecimal data is logged. For unkown card formats only the raw binary output is logged with no guess at the preamble and without showing the data in hexadecimal format to prevent confusion. If you know what kind of card was captured, simply look up the preamble and add it to the beginning of the binary then typically convert it to hexadecimal format to make a clone of a card. It is possible the card is actually an unknown format and the preamble was guessed incorrectly with the device thinking it was a known card format(the guess is based on the bit count output by the reader), if this is the case in the log file there is a literal space in the binary between the preamble and the card data, simply ignore the preamble. When replaying a captured credential*(see note below) you do not include the preamble as that is not output by the card reader but instead you only replay*(see note below) the actual card data as output from the reader. You only need to worry about the preamble if making a clone of a card. The primary function of this device is for logging the raw binary data as output from a Wiegand Interface. You can read from 1 bit all the way up to 4,096 bits. The default buffer setting only allows 52 bits and must be manually increased from the settings page accessible from the web interface. ## *Experimental TX Mode The device was made with minimal hardware to keep costs extremely low and in reach of hobbyist and also so security professionals can buy multiple units and also use them without the fear of losing a unit. This being said there are no level shifters on the board.(It is possible that in the future a PRO version may be released) This means that with the current hardware the device can work with a 3V3 Wiegand Interface as well as a 5V Wiegand interface because the hardware operates at 3V3 and is also 5V tolerant. The drawback of this is that not all 5V Wiegand controllers are guaranteed to be triggered when replaying or fuzzing data because only 3V3 is output from the device. There is also a risk when the device is in TX mode and the output goes low for 40uS, if the device were to also receive data during this time there will be a short. For this reason be sure that absoulutely no cards are being scanned while the device is in TX mode. The device does not go into TX mode until you press on a form submit button and as soon as the data is done being transmitted it goes back into listening mode. For the reasons above TX mode is for experimental use only and was designed primarily for easily debugging the software when making changes.(two units were tied together) **Use transmit mode at your own risk, it is not officially supported. Consider it a bonus in the software.** ## **Installation Notes [Click here for wiring diagrams](Installation-Schematics/README.md) [Click here to see connector options](/Connector-Adapter-Options/README.md) * Make sure the reader outputs data in the Wiegand format * Connect D0 on device to D0 on reader * Connect D1 on device to D1 on reader * Connect + on device to + on reader * Connect - on device to - on reader * The ESP-RFID-Tool accepts 4.5-12v but you must also be sure to supply enough voltage and current to power your reader if creating a standalone or portable unit. * SAFETY: It has come to my attention that the voltage regulator used on the commercially available units that you may find for sale is different than the voltage regulator I originally chose for this project. Also due to global chip shortages and the possibility of manufacturers substituting components I am downgrading the absolute maximum voltage rating to 12v as in you may be stressing the unit to its limits at this voltage and extra care should be taken. Most of my smaller portable prototypes ran at around 9v(x6 AA Batteries) and I found this to be more than adequate, remember that you can always power your reader and the RFID-Tool unit separately if needed and I suggest supplying your project with the lowest possible voltage that you can get away with. In fact, I have found multiple readers that run just fine at less than the recommended voltage. Note that I did not notice a significant range increase in my original testing between supplying 12v and 24v to my reader(I do not recommend this as I tend to abuse the specs for what I am testing, and I was using a different voltage regulator in my prototype). Also be advised that most commonly used batteries produce more than the commonly stated nominal voltage at a full charge. It may also be a good idea to apply a heatsink to your voltage regulator especially if you notice that the unit runs hot at your chosen voltage. It is also never recommended to leave your device unattended. Please be safe and take all necessary safety precautions when testing your setup. * OPTIONAL: Connect 4.5-12v battery into the same + and -(only if building a portable unit, do not add a battery if implanting device into an existing installation, or if you do use a battery do not connect the + wire from the existing installation to your device, only tie in the GND -)   * NOTE: At a minimum D0, D1, and GND(-) must be connected to the reader for proper function, no matter the power source. * Configure settings * See Below ## Making Sense of the Binary Data [Keypads](Keypad/README.md) [Magstripe/ABA Format](Magstripe/README.md) ## Flashing Firmware OPTION 1: OTA via the Web Interface: * Download one of the latest releases from * https://github.com/rfidtool/ESP-RFID-Tool/releases * Login to the device's admin panel and upgrade the firmware. OPTION 2: Arduino IDE: * Use the ESP Flasher R4 by April Brother: * https://blog.aprbrother.com/product/esp-flasher-r4 * Clone/download the source. * Add these libraries: * ArduinoJson library 5.13.1 by Benoit Blanchon * https://github.com/bblanchon/ArduinoJson * ESP8266FtpServer.h * https://github.com/exploitagency/esp8266FTPServer/tree/feature/bbx10_speedup * Choose the board NodeMCU 1.0. * Upload. ## Software Help ### Accessing ESP-RFID-Tool Web Interface SSID: "ESP-RFID-Tool" URL: http://192.168.1.1 ### Configure ESP-RFID-Tool #### Default credentials to access the configuration page: * Username: "admin" * Password: "rfidtool" #### Default credentials for ftp server: * Username: "ftp-admin" * Password: "rfidtool" #### WiFi Configuration: Network Type: * Access Point Mode: Create a standalone access point(No Internet Connectivity-Requires Close Proximity) * Join Existing Network: Join an existing network(Possible Internet Connectivity-Could use Device Remotely) Hidden: Choose whether or not to use a hidden SSID when creating an access point SSID: SSID of the access point to create or of the network you are choosing to join Password: Password of the access point which you wish to create or of the network you are choosing to join Channel: Channel of the access point you are creating IP: IP to set for device Gateway: Gateway to use, make it the same as ESP-RFID-Tool's IP if an access point or the same as the router if joining a network Subnet: Typically set to 255.255.255.0 #### Web Interface Administration Settings: Username: Username to configure/upgrade ESP-RFID-Tool Password: Password to configure/upgrade ESP-RFID-Tool FTP Server Settings: Note: Supports Passive(PASV) Mode Only! * Enabled: Turn FTP Server ON * Disabled: Turn FTP Server OFF Username: Username to login to ftp server Password: Password to login to ftp server Power LED: * Enabled: Turn ON Power LED * Disabled: Turn OFF Power LED RFID Capture Log: Useful to change this value to differentiate between facilities during various security assessments. File Name: File name to save captured RFID tags to for the current security assessment. #### List Exfiltrated Data Displays all log files containing RFID tag captures. #### Format File System This will erase the contents of the SPIFFS file system including ALL RFID tag captures. Formatting may take up to 90 seconds. All current settings will be retained unless you reboot your device during this process. #### Upgrade ESP-RFID-Tool Firmware Authenticate using your username and password set in the configuration page. Default credentials to access the firmware upgrade page: * Username: "admin" * Password: "rfidtool" Select "Browse" choose the new firmware to be uploaded and then click "Upgrade". You will need to manually reset the device upon the browser alerting you that the upgrade was successful. #### Jumpers * J1: Bridge to reset the board(your FTDI doesn't have a reset button?) * J2: Cut the trace to disable DTR pin after programming then use it as an additional IO(continue updating firmware via web interface) * J3: Bridge this during a power cycle to restore default configuration without losing your log files. #### Restore Default Settings * Option 1: Go to settings under web interface and choose restore default configuration. * Option 2: Bridge J3 before booting the device. (Either before powering on or bridge it and reset the device) * Option 3: Connect via serial(9600 baud) and send the command "ResetDefaultConfig:" without quotes. ## History I pushed the design for the original prototype to GitHub back in September of 2016 albeit under a different repo. I was using an Adafruit Feather Huzzah running some code that I had modified porting the Tastic RFID Thief(by Fran Brown from Bishop Fox) to the ESP12S chip. At the time no sort of Wiegand logger existed offering WiFi capabilities and providing an easy to use web interface for accessing the log files.(I could not find one so I created it) During the second evolution of the project I decided to design dedicated hardware and I lightly upgraded the software. It was open source hardware and it was out there on GitHub but still not easily available to the masses. Not everyone is confident in surface mount soldering and even for me it was time consuming assembling boards for personal use. It was then that I realized there is a need for an affordable device like mine to be mass produced so anyone that has a legitimate for need one can have access to it. During the third stage I redesigned both the software and the hardware and decided to contact April Brother to see about them manufacturing it and selling it for a fair price. That is when ESP-RFID-Tool was born. ## Licensing Information Created by Corey Harding https://github.com/rfidtool/ESP-RFID-Tool ESP-RFID-Tool software is licensed under the MIT License #### Libraries/borrowed code being used ##### Arduino and ESP8266 core libraries * Typically: GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 * Assorted Authors ##### ArduinoJson.h * The MIT License (MIT) * Copyright (c) 2014-2017 Benoit BLANCHON ##### ESP8266FtpServer.h * GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 * Originally by nailbuster, later modified by bbx10 and apullin ##### WiegandNG.h * GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 * JP Liew ##### Wiegand Preamble Calculator Code * No License Specified * Fran Brown of Bishop Fox ##### strrev.h * Custom License(see file) * Copyright (c) 2007 Dmitry Xmelkov ##### aba-decode.py * No License Specified * Andrew MacPherson(andrewmohawk) ================================================ FILE: Source Code/esprfidtool/HelpText.h ================================================ const char HelpText[] PROGMEM = R"=====( ESP-RFID-Tool Help Page <- BACK TO INDEX

-----
HELP
-----

ESP-RFID-Tool

Created by Corey Harding
www.LegacySecurityGroup.com / www.Exploit.Agency
https://github.com/rfidtool/ESP-RFID-Tool - See Link for Updated Firmware or for more detailed Help

The ESP-RFID-Tool is a tool created for logging Wiegand data and also for testing devices that contain a Wiegand Interface. The primary target group is 26-37bit HID Cards but it will also work with most devices that output Wiegand data. ESP-RFID-Tool can be combined with a RFID reader and a battery to create a portable standalone RFID badge logger, it can also be integrated into existing systems without the need for a battery and instead drawing its power directly from the wiring in the existing installation. The ESP-RFID-Tool can read the data from any device that contains a Wiegand Interface and outputs data from 1 bit long up to 4,096 bits long, although anything other than 26-37bit is experimental. The ESP-RFID-Tool is not even limited to RFID technologies, many other devices also contain a Wiegand Interface as it is an access control system standard, this includes pin pads(keypad), magnetic stripe(magstripe), there are even non access control related devices that utilize a Wiegand Interface.

The ESP-RFID-Tool software is distributed under the MIT License. The license and copyright notice can not be removed and must be distributed alongside all future copies of the software.

-----
Accessing ESP-RFID-Tool Web Interface
-----

SSID: "ESP-RFID-Tool"
URL: http://192.168.1.1

-----
Configure ESP-RFID-Tool
-----

Default credentials to access the configuration page:
Username: "admin"
Password: "rfidtool"

Default credentials for ftp server:
Username: "ftp-admin"
Password: "rfidtool"

WiFi Configuration:

Network Type:
Access Point Mode: Create a standalone access point(No Internet Connectivity-Requires Close Proximity)
Join Existing Network: Join an existing network(Possible Internet Connectivity-Could use Device Remotely)

Hidden: Choose whether or not to use a hidden SSID when creating an access point

SSID: SSID of the access point to create or of the network you are choosing to join
Password: Password of the access point which you wish to create or of the network you are choosing to join
Channel: Channel of the access point you are creating

IP: IP to set for device
Gateway: Gateway to use, make it the same as ESP-RFID-Tool's IP if an access point or the same as the router if joining a network
Subnet: Typically set to 255.255.255.0

Web Interface Administration Settings:

Username: Username to configure/upgrade ESP-RFID-Tool
Password: Password to configure/upgrade ESP-RFID-Tool

FTP Server Settings:

Note: Supports Passive(PASV) Mode Only!
Enabled: Turn FTP Server ON
Disabled: Turn FTP Server OFF
Username: Username to login to ftp server
Password: Password to login to ftp server

Power LED:

Enabled: Turn ON Power LED
Disabled: Turn OFF Power LED

RFID Capture Log:

Useful to change this value to differentiate between facilities during various security assessments.
File Name: File name to save captured RFID tags to for the current security assessment.

-----
List Exfiltrated Data
-----

Displays all log files containing RFID tag captures.

-----
Format File System
-----

This will erase the contents of the SPIFFS file system including ALL RFID tag captures.
Formatting may take up to 90 seconds.
All current settings will be retained unless you reboot your device during this process.

-----
Upgrade ESP-RFID-Tool Firmware
-----

Authenticate using your username and password set in the configuration page.

Default credentials to access the firmware upgrade page:
Username: "admin"
Password: "rfidtool"

Select "Browse" choose the new firmware to be uploaded and then click "Upgrade".

You will need to manually reset the device upon the browser alerting you that the upgrade was successful.

-----
Licensing Information
-----

Created by Corey Harding
https://github.com/rfidtool/ESP-RFID-Tool
ESP-RFID-Tool software is licensed under the MIT License
/*
MIT License

Copyright (c) [2018] [Corey Harding]

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.
*/

Click here for additional licensing information )====="; ================================================ FILE: Source Code/esprfidtool/LICENSE ================================================ SOFTWARE LICENSE MIT License Copyright (c) [2018] [Corey Harding] 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. ================================================ FILE: Source Code/esprfidtool/License.h ================================================ const char License[] PROGMEM = R"=====( ESP-RFID-Tool Licensing Page <- BACK TO INDEX

ESP-RFID-Tool by Corey Harding: https://www.LegacySecurityGroup.com
Code available at: https://github.com/rfidtool/ESP-RFID-Tool

ESP-RFID-Tool Hardware was created by Corey Harding
ESP-RFID-Tool Software is licensed under the MIT License
/*
 MIT License

 Copyright (c) [2018] [Corey Harding]

 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.
*/

Core libraries used:

/*
 Arduino.h - Main include file for the Arduino SDK
 Copyright (c) 2005-2013 Arduino Team. All right reserved.
 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 library; if not, write to the Free Software
 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

/*
 ESP8266WiFi.h - esp8266 Wifi support.
 Based on WiFi.h from Arduino WiFi shield library.
 Copyright (c) 2011-2014 Arduino. All right reserved.
 Modified by Ivan Grokhotkov, December 2014
 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 library; if not, write to the Free Software
 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

/*
 WiFiClient.h - Library for Arduino Wifi shield.
 Copyright (c) 2011-2014 Arduino. All right reserved.
 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 library; if not, write to the Free Software
 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 Modified by Ivan Grokhotkov, December 2014 - esp8266 support
*/

/*
 ESP8266WebServer.h - Dead simple web-server.
 Supports only one simultaneous client, knows how to handle GET and POST.
 Copyright (c) 2014 Ivan Grokhotkov. All rights reserved.
 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 library; if not, write to the Free Software
 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 Modified 8 May 2015 by Hristo Gochkov (proper post and file upload handling)
*/

/*
 Esp8266httpupdateserver.h No license information available.
*/

/*
 ESP8266mDNS.h
 ESP8266 Multicast DNS (port of CC3000 Multicast DNS library)
 Version 1.1
 Copyright (c) 2013 Tony DiCola (tony@tonydicola.com)
 ESP8266 port (c) 2015 Ivan Grokhotkov (ivan@esp8266.com)
 Extended MDNS-SD support 2016 Lars Englund (lars.englund@gmail.com)
 This is a simple implementation of multicast DNS query support for an Arduino
 running on ESP8266 chip. Only support for resolving address queries is currently
 implemented.
 License (MIT license):
 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.
*/

/*
 FS.h - file system wrapper
 Copyright (c) 2015 Ivan Grokhotkov. All rights reserved.
 This file is part of the esp8266 core for Arduino environment.
 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 library; if not, write to the Free Software
 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

/*
 ArduinoJson.h
 The MIT License (MIT)
 ---------------------

 Copyright (c) 2014-2017 Benoit BLANCHON

 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.
*/

/*
 ESP8266FtpServer.h - by nailbuster, later modified by bbx10 and apullin
                   GNU LESSER GENERAL PUBLIC LICENSE
                       Version 2.1, February 1999
 https://github.com/apullin/esp8266FTPServer/blob/feature/bbx10_speedup/LICENSE
*/

/*
  WiegandNG.h by JP Liew
  https://github.com/jpliew/Wiegand-NG-Multi-Bit-Wiegand-Library-for-Arduino
  GNU LGPL License 2.1
  
  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.
*/

/*
  Wiegand Preamble Calculator Code from the Tastic RFID Thief byFran Brown of Bishop Fox
  https://www.bishopfox.com/resources/tools/rfid-hacking/attack-tools/
*/

/*
  Original source for aba-decode.py by Andrew MacPherson(andrewmohawk)
  https://andrewmohawk.com/2012/05/29/magnetic-stripes-part-1/
  https://pastebin.com/h9eVqRxz
*/

/*
  strrev.h by Dmitry Xmelkov
  Copyright (c) 2007  Dmitry Xmelkov
   All rights reserved.
   Redistribution and use in source and binary forms, with or without
   modification, are permitted provided that the following conditions are met:
   * Redistributions of source code must retain the above copyright
     notice, this list of conditions and the following disclaimer.
   * 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.
   * Neither the name of the copyright holders nor the names of
     contributors may be used to endorse or promote products derived
     from this software without specific prior written permission.
   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT OWNER 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.
*/

This is not a comprehensive list, these "Core Libraries" may depend on additional
libraries, more information can be obtained by viewing the source code of the main libraries.
)====="; ================================================ FILE: Source Code/esprfidtool/WiegandNG.cpp ================================================ #include "WiegandNG.h" // pcintbranch volatile unsigned long WiegandNG::_lastPulseTime; // time last bit pulse received volatile unsigned int WiegandNG::_bitCounted; // number of bits arrived at Interrupt pins volatile unsigned char *WiegandNG::_buffer; // buffer for data retention unsigned int WiegandNG::_bufferSize; // memory (bytes) allocated for buffer void shift_left(volatile unsigned char *ar, int size, int shift) { while (shift--) { // for each bit to shift ... int carry = 0; // clear the initial carry bit. int lastElement = size-1; for (int i = 0; i < size; i++) { // for each element of the array, from low byte to high byte if (i!=lastElement) { // condition ? valueIfTrue : valueIfFalse carry = (ar[i+1] & 0x80) ? 1 : 0; ar[i] = carry | (ar[i]<<1); } else { ar[i] <<=1; } } } } void WiegandNG::clear() { // reset variables to start new capture _bitCounted=0; _lastPulseTime = millis(); memset((unsigned char *)_buffer,0,_bufferSize); interrupts(); // allow interrupt } void WiegandNG::pause() { noInterrupts(); // disable interrupt so that user can process data } volatile unsigned char * WiegandNG::getRawData() { return _buffer; // return pointer of the buffer } unsigned int WiegandNG::getPacketGap() { return _packetGap; } unsigned int WiegandNG::getBitAllocated() { return _bitAllocated; } unsigned int WiegandNG::getBitCounted() { return _bitCounted; } unsigned int WiegandNG::getBufferSize() { return _bufferSize; } bool WiegandNG::available() { bool ret=false; noInterrupts(); unsigned long tempLastPulseTime = _lastPulseTime; interrupts(); unsigned long sysTick = millis(); // if ((sysTick - _lastPulseTime) > _packetGap) { // _packetGap (ms) laps if ((sysTick - tempLastPulseTime) > _packetGap) { // _packetGap (ms) laps if(_bitCounted>0) { // bits found, must have data, return true /*if(_bitCounted<8) { Serial.print(_bitCounted); Serial.print(", "); Serial.print(sysTick); Serial.print(", "); Serial.print(_lastPulseTime); Serial.print(","); Serial.println(tempLastPulseTime); }*/ ret=true; } else { _lastPulseTime = millis(); } } return ret; } void WiegandNG::ReadD0 () { _bitCounted++; // increment bit count for Interrupt connected to D0 shift_left(_buffer,_bufferSize,1); // shift 0 into buffer _lastPulseTime = millis(); // keep track of time last wiegand bit received } void WiegandNG::ReadD1() { _bitCounted++; // increment bit count for Interrupt connected to D1 if (_bitCounted > (_bufferSize * 8)) { _bitCounted=0; // overflowed, } else { shift_left(_buffer,_bufferSize,1); // shift 1 into buffer _buffer[_bufferSize-1] |=1; // set last bit 1 _lastPulseTime = millis(); // keep track of time last wiegand bit received } } bool WiegandNG::begin(unsigned int allocateBits, unsigned int packetGap) { bool ret; // newer versions of Arduino provide pin to interrupt mapping ret=begin(2, 3, allocateBits, packetGap); return ret; } bool WiegandNG::begin(uint8_t pinD0, uint8_t pinD1, unsigned int allocateBits, unsigned int packetGap) { if (_buffer != NULL) { delete [] _buffer; } _packetGap = packetGap; _bitAllocated = allocateBits; _bufferSize=(_bitAllocated/8); // calculate the number of bytes required to store wiegand bits if((_bitAllocated % 8) >0) _bufferSize++; // add 1 extra byte to cater for bits that are not divisible by 8 _buffer = new unsigned char [_bufferSize]; // allocate memory for buffer if(_buffer == NULL) return false; // not enough memory, return false clear(); pinMode(pinD0, INPUT); // set D0 pin as input pinMode(pinD1, INPUT); // set D1 pin as input attachInterrupt(digitalPinToInterrupt(pinD0), ReadD0, FALLING); // hardware interrupt - high to low pulse attachInterrupt(digitalPinToInterrupt(pinD1), ReadD1, FALLING); // hardware interrupt - high to low pulse return true; } WiegandNG::WiegandNG() { } WiegandNG::~WiegandNG() { if (_buffer != NULL) { delete [] _buffer; } } ================================================ FILE: Source Code/esprfidtool/WiegandNG.h ================================================ #ifndef _WIEGAND_NG_H #define _WIEGAND_NG_H #if defined(ARDUINO) && ARDUINO >= 100 #include "Arduino.h" #else #include "WProgram.h" #endif class WiegandNG { private: static void ReadD0(); static void ReadD1(); static volatile unsigned long _lastPulseTime; // time last bits received static volatile unsigned int _bitCounted; // number of bits arrived at Interrupt pins static unsigned int _bufferSize; // memory (bytes) allocated for buffer unsigned int _bitAllocated; // wiegand bits required unsigned int _packetGap; // gap between wiegand packet in millisecond static volatile unsigned char * _buffer; // buffer for data retention public: bool begin(unsigned int bits, unsigned int packetGap=25); // default packetGap is 25ms bool begin(uint8_t pinD0, uint8_t pinD1, unsigned int bits, unsigned int packetGap); bool available(); void clear(); void pause(); unsigned int getBitCounted(); unsigned int getBitAllocated(); unsigned int getBufferSize(); unsigned int getPacketGap(); volatile unsigned char *getRawData(); WiegandNG(); ~WiegandNG(); }; #endif ================================================ FILE: Source Code/esprfidtool/aba2str.h ================================================ String aba2str (String magstripe, int magStart, int magEnd, String swipeDirection) { //f.println(String()+"Start pos:"+magStart); //f.println(String()+"Start pos:"+magEnd); String ABA=""; String aba2str=""; int magCount=abs(magEnd-magStart); //f.println(String()+"magCount:"+magCount); aba2str=(String()+"\"Cleaned\" Binary:"+magstripe.substring(magStart,magEnd)+"\n"); aba2str+=(String()+" * Possible "+swipeDirection+" Card Data\(ASCII\):"); while (magCount>0) { ABA=magstripe.substring(magStart,magStart+4); if (ABA=="1101") {aba2str+=(";");} else if (ABA=="0000") {aba2str+=("0");} else if (ABA=="1000") {aba2str+=("1");} else if (ABA=="0100") {aba2str+=("2");} else if (ABA=="1100") {aba2str+=("3");} else if (ABA=="0010") {aba2str+=("4");} else if (ABA=="1010") {aba2str+=("5");} else if (ABA=="0110") {aba2str+=("6");} else if (ABA=="1110") {aba2str+=("7");} else if (ABA=="0001") {aba2str+=("8");} else if (ABA=="1001") {aba2str+=("9");} else if (ABA=="0011") {aba2str+=("<");} else if (ABA=="0111") {aba2str+=(">");} else if (ABA=="0101") {aba2str+=(":");} else if (ABA=="1011") {aba2str+=("=");} else if (ABA=="1111") {aba2str+=("?");} else {aba2str+=("_UNKNOWN-CHARACTER_");} magStart=magStart+5; magCount=magCount-5; } return aba2str; } ================================================ FILE: Source Code/esprfidtool/api.h ================================================ void apiTX(String apiBIN, int apipulsewidth, int apidatainterval, int wait) { wg.pause(); digitalWrite(DATA0, HIGH); pinMode(DATA0,OUTPUT); digitalWrite(DATA1, HIGH); pinMode(DATA1,OUTPUT); for (int i=0; i<=apiBIN.length(); i++) { if (apiBIN.charAt(i) == '0') { digitalWrite(DATA0, LOW); delayMicroseconds(apipulsewidth); digitalWrite(DATA0, HIGH); } else if (apiBIN.charAt(i) == '1') { digitalWrite(DATA1, LOW); delayMicroseconds(apipulsewidth); digitalWrite(DATA1, HIGH); } if (apiBIN.charAt(i) == ',') { delayMicroseconds(wait); } else { delayMicroseconds(apidatainterval); } } apiBIN=""; pinMode(DATA0, INPUT); pinMode(DATA1, INPUT); wg.clear(); } void apiinfo(int prettify) { FSInfo fs_info; SPIFFS.info(fs_info); String total; total=fs_info.totalBytes; String used; used=fs_info.usedBytes; String freespace; freespace=fs_info.totalBytes-fs_info.usedBytes; const size_t bufferSize = JSON_ARRAY_SIZE(5) + JSON_OBJECT_SIZE(3); DynamicJsonBuffer jsonAPIbuffer(bufferSize); JsonObject& apilog = jsonAPIbuffer.createObject(); apilog["Device"] = "ESP-RFID-Tool"; apilog["Firmware"] = version; apilog["API"] = APIversion; JsonObject& apifs = apilog.createNestedObject("File System"); apifs["Total Space"]=total; apifs["Used Space"]=used; apifs["Free Space"]=freespace; apilog["Free Memory"] = String(ESP.getFreeHeap(),DEC); String API_Response=""; if (prettify==1) { apilog.prettyPrintTo(API_Response); } else { apilog.printTo(API_Response); } server.send(200, "application/json", API_Response); delay(50); jsonAPIbuffer.clear(); } void apilistlogs(int prettify) { Dir dir = SPIFFS.openDir("/"); String FileList = ""; int logcount=0; while (dir.next()) { File f = dir.openFile("r"); String FileName = dir.fileName(); if((!FileName.startsWith("/payloads/"))&&(!FileName.startsWith("/esploit.json"))&&(!FileName.startsWith("/esportal.json"))&&(!FileName.startsWith("/esprfidtool.json"))&&(!FileName.startsWith("/config.json"))) { logcount++; } f.close(); } const size_t bufferSize = JSON_ARRAY_SIZE(5) + JSON_OBJECT_SIZE(1); DynamicJsonBuffer jsonAPIbuffer(bufferSize); JsonObject& apilog = jsonAPIbuffer.createObject(); apilog["Device"] = "ESP-RFID-Tool"; apilog["Firmware"] = version; apilog["API"] = APIversion; apilog["Log Count"] = logcount; int currentlog=0; Dir dir2ndrun = SPIFFS.openDir("/"); while (dir2ndrun.next()) { File f = dir2ndrun.openFile("r"); String FileName = dir2ndrun.fileName(); if ((!FileName.startsWith("/payloads/"))&&(!FileName.startsWith("/esploit.json"))&&(!FileName.startsWith("/esportal.json"))&&(!FileName.startsWith("/esprfidtool.json"))&&(!FileName.startsWith("/config.json"))) { currentlog++; FileName.remove(0,1); JsonObject& apilistlogs = apilog.createNestedObject(String(currentlog)); apilistlogs["File Name"]=FileName; } f.close(); } String API_Response=""; if (prettify==1) { apilog.prettyPrintTo(API_Response); } else { apilog.printTo(API_Response); } server.send(200, "application/json", API_Response); delay(50); jsonAPIbuffer.clear(); } void apilog(String logfile,int prettify) { File f = SPIFFS.open(String()+"/"+logfile, "r"); if (!f) { server.send(200, "application/json", "Log file not found"); delay(50); } else { int apiCAPTUREcount=0; while(f.available()) { String line = f.readStringUntil('\n'); if(line.indexOf(",Binary:") > 0) { apiCAPTUREcount++; int firstIndex = line.indexOf(",Binary:"); int secondIndex = line.indexOf(",", firstIndex + 1); String binaryCaptureLINE=line.substring(firstIndex+8, secondIndex); } } f.close(); const size_t bufferSize = JSON_ARRAY_SIZE(6) + JSON_OBJECT_SIZE(4); DynamicJsonBuffer jsonAPIbuffer(bufferSize); JsonObject& apilog = jsonAPIbuffer.createObject(); apilog["Device"] = "ESP-RFID-Tool"; apilog["Firmware"] = version; apilog["API"] = APIversion; apilog["Log File"] = logfile; apilog["Captures"] = apiCAPTUREcount; int apiCURRENTcapture=0; File f = SPIFFS.open(String()+"/"+logfile, "r"); while(f.available()) { String line = f.readStringUntil('\n'); if(line.indexOf(",Binary:") > 0) { apiCURRENTcapture++; int firstIndex = line.indexOf(",Binary:"); int secondIndex = line.indexOf(",", firstIndex + 1); String binaryCaptureLINE=line.substring(firstIndex+8, secondIndex); if ( binaryCaptureLINE.indexOf(" ") > 0 ) { binaryCaptureLINE=binaryCaptureLINE.substring(binaryCaptureLINE.indexOf(" ")+1); } binaryCaptureLINE.replace("\r",""); JsonObject& apiCURRENTcaptureOBJECT = apilog.createNestedObject(String(apiCURRENTcapture)); apiCURRENTcaptureOBJECT["Bit Count"]=binaryCaptureLINE.length(); apiCURRENTcaptureOBJECT["Binary"]=binaryCaptureLINE; if(line.indexOf(",HEX:") > 0) { int hfirstIndex = line.indexOf(",HEX:"); int hsecondIndex = line.indexOf(",", hfirstIndex + 1); String hexCURRENT=line.substring(hfirstIndex+5, hsecondIndex); hexCURRENT.replace("\r",""); apiCURRENTcaptureOBJECT["Hexadecimal"]=hexCURRENT; } if(line.indexOf(",Keypad Code:") > 0) { int kfirstIndex = line.indexOf(",Keypad Code:"); int ksecondIndex = line.indexOf(",", kfirstIndex + 1); String pinCURRENT=line.substring(kfirstIndex+13, ksecondIndex); pinCURRENT.replace("\r",""); apiCURRENTcaptureOBJECT["Keypad Press"]=pinCURRENT; } } } f.close(); String API_Response=""; if (prettify==1) { apilog.prettyPrintTo(API_Response); } else { apilog.printTo(API_Response); } server.send(200, "application/json", API_Response); delay(50); jsonAPIbuffer.clear(); } } ================================================ FILE: Source Code/esprfidtool/api_server.h ================================================ server.on("/api/tx/bin", [](){ String api_binary=""; int api_pulsewidth=txdelayus; int api_datainterval=(txdelayms*1000); int prettify=0; int api_wait=100000; if (server.hasArg("binary")) { api_binary=(server.arg("binary")); } if (server.hasArg("pulsewidth")) { api_pulsewidth=(server.arg("pulsewidth").toInt()); } if (server.hasArg("interval")) { api_datainterval=(server.arg("interval").toInt()); } if (server.hasArg("wait")) { api_wait=(server.arg("wait").toInt()); } if (server.hasArg("prettify")) { prettify=1; } const size_t bufferSize = JSON_ARRAY_SIZE(4) + JSON_OBJECT_SIZE(5); DynamicJsonBuffer jsonAPIbuffer(bufferSize); JsonObject& apitxbin = jsonAPIbuffer.createObject(); apitxbin["Device"] = "ESP-RFID-Tool"; apitxbin["Firmware"] = version; apitxbin["API"] = APIversion; JsonObject& apitxbinary = apitxbin.createNestedObject("Transmission"); int commacount=0; for (int commalook=0; commalook<=api_binary.length(); commalook++) { if (api_binary.charAt(commalook)==',') { commacount++; } } apitxbinary["Bit Count"]=api_binary.length()-commacount; apitxbinary["Binary"]=api_binary; apitxbinary["Wiegand Data Pulse Width"]=String()+api_pulsewidth+"us"; apitxbinary["Wiegand Data Interval"]=String()+api_datainterval+"us"; apitxbinary["Delay Between Packets"]=String()+api_wait+"us"; if (api_binary=="") { server.send(200, "text/html", F( "Binary to tx not specified.
" "Usage: [server]/api/tx/bin?binary=[binary]&pulsewidth=[delay_us]&interval=[delay_us]&wait=[delay_us_between_packets]
" "Use commas to separate the binary for transmitting multiple packets(useful for sending multiple keypresses for imitating keypads)
" "Example to TX Pin Code 1337# waiting 100,000us between packets(keypresses): /api/tx/bin?binary=11100001,11000011,11000011,10000111,01001011&wait=100000&prettify=1
" )); } else { String API_Response=""; if (prettify==1) { apitxbin.prettyPrintTo(API_Response); } else { apitxbin.printTo(API_Response); } server.send(200, "application/json", API_Response); delay(50); jsonAPIbuffer.clear(); apiTX(api_binary,api_pulsewidth,api_datainterval,api_wait); } }); server.on("/api/help", [](){ String apihelpHTML=String()+F( "<- BACK TO INDEX

" "API Version: " )+APIversion+F( "

" "/api/info
" "Usage: [server]/api/info
" "
" "/api/viewlog
" "Usage: [server]/api/viewlog?logfile=[log.txt]
" "
" "/api/listlogs
" "Usage: [server]/api/listlogs
" "
" "/api/tx/bin
" "Usage: [server]/api/tx/bin?binary=[binary]&pulsewidth=[delay_us]&interval=[delay_us]&wait=[delay_us_between_packets]
" "Use commas to separate the binary for transmitting multiple packets(useful for sending multiple keypresses for imitating keypads)
" "Example to TX Pin Code 1337# waiting 100,000us between packets(keypresses): /api/tx/bin?binary=11100001,11000011,11000011,10000111,01001011&wait=100000&prettify=1
" "
" "Universal Arguments
" "Prettify: [api-url]?[args]&prettify=1
" ); server.send(200, "text/html", apihelpHTML); }); server.on("/api/info", [](){ int prettify=0; if (server.hasArg("prettify")) { prettify=1; } apiinfo(prettify); }); server.on("/api/listlogs", [](){ int prettify=0; if (server.hasArg("prettify")) { prettify=1; } apilistlogs(prettify); }); server.on("/api/viewlog", [](){ int prettify=0; if (server.hasArg("prettify")) { prettify=1; } if (server.hasArg("logfile")) { apilog(server.arg("logfile"),prettify); } else { server.send(200, "application/json", F("Usage: [server]/api/viewlog?logfile=[logfile.txt]")); } }); ================================================ FILE: Source Code/esprfidtool/esprfidtool.ino ================================================ /* * ESP-RFID-Tool * by Corey Harding of www.Exploit.Agency / www.LegacySecurityGroup.com * ESP-RFID-Tool Software is distributed under the MIT License. The license and copyright notice can not be removed and must be distributed alongside all future copies of the software. * MIT License Copyright (c) [2018] [Corey Harding] 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 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. */ #include "HelpText.h" #include "License.h" #include "version.h" #include "strrev.h" #include "aba2str.h" #include #include #include #include #include #include #include #include #include // ArduinoJson library 5.11.0 by Benoit Blanchon https://github.com/bblanchon/ArduinoJson #include // https://github.com/exploitagency/esp8266FTPServer/tree/feature/bbx10_speedup #include #include #define DATA0 14 #define DATA1 12 #define LED_BUILTIN 2 #define RESTORE_DEFAULTS_PIN 4 //GPIO 4 int jumperState = 0; //For restoring default settings #include "WiegandNG.h" //https://github.com/jpliew/Wiegand-NG-Multi-Bit-Wiegand-Library-for-Arduino // Port for web server ESP8266WebServer server(80); ESP8266WebServer httpServer(1337); ESP8266HTTPUpdateServer httpUpdater; FtpServer ftpSrv; const byte DNS_PORT = 53; DNSServer dnsServer; HTTPClient http; const char* update_path = "/update"; int accesspointmode; char ssid[32]; char password[64]; int channel; int hidden; char local_IPstr[16]; char gatewaystr[16]; char subnetstr[16]; char update_username[32]; char update_password[64]; char ftp_username[32]; char ftp_password[64]; int ftpenabled; int ledenabled; char logname[31]; unsigned int bufferlength; unsigned int rxpacketgap; int txdelayus; int txdelayms; int safemode; int dos=0; int TXstatus=0; String pinHTML; #include "pinSEND.h" String dataCONVERSION=""; WiegandNG wg; void LogWiegand(WiegandNG &tempwg) { volatile unsigned char *buffer=tempwg.getRawData(); unsigned int bufferSize = tempwg.getBufferSize(); unsigned int countedBits = tempwg.getBitCounted(); unsigned int countedBytes = (countedBits/8); if ((countedBits % 8)>0) countedBytes++; //unsigned int bitsUsed = countedBytes * 8; bool binChunk2exists=false; volatile unsigned long cardChunk1 = 0; volatile unsigned long cardChunk2 = 0; volatile unsigned long binChunk2 = 0; volatile unsigned long binChunk1 = 0; String binChunk3=""; bool unknown=false; binChunk2exists=false; int binChunk2len=0; int j=0; for (unsigned int i=bufferSize-countedBytes; i< bufferSize;i++) { unsigned char bufByte=buffer[i]; for(int x=0; x<8;x++) { if ( (((bufferSize-i) *8)-x) <= countedBits) { j++; if((bufByte & 0x80)) { //write 1 if(j<23) { binChunk1 = binChunk1 << 1; binChunk1 |= 1; } else if(j<=52) { binChunk2exists=true; binChunk2len++; binChunk2 = binChunk2 << 1; binChunk2 |= 1; } else if(j>52){ binChunk3=binChunk3+"1"; } } else { //write 0 if(j<23) { binChunk1 = binChunk1 << 1; } else if(j<=52){ binChunk2exists=true; binChunk2len++; binChunk2 = binChunk2 << 1; } else if(j>52){ binChunk3=binChunk3+"0"; } } } bufByte<<=1; } } j=0; switch (countedBits) { //Add the preamble to known cards case 26: for(int i = 19; i >= 0; i--) { if(i == 13 || i == 2){ bitWrite(cardChunk1, i, 1); // Write preamble 1's to the 13th and 2nd bits } else if(i > 2) { bitWrite(cardChunk1, i, 0); // Write preamble 0's to all other bits above 1 } else { bitWrite(cardChunk1, i, bitRead(binChunk1, i + 20)); // Write remaining bits to cardChunk1 from binChunk1 } if(i < 20) { bitWrite(cardChunk2, i + 4, bitRead(binChunk1, i)); // Write the remaining bits of binChunk1 to cardChunk2 } if(i < 4) { bitWrite(cardChunk2, i, bitRead(binChunk2, i)); // Write the remaining bit of cardChunk2 with binChunk2 bits } } break; case 27: for(int i = 19; i >= 0; i--) { if(i == 13 || i == 3){ bitWrite(cardChunk1, i, 1); } else if(i > 3) { bitWrite(cardChunk1, i, 0); } else { bitWrite(cardChunk1, i, bitRead(binChunk1, i + 19)); } if(i < 19) { bitWrite(cardChunk2, i + 5, bitRead(binChunk1, i)); } if(i < 5) { bitWrite(cardChunk2, i, bitRead(binChunk2, i)); } } break; case 28: for(int i = 19; i >= 0; i--) { if(i == 13 || i == 4){ bitWrite(cardChunk1, i, 1); } else if(i > 4) { bitWrite(cardChunk1, i, 0); } else { bitWrite(cardChunk1, i, bitRead(binChunk1, i + 18)); } if(i < 18) { bitWrite(cardChunk2, i + 6, bitRead(binChunk1, i)); } if(i < 6) { bitWrite(cardChunk2, i, bitRead(binChunk2, i)); } } break; case 29: for(int i = 19; i >= 0; i--) { if(i == 13 || i == 5){ bitWrite(cardChunk1, i, 1); } else if(i > 5) { bitWrite(cardChunk1, i, 0); } else { bitWrite(cardChunk1, i, bitRead(binChunk1, i + 17)); } if(i < 17) { bitWrite(cardChunk2, i + 7, bitRead(binChunk1, i)); } if(i < 7) { bitWrite(cardChunk2, i, bitRead(binChunk2, i)); } } break; case 30: for(int i = 19; i >= 0; i--) { if(i == 13 || i == 6){ bitWrite(cardChunk1, i, 1); } else if(i > 6) { bitWrite(cardChunk1, i, 0); } else { bitWrite(cardChunk1, i, bitRead(binChunk1, i + 16)); } if(i < 16) { bitWrite(cardChunk2, i + 8, bitRead(binChunk1, i)); } if(i < 8) { bitWrite(cardChunk2, i, bitRead(binChunk2, i)); } } break; case 31: for(int i = 19; i >= 0; i--) { if(i == 13 || i == 7){ bitWrite(cardChunk1, i, 1); } else if(i > 7) { bitWrite(cardChunk1, i, 0); } else { bitWrite(cardChunk1, i, bitRead(binChunk1, i + 15)); } if(i < 15) { bitWrite(cardChunk2, i + 9, bitRead(binChunk1, i)); } if(i < 9) { bitWrite(cardChunk2, i, bitRead(binChunk2, i)); } } break; case 32: for(int i = 19; i >= 0; i--) { if(i == 13 || i == 8){ bitWrite(cardChunk1, i, 1); } else if(i > 8) { bitWrite(cardChunk1, i, 0); } else { bitWrite(cardChunk1, i, bitRead(binChunk1, i + 14)); } if(i < 14) { bitWrite(cardChunk2, i + 10, bitRead(binChunk1, i)); } if(i < 10) { bitWrite(cardChunk2, i, bitRead(binChunk2, i)); } } break; case 33: for(int i = 19; i >= 0; i--) { if(i == 13 || i == 9){ bitWrite(cardChunk1, i, 1); } else if(i > 9) { bitWrite(cardChunk1, i, 0); } else { bitWrite(cardChunk1, i, bitRead(binChunk1, i + 13)); } if(i < 13) { bitWrite(cardChunk2, i + 11, bitRead(binChunk1, i)); } if(i < 11) { bitWrite(cardChunk2, i, bitRead(binChunk2, i)); } } break; case 34: for(int i = 19; i >= 0; i--) { if(i == 13 || i == 10){ bitWrite(cardChunk1, i, 1); } else if(i > 10) { bitWrite(cardChunk1, i, 0); } else { bitWrite(cardChunk1, i, bitRead(binChunk1, i + 12)); } if(i < 12) { bitWrite(cardChunk2, i + 12, bitRead(binChunk1, i)); } if(i < 12) { bitWrite(cardChunk2, i, bitRead(binChunk2, i)); } } break; case 35: for(int i = 19; i >= 0; i--) { if(i == 13 || i == 11){ bitWrite(cardChunk1, i, 1); } else if(i > 11) { bitWrite(cardChunk1, i, 0); } else { bitWrite(cardChunk1, i, bitRead(binChunk1, i + 11)); } if(i < 11) { bitWrite(cardChunk2, i + 13, bitRead(binChunk1, i)); } if(i < 13) { bitWrite(cardChunk2, i, bitRead(binChunk2, i)); } } break; case 36: for(int i = 19; i >= 0; i--) { if(i == 13 || i == 12){ bitWrite(cardChunk1, i, 1); } else if(i > 12) { bitWrite(cardChunk1, i, 0); } else { bitWrite(cardChunk1, i, bitRead(binChunk1, i + 10)); } if(i < 10) { bitWrite(cardChunk2, i + 14, bitRead(binChunk1, i)); } if(i < 14) { bitWrite(cardChunk2, i, bitRead(binChunk2, i)); } } break; case 37: for(int i = 19; i >= 0; i--) { if(i == 13){ bitWrite(cardChunk1, i, 0); } else { bitWrite(cardChunk1, i, bitRead(binChunk1, i + 9)); } if(i < 9) { bitWrite(cardChunk2, i + 15, bitRead(binChunk1, i)); } if(i < 15) { bitWrite(cardChunk2, i, bitRead(binChunk2, i)); } } break; default: //unknown card unknown=true; //String binChunk3 is like cardChunk0 cardChunk1=binChunk2; cardChunk2=binChunk1; break; } File f = SPIFFS.open("/"+String(logname), "a"); //Open the log in append mode to store capture int preambleLen; if (unknown==true && countedBits!=4 && countedBits!=8 && countedBits!=248) { f.print(F("Unknown ")); preambleLen=0; } else { preambleLen=(44-countedBits); } f.print(String()+countedBits+F(" bit card,")); if (countedBits==4||countedBits==8) { f.print(F("Possible keypad entry,")); } if (countedBits==248) { f.print(F("possible magstripe card,")); } String magstripe=""; if (unknown!=true) { f.print(String()+preambleLen+F(" bit preamble,")); } f.print(F("Binary:")); //f.print(" "); //debug line if (binChunk2exists==true && unknown!=true) { for(int i = (((countedBits+preambleLen)-countedBits)+(countedBits-24)); i--;) { if (i==((((countedBits+preambleLen)-countedBits)+(countedBits-24))-preambleLen-1) && unknown!=true) { f.print(" "); } f.print(bitRead(cardChunk1, i)); if(i == 0){ break; } } } if ((countedBits>=24) && unknown!=true) { for(int i = 24; i--;) { f.print(bitRead(cardChunk2, i)); if(i == 0){ break; } } } else if ((countedBits>=23) && unknown==true) { int i; if (countedBits>=52) { i=22; } else { i =(countedBits-binChunk2len); } for(i; i--;) { f.print(bitRead(binChunk1, i)); if (countedBits==248) { magstripe+=bitRead(binChunk1, i); } if(i == 0){ break; } } } else { for(int i = countedBits; i--;) { f.print(bitRead(binChunk1, i)); if(i == 0){ break; } } } if (binChunk2exists==true && unknown==true) { int i; if (countedBits>=52) { i=30; } else { i=(binChunk2len); } for(i; i--;) { f.print(bitRead(binChunk2, i)); if (countedBits==248) { magstripe+=bitRead(binChunk2, i); } if(i == 0){ break; } } } if (countedBits>52) { f.print(binChunk3); if (countedBits==248) { magstripe+=binChunk3; } } if (countedBits<=52 && unknown!=true) { f.print(",HEX:"); if (binChunk2exists==true) { f.print(cardChunk1, HEX); } //f.print(" "); //debug line f.println(cardChunk2, HEX); } else if (countedBits==4||countedBits==8) { f.print(",Keypad Code:"); if (binChunk1 == 0B0000||binChunk1 == 0b11110000) { f.print("0"); } else if (binChunk1 == 0B0001||binChunk1 == 0b11100001) { f.print("1"); } else if (binChunk1 == 0B0010||binChunk1 == 0b11010010) { f.print("2"); } else if (binChunk1 == 0B0011||binChunk1 == 0b11000011) { f.print("3"); } else if (binChunk1 == 0B0100||binChunk1 == 0b10110100) { f.print("4"); } else if (binChunk1 == 0B0101||binChunk1 == 0b10100101) { f.print("5"); } else if (binChunk1 == 0B0110||binChunk1 == 0b10010110) { f.print("6"); } else if (binChunk1 == 0B0111||binChunk1 == 0b10000111) { f.print("7"); } else if (binChunk1 == 0B1000||binChunk1 == 0b01111000) { f.print("8"); } else if (binChunk1 == 0B1001||binChunk1 == 0b01101001) { f.print("9"); } else if (binChunk1 == 0B1010||binChunk1 == 0b01011010) { f.print("*"); } else if (binChunk1 == 0B1011||binChunk1 == 0b01001011) { f.print("#"); } else if (binChunk1 == 0b1100||binChunk1 == 0b00111100) { f.print("F1"); } else if (binChunk1 == 0b1101||binChunk1 == 0b00101101) { f.print("F2"); } else if (binChunk1 == 0b1110||binChunk1 == 0b00011110) { f.print("F3"); } else if (binChunk1 == 0b1111||binChunk1 == 0b00001111) { f.print("F4"); } else { f.print("?"); } f.print(",HEX:"); if (countedBits==8) { char hexCHAR[3]; sprintf(hexCHAR, "%02X", binChunk1); f.println(hexCHAR); } else if (countedBits==4) { f.println(binChunk1, HEX); } } else if (countedBits==248) { f.println(","); } else { f.println(""); } if (countedBits==248) { int startSentinel=magstripe.indexOf("11010"); int endSentinel=(magstripe.lastIndexOf("11111")+4); int magStart=0; int magEnd=1; //f.print("
");
  
    f.print(" * Trying \"Forward\" Swipe,");
    magStart=startSentinel;
    magEnd=endSentinel;
    f.println(aba2str(magstripe,magStart,magEnd,"\"Forward\" Swipe"));
    
    f.print(" * Trying \"Reverse\" Swipe,");
    char magchar[249];
    magstripe.toCharArray(magchar,249);
    magstripe=String(strrev(magchar));
    //f.println(String()+"Reverse: "+magstripe);
    magStart=magstripe.indexOf("11010");
    magEnd=(magstripe.lastIndexOf("11111")+4);
    f.println(aba2str(magstripe,magStart,magEnd,"\"Reverse\" Swipe"));
  
    //f.print("
"); //f.println(String()+F(" * You can verify the data at the following URL: https://www.legacysecuritygroup.com/aba-decode.php?binary=")+magstripe+F("")); } //Debug // f.print(F("Free heap:")); // f.println(ESP.getFreeHeap(),DEC); unknown=false; binChunk3=""; binChunk2exists=false; binChunk1 = 0; binChunk2 = 0; cardChunk1 = 0; cardChunk2 = 0; binChunk2len=0; f.close(); //done } #include "api.h" void settingsPage() { if(!server.authenticate(update_username, update_password)) return server.requestAuthentication(); String accesspointmodeyes; String accesspointmodeno; if (accesspointmode==1){ accesspointmodeyes=" checked=\"checked\""; accesspointmodeno=""; } else { accesspointmodeyes=""; accesspointmodeno=" checked=\"checked\""; } String ftpenabledyes; String ftpenabledno; if (ftpenabled==1){ ftpenabledyes=" checked=\"checked\""; ftpenabledno=""; } else { ftpenabledyes=""; ftpenabledno=" checked=\"checked\""; } String ledenabledyes; String ledenabledno; if (ledenabled==1){ ledenabledyes=" checked=\"checked\""; ledenabledno=""; } else { ledenabledyes=""; ledenabledno=" checked=\"checked\""; } String hiddenyes; String hiddenno; if (hidden==1){ hiddenyes=" checked=\"checked\""; hiddenno=""; } else { hiddenyes=""; hiddenno=" checked=\"checked\""; } String safemodeyes; String safemodeno; if (safemode==1){ safemodeyes=" checked=\"checked\""; safemodeno=""; } else { safemodeyes=""; safemodeno=" checked=\"checked\""; } server.send(200, "text/html", String()+ F( "" "" "" "" "ESP-RFID-Tool Settings" "" "" "" "<- BACK TO INDEX

" "

ESP-RFID-Tool Settings

" "" "
" "
" "

" "WiFi Configuration:

" "Network Type
" )+ F("Access Point Mode:
" "Join Existing Network:

" "Hidden
" "Yes
" "No

" "SSID:
" "Password:
" "Channel:

" "IP:
" "Gateway:
" "Subnet:

" "


" "Web Interface Administration Settings:

" "Username:
" "Password:

" "
" "FTP Server Settings
" "Changes require a reboot.
" "Enabled
" "Disabled
" "FTP Username:
" "FTP Password:

" "
" "Power LED:
" "Changes require a reboot.
" "Enabled
" "Disabled

" "
" "RFID Capture Log:
" "Useful to change this value to differentiate between facilities during various security assessments.
" "File Name:
" "
" "Experimental Settings:
" "Changes require a reboot.
" "Default Buffer Length is 256 bits with an allowed range of 52-4096 bits." "
Default Experimental TX mode timing is 40us Wiegand Data Pulse Width and a 2ms Wiegand Data Interval with an allowed range of 0-1000." "
Changing these settings may result in unstable performance.

" "Wiegand RX Buffer Length: bit(s)
" "Wiegand RX Packet Length: millisecond(s)
" "Experimental TX Wiegand Data Pulse Width: microsecond(s)
" "Experimental TX Wiegand Data Interval: millisecond(s)
" "
" "Safe Mode:
" "Enable to reboot the device after every capture.
Disable to avoid missing quick consecutive captures such as keypad entries.

" "Enabled
" "Disabled

" "
" "" "" "
" "
" "

" "" "" ) ); } void handleSettings() { if (server.hasArg("SETTINGS")) { handleSubmitSettings(); } else { settingsPage(); } } void returnFail(String msg) { server.sendHeader("Connection", "close"); server.sendHeader("Access-Control-Allow-Origin", "*"); server.send(500, "text/plain", msg + "\r\n"); } void handleSubmitSettings() { String SETTINGSvalue; if (!server.hasArg("SETTINGS")) return returnFail("BAD ARGS"); SETTINGSvalue = server.arg("SETTINGS"); accesspointmode = server.arg("accesspointmode").toInt(); server.arg("ssid").toCharArray(ssid, 32); server.arg("password").toCharArray(password, 64); channel = server.arg("channel").toInt(); hidden = server.arg("hidden").toInt(); server.arg("local_IPstr").toCharArray(local_IPstr, 16); server.arg("gatewaystr").toCharArray(gatewaystr, 16); server.arg("subnetstr").toCharArray(subnetstr, 16); server.arg("update_username").toCharArray(update_username, 32); server.arg("update_password").toCharArray(update_password, 64); server.arg("ftp_username").toCharArray(ftp_username, 32); server.arg("ftp_password").toCharArray(ftp_password, 64); ftpenabled = server.arg("ftpenabled").toInt(); ledenabled = server.arg("ledenabled").toInt(); server.arg("logname").toCharArray(logname, 31); bufferlength = server.arg("bufferlength").toInt(); rxpacketgap = server.arg("rxpacketgap").toInt(); txdelayus = server.arg("txdelayus").toInt(); txdelayms = server.arg("txdelayms").toInt(); safemode = server.arg("safemode").toInt(); if (SETTINGSvalue == "1") { saveConfig(); server.send(200, "text/html", F("<- BACK TO INDEX



Settings have been saved.
Some setting may require manually rebooting before taking effect.
If network configuration has changed then be sure to connect to the new network first in order to access the web interface.")); delay(50); loadConfig(); } else if (SETTINGSvalue == "0") { settingsPage(); } else { returnFail("Bad SETTINGS value"); } } bool loadDefaults() { StaticJsonBuffer<500> jsonBuffer; JsonObject& json = jsonBuffer.createObject(); json["version"] = version; json["accesspointmode"] = "1"; json["ssid"] = "ESP-RFID-Tool"; json["password"] = ""; json["channel"] = "6"; json["hidden"] = "0"; json["local_IP"] = "192.168.1.1"; json["gateway"] = "192.168.1.1"; json["subnet"] = "255.255.255.0"; json["update_username"] = "admin"; json["update_password"] = "rfidtool"; json["ftp_username"] = "ftp-admin"; json["ftp_password"] = "rfidtool"; json["ftpenabled"] = "0"; json["ledenabled"] = "1"; json["logname"] = "log.txt"; json["bufferlength"] = "256"; json["rxpacketgap"] = "15"; json["txdelayus"] = "40"; json["txdelayms"] = "2"; json["safemode"] = "0"; File configFile = SPIFFS.open("/esprfidtool.json", "w"); json.printTo(configFile); configFile.close(); jsonBuffer.clear(); loadConfig(); } bool loadConfig() { File configFile = SPIFFS.open("/esprfidtool.json", "r"); if (!configFile) { delay(3500); loadDefaults(); } size_t size = configFile.size(); std::unique_ptr buf(new char[size]); configFile.readBytes(buf.get(), size); StaticJsonBuffer<500> jsonBuffer; JsonObject& json = jsonBuffer.parseObject(buf.get()); if (!json["version"]) { delay(3500); loadDefaults(); ESP.restart(); } //Resets config to factory defaults on an update. if (json["version"]!=version) { delay(3500); loadDefaults(); ESP.restart(); } strcpy(ssid, (const char*)json["ssid"]); strcpy(password, (const char*)json["password"]); channel = json["channel"]; hidden = json["hidden"]; accesspointmode = json["accesspointmode"]; strcpy(local_IPstr, (const char*)json["local_IP"]); strcpy(gatewaystr, (const char*)json["gateway"]); strcpy(subnetstr, (const char*)json["subnet"]); strcpy(update_username, (const char*)json["update_username"]); strcpy(update_password, (const char*)json["update_password"]); strcpy(ftp_username, (const char*)json["ftp_username"]); strcpy(ftp_password, (const char*)json["ftp_password"]); ftpenabled = json["ftpenabled"]; ledenabled = json["ledenabled"]; strcpy(logname, (const char*)json["logname"]); bufferlength = json["bufferlength"]; rxpacketgap = json["rxpacketgap"]; txdelayus = json["txdelayus"]; txdelayms = json["txdelayms"]; safemode = json["safemode"]; IPAddress local_IP; local_IP.fromString(local_IPstr); IPAddress gateway; gateway.fromString(gatewaystr); IPAddress subnet; subnet.fromString(subnetstr); /* Serial.println(accesspointmode); Serial.println(ssid); Serial.println(password); Serial.println(channel); Serial.println(hidden); Serial.println(local_IP); Serial.println(gateway); Serial.println(subnet); */ WiFi.persistent(false); //ESP.eraseConfig(); // Determine if set to Access point mode if (accesspointmode == 1) { WiFi.disconnect(true); WiFi.mode(WIFI_AP); // Serial.print("Starting Access Point ... "); // Serial.println(WiFi.softAP(ssid, password, channel, hidden) ? "Success" : "Failed!"); WiFi.softAP(ssid, password, channel, hidden); // Serial.print("Setting up Network Configuration ... "); // Serial.println(WiFi.softAPConfig(local_IP, gateway, subnet) ? "Success" : "Failed!"); WiFi.softAPConfig(local_IP, gateway, subnet); // WiFi.reconnect(); // Serial.print("IP address = "); // Serial.println(WiFi.softAPIP()); } // or Join existing network else if (accesspointmode != 1) { WiFi.disconnect(true); WiFi.mode(WIFI_STA); // Serial.print("Setting up Network Configuration ... "); WiFi.config(local_IP, gateway, subnet); // WiFi.config(local_IP, gateway, subnet); // Serial.print("Connecting to network ... "); // WiFi.begin(ssid, password); WiFi.begin(ssid, password); WiFi.reconnect(); // Serial.print("IP address = "); // Serial.println(WiFi.localIP()); } configFile.close(); jsonBuffer.clear(); return true; } bool saveConfig() { StaticJsonBuffer<500> jsonBuffer; JsonObject& json = jsonBuffer.createObject(); json["version"] = version; json["accesspointmode"] = accesspointmode; json["ssid"] = ssid; json["password"] = password; json["channel"] = channel; json["hidden"] = hidden; json["local_IP"] = local_IPstr; json["gateway"] = gatewaystr; json["subnet"] = subnetstr; json["update_username"] = update_username; json["update_password"] = update_password; json["ftp_username"] = ftp_username; json["ftp_password"] = ftp_password; json["ftpenabled"] = ftpenabled; json["ledenabled"] = ledenabled; json["logname"] = logname; json["bufferlength"] = bufferlength; json["rxpacketgap"] = rxpacketgap; json["txdelayus"] = txdelayus; json["txdelayms"] = txdelayms; json["safemode"] = safemode; File configFile = SPIFFS.open("/esprfidtool.json", "w"); json.printTo(configFile); configFile.close(); jsonBuffer.clear(); return true; } File fsUploadFile; String webString; void ListLogs(){ String directory; directory="/"; FSInfo fs_info; SPIFFS.info(fs_info); String total; total=fs_info.totalBytes; String used; used=fs_info.usedBytes; String freespace; freespace=fs_info.totalBytes-fs_info.usedBytes; Dir dir = SPIFFS.openDir(directory); String FileList = String()+F("<- BACK TO INDEX

File System Info Calculated in Bytes
Total: ")+total+" Free: "+freespace+" "+" Used: "+used+"

NOTE: Larger log files will need to be downloaded instead of viewed from the browser.
"; while (dir.next()) { String FileName = dir.fileName(); File f = dir.openFile("r"); FileList += " "; if((!FileName.startsWith("/payloads/"))&&(!FileName.startsWith("/esploit.json"))&&(!FileName.startsWith("/esportal.json"))&&(!FileName.startsWith("/esprfidtool.json"))&&(!FileName.startsWith("/config.json"))) FileList += ""+""; f.close(); } FileList += "
Display File ContentsSize in BytesDownload FileDelete File
"+FileName+""+f.size()+"
"; server.send(200, "text/html", FileList); } bool RawFile(String rawfile) { if (SPIFFS.exists(rawfile)) { if(!server.authenticate(update_username, update_password)){ server.requestAuthentication();} File file = SPIFFS.open(rawfile, "r"); size_t sent = server.streamFile(file, "application/octet-stream"); file.close(); return true; } return false; } void ViewLog(){ webString=""; String payload; String ShowPL; payload += server.arg(0); File f = SPIFFS.open(payload, "r"); String webString = f.readString(); f.close(); ShowPL = String()+F( "" "<- BACK TO INDEX

" "List Exfiltrated Data - Experimental TX Mode - Data Conversion Tools

" "
" "Binary: " "
" "Pulse Width: us " "Data Interval: us " "Delay Between Packets: us
" "" "
" "Use commas to separate the binary for transmitting multiple packets(useful for sending multiple keypresses for imitating keypads)
" "
" " - " "
")
    +payload+
    F("\n"
    "Note: Preambles shown are only a guess based on card length and may not be accurate for every card format.\n"
    "-----\n")
    +webString+
    F("
") ; webString=""; server.send(200, "text/html", ShowPL); } // Start Networking void setup() { Serial.begin(9600); Serial.println(F(".....")); Serial.println(String()+F("ESP-RFID-Tool v")+version); //SPIFFS.format(); SPIFFS.begin(); //loadDefaults(); //uncomment to restore default settings if double reset fails for some reason //Jump RESTORE_DEFAULTS_PIN to GND while powering on device to reset the device to factory defaults pinMode(RESTORE_DEFAULTS_PIN, INPUT_PULLUP); jumperState = digitalRead(RESTORE_DEFAULTS_PIN); if (jumperState == LOW) { Serial.println(String()+F("Pin ")+RESTORE_DEFAULTS_PIN+F("Grounded")); Serial.println(F("Loading default config...")); loadDefaults(); } loadConfig(); if(!wg.begin(DATA0,DATA1,bufferlength,rxpacketgap)) { Serial.println(F("Could not begin Wiegand logging,")); Serial.println(F("Out of memory!")); } //Set up Web Pages server.on("/",[]() { FSInfo fs_info; SPIFFS.info(fs_info); String total; total=fs_info.totalBytes; String used; used=fs_info.usedBytes; String freespace; freespace=fs_info.totalBytes-fs_info.usedBytes; server.send(200, "text/html", String()+F("ESP-RFID-Tool v")+version+F("
" "
" "by Corey Harding
" "www.RFID-Tool.com
" "www.LegacySecurityGroup.com / www.Exploit.Agency

" "-----
" "File System Info Calculated in Bytes
" "Total: ")+total+" Free: "+freespace+" "+" Used: "+used+F("
-----
" "List Exfiltrated Data
-
" "Experimental TX Mode
-
" "Data Conversion Tools
-
" "Configure Settings
-
" "Format File System
-
" "Upgrade Firmware
-
" "API Info
-
" "Help" "")); }); server.onNotFound([]() { if (!RawFile(server.uri())) server.send(404, "text/plain", F("Error 404 File Not Found")); }); server.on("/settings", handleSettings); server.on("/firmware", [](){ server.send(200, "text/html", String()+F("<- BACK TO INDEX

Open Arduino IDE.
Pull down \"Sketch\" Menu then select \"Export Compiled Binary\".
On this page click \"Browse\", select the binary you exported earlier, then click \"Update\".
You may need to manually reboot the device to reconnect.
")); }); server.on("/restoredefaults", [](){ server.send(200, "text/html", F("This will restore the device to the default configuration.

Are you sure?

YES - NO")); }); server.on("/restoredefaults/yes", [](){ if(!server.authenticate(update_username, update_password)) return server.requestAuthentication(); server.send(200, "text/html", F("<- BACK TO INDEX

Network
---
SSID: ESP-RFID-Tool

Administration
---
USER: admin PASS: rfidtool")); delay(50); loadDefaults(); ESP.restart(); }); server.on("/deletelog", [](){ String deletelog; deletelog += server.arg(0); server.send(200, "text/html", String()+F("This will delete the file: ")+deletelog+F(".

Are you sure?

YES - NO")); }); server.on("/viewlog", ViewLog); server.on("/deletelog/yes", [](){ if(!server.authenticate(update_username, update_password)) return server.requestAuthentication(); String deletelog; deletelog += server.arg(0); if (!deletelog.startsWith("/payloads/")) server.send(200, "text/html", String()+F("<- BACK TO INDEX

List Exfiltrated Data

Deleting file: ")+deletelog); delay(50); SPIFFS.remove(deletelog); }); server.on("/format", [](){ server.send(200, "text/html", F("<- BACK TO INDEX

This will reformat the SPIFFS File System.

Are you sure?

YES - NO")); }); server.on("/logs", ListLogs); server.on("/reboot", [](){ if(!server.authenticate(update_username, update_password)) return server.requestAuthentication(); server.send(200, "text/html", F("<- BACK TO INDEX

Rebooting Device...")); delay(50); ESP.restart(); }); server.on("/format/yes", [](){ if(!server.authenticate(update_username, update_password)) return server.requestAuthentication(); server.send(200, "text/html", F("<- BACK TO INDEX

Formatting file system: This may take up to 90 seconds")); delay(50); // Serial.print("Formatting file system..."); SPIFFS.format(); // Serial.println(" Success"); saveConfig(); }); server.on("/help", []() { server.send_P(200, "text/html", HelpText); }); server.on("/license", []() { server.send_P(200, "text/html", License); }); server.on("/data-convert", [](){ if (server.hasArg("bin2hexHTML")) { int bin2hexBUFFlen=(((server.arg("bin2hexHTML")).length())+1); char bin2hexCHAR[bin2hexBUFFlen]; (server.arg("bin2hexHTML")).toCharArray(bin2hexCHAR,bin2hexBUFFlen); dataCONVERSION+=String()+F("Binary: ")+bin2hexCHAR+F("

"); String hexTEMP=""; int binCOUNT=(bin2hexBUFFlen-1); for (int currentBINpos=0; currentBINposYou may want to drop the leading zero(if there is one) and if your cloning software does not handle it for you.

"); hexTEMP=""; dataCONVERSION+=F("

"); bin2hexBUFFlen=0; } if (server.hasArg("hex2binHTML")) { int hex2binBUFFlen=(((server.arg("hex2binHTML")).length())+1); char hex2binCHAR[hex2binBUFFlen]; (server.arg("hex2binHTML")).toCharArray(hex2binCHAR,hex2binBUFFlen); dataCONVERSION+=String()+F("Hexadecimal: ")+hex2binCHAR+F("

"); String binTEMP=""; int charCOUNT=(hex2binBUFFlen-1); for (int currentHEXpos=0; currentHEXpos
"); binTEMP=""; dataCONVERSION+=F("

"); hex2binBUFFlen=0; } if (server.hasArg("abaHTML")) { String abaHTML=(server.arg("abaHTML")); dataCONVERSION="Trying \"Forward\" Swipe
"; dataCONVERSION+=("Forward Binary:"+abaHTML+"
"); int abaStart=abaHTML.indexOf("11010"); int abaEnd=(abaHTML.lastIndexOf("11111")+4); dataCONVERSION+=aba2str(abaHTML,abaStart,abaEnd,"\"Forward\" Swipe"); dataCONVERSION+=" * Trying \"Reverse\" Swipe
"; int abaBUFFlen=((abaHTML.length())+1); char abachar[abaBUFFlen]; abaHTML.toCharArray(abachar,abaBUFFlen); abaHTML=String(strrev(abachar)); dataCONVERSION+=("Reversed Binary:"+abaHTML+"
"); abaStart=abaHTML.indexOf("11010"); abaEnd=(abaHTML.lastIndexOf("11111")+4); dataCONVERSION+=aba2str(abaHTML,abaStart,abaEnd,"\"Reverse\" Swipe"); //dataCONVERSION+=(String()+F(" * You can verify the data at the following URL:
https://www.legacysecuritygroup.com/aba-decode.php?binary=")+abaHTML+F("")); dataCONVERSION.replace("*", "

"); dataCONVERSION.replace(":", ": "); abaHTML=""; abaStart=0; abaEnd=0; } server.send(200, "text/html", String()+F( "<- BACK TO INDEX

") +dataCONVERSION+ F( "
" "
" "Convert ABA Binary Data to ASCII:
" "
" "
" "
" "
" "
" "Convert Binary Data to Hexadecimal:
" "For use with card cloning, typically includes both the preamble and card data(binary before and after the space in log).
" "
" "
" "
" "
" "
" "Convert Hexadecimal Data to Binary:
" "In some situations you may want to add a leading zero to pad the output to come up with the correct number of bits.
" "
" "
" "
" ) ); dataCONVERSION=""; }); #include "api_server.h" server.on("/stoptx", [](){ server.send(200, "text/html", F("This will kill any ongoing transmissions.

Are you sure?

YES - NO")); }); server.on("/stoptx/yes", [](){ TXstatus=0; server.send(200, "text/html", F("<- BACK TO INDEX

<- BACK TO EXPERIMENTAL TX MODE

All transmissions have been stopped.")); }); server.on("/experimental", [](){ String experimentalStatus="Awaiting Instructions"; if (server.hasArg("pinHTML")||server.hasArg("bruteEND")) { pinHTML=server.arg("pinHTML"); int pinBITS=server.arg("pinBITS").toInt(); int pinHTMLDELAY=server.arg("pinHTMLDELAY").toInt(); int bruteforcing; int brutePAD=(server.arg("bruteSTART").length()); if (server.hasArg("bruteSTART")) { bruteforcing=1; } else { bruteforcing=0; } TXstatus=1; wg.pause(); digitalWrite(DATA0, HIGH); pinMode(DATA0,OUTPUT); digitalWrite(DATA1, HIGH); pinMode(DATA1,OUTPUT); pinHTML.replace("F1","C"); pinHTML.replace("F2","D"); pinHTML.replace("F3","E"); pinHTML.replace("F4","F"); experimentalStatus=String()+"Transmitting "+pinBITS+"bit Wiegand Format PIN: "+pinHTML+" with a "+pinHTMLDELAY+"ms delay between \"keypresses\""; delay(50); int bruteSTART; int bruteEND; if (server.hasArg("bruteSTART")) { bruteSTART=server.arg("bruteSTART").toInt(); } else { bruteSTART=0; } if (server.hasArg("bruteEND")) { bruteEND=server.arg("bruteEND").toInt(); } else { bruteEND=0; } if (server.hasArg("bruteSTART")) { server.send(200, "text/html", String()+"<- BACK TO INDEX

<- BACK TO EXPERIMENTAL TX MODE

Brute forcing "+pinBITS+"bit Wiegand Format PIN from "+(server.arg("bruteSTART"))+" to "+(server.arg("bruteEND"))+" with a "+pinHTMLDELAY+"ms delay between \"keypresses\"
This may take a while, your device will be busy until the sequence has been completely transmitted!
Please \"STOP CURRENT TRANSMISSION\" before attempting to use your device or simply wait for the transmission to finish.
You can view if the brute force attempt has completed by returning to the Experimental TX page and checking the status located under \"Transmit Status\"

"); delay(50); } String bruteSTARTchar=""; String bruteENDchar=""; if (server.hasArg("bruteSTARTchar")&&(server.arg("bruteSTARTchar")!="")) { bruteSTARTchar=(server.arg("bruteSTARTchar")); bruteSTARTchar.replace("F1","C"); bruteSTARTchar.replace("F2","D"); bruteSTARTchar.replace("F3","E"); bruteSTARTchar.replace("F4","F"); } if (server.hasArg("bruteENDchar")&&(server.arg("bruteENDchar")!="")) { bruteENDchar=(server.arg("bruteENDchar")); bruteENDchar=(server.arg("bruteENDchar")); bruteENDchar.replace("F1","C"); bruteENDchar.replace("F2","D"); bruteENDchar.replace("F3","E"); bruteENDchar.replace("F4","F"); } unsigned long bruteFAILdelay=0; unsigned long bruteFAILS=0; int bruteFAILmultiplier=0; int bruteFAILmultiplierCURRENT=0; int bruteFAILmultiplierAFTER=0; int delayAFTERpin=0; int bruteFAILSmax=0; bruteFAILSmax=(server.arg("bruteFAILSmax")).toInt(); delayAFTERpin=(server.arg("delayAFTERpin")).toInt(); bruteFAILdelay=(server.arg("bruteFAILdelay")).toInt(); bruteFAILmultiplier=(server.arg("bruteFAILmultiplier")).toInt(); bruteFAILmultiplierAFTER=(server.arg("bruteFAILmultiplierAFTER")).toInt(); for (int brute=bruteSTART; brute<=bruteEND; brute++) { if (bruteforcing==1) { pinHTML=String(brute); while (pinHTML.length()=4294967000) { bruteFAILS=(4294966000); } if (bruteFAILdelay>=4294967000) { bruteFAILdelay=(4294966000); } if (bruteFAILmultiplier!=0) { bruteFAILmultiplierCURRENT++; if (bruteFAILmultiplierCURRENT>=bruteFAILmultiplierAFTER) { bruteFAILmultiplierCURRENT=0; bruteFAILdelay=(bruteFAILdelay*bruteFAILmultiplier); } } if ((bruteFAILS>=bruteFAILSmax)&&(bruteFAILSmax!=0)) { delay(bruteFAILdelay*1000); } else { delay(delayAFTERpin); } } pinMode(DATA0, INPUT); pinMode(DATA1, INPUT); wg.clear(); pinHTML=""; pinHTMLDELAY=100; TXstatus=0; bruteforcing=0; brutePAD=0; bruteSTARTchar=""; bruteENDchar=""; bruteFAILdelay=0; bruteFAILS=0; bruteFAILmultiplier=0; bruteFAILmultiplierCURRENT=0; bruteFAILmultiplierAFTER=0; delayAFTERpin=0; bruteFAILSmax=0; } if (server.hasArg("binHTML")) { String binHTML=server.arg("binHTML"); wg.pause(); digitalWrite(DATA0, HIGH); pinMode(DATA0,OUTPUT); digitalWrite(DATA1, HIGH); pinMode(DATA1,OUTPUT); for (int i=0; i<=binHTML.length(); i++) { if (binHTML.charAt(i) == '0') { digitalWrite(DATA0, LOW); delayMicroseconds(txdelayus); digitalWrite(DATA0, HIGH); } else if (binHTML.charAt(i) == '1') { digitalWrite(DATA1, LOW); delayMicroseconds(txdelayus); digitalWrite(DATA1, HIGH); } delay(txdelayms); } pinMode(DATA0, INPUT); pinMode(DATA1, INPUT); wg.clear(); experimentalStatus=String()+"Transmitting Binary: "+binHTML; binHTML=""; } if (server.arg("fuzzType")=="simultaneous") { int fuzzTimes=0; dos=0; if ((server.arg("fuzzTimes"))=="dos") { dos=1; server.send(200, "text/html", String()+ "<- BACK TO INDEX

" "<- BACK TO EXPERIMENTAL TX MODE

" "Denial of Service mode active.
Transmitting D0 and D1 bits simultaneously until stopped." "
This may take a while, your device will be busy until the sequence has been completely transmitted!" "
Please \"STOP CURRENT TRANSMISSION\" before attempting to use your device or simply wait for the transmission to finish.
" "You can view if the fuzzing attempt has completed by returning to the Experimental TX page and checking the status located under \"Transmit Status\"

" ""); delay(50); } else { fuzzTimes=server.arg("fuzzTimes").toInt(); server.send(200, "text/html", String()+ "<- BACK TO INDEX

" "<- BACK TO EXPERIMENTAL TX MODE

" "Transmitting D0 and D1 bits simultaneously "+fuzzTimes+" times." "
This may take a while, your device will be busy until the sequence has been completely transmitted!" "
Please \"STOP CURRENT TRANSMISSION\" before attempting to use your device or simply wait for the transmission to finish.
" "You can view if the fuzzing attempt has completed by returning to the Experimental TX page and checking the status located under \"Transmit Status\"

" ""); delay(50); } wg.pause(); digitalWrite(DATA0, HIGH); pinMode(DATA0,OUTPUT); digitalWrite(DATA1, HIGH); pinMode(DATA1,OUTPUT); TXstatus=1; for (int i=0; i<=fuzzTimes || dos==1; i++) { digitalWrite(DATA0, LOW); digitalWrite(DATA1, LOW); delayMicroseconds(txdelayus); digitalWrite(DATA0, HIGH); digitalWrite(DATA1, HIGH); delay(txdelayms); server.handleClient(); if (TXstatus!=1) { break; } } pinMode(DATA0, INPUT); pinMode(DATA1, INPUT); wg.clear(); TXstatus=0; dos=0; //experimentalStatus=String()+"Transmitting D0 and D1 bits simultaneously "+fuzzTimes+" times."; } if (server.arg("fuzzType")=="alternating") { int fuzzTimes=0; dos=0; if ((server.arg("fuzzTimes"))=="dos") { dos=1; server.send(200, "text/html", String()+ "<- BACK TO INDEX

" "<- BACK TO EXPERIMENTAL TX MODE

" "Denial of Service mode active.
Transmitting bits alternating between D0 and D1 until stopped." "
This may take a while, your device will be busy until the sequence has been completely transmitted!" "
Please \"STOP CURRENT TRANSMISSION\" before attempting to use your device or simply wait for the transmission to finish.
" "You can view if the fuzzing attempt has completed by returning to the Experimental TX page and checking the status located under \"Transmit Status\"

" ""); delay(50); } else { fuzzTimes=server.arg("fuzzTimes").toInt(); server.send(200, "text/html", String()+ "<- BACK TO INDEX

" "<- BACK TO EXPERIMENTAL TX MODE

" "Transmitting "+fuzzTimes+" bits alternating between D0 and D1." "
This may take a while, your device will be busy until the sequence has been completely transmitted!" "
Please \"STOP CURRENT TRANSMISSION\" before attempting to use your device or simply wait for the transmission to finish.
" "You can view if the fuzzing attempt has completed by returning to the Experimental TX page and checking the status located under \"Transmit Status\"

" ""); delay(50); } wg.pause(); digitalWrite(DATA0, HIGH); pinMode(DATA0,OUTPUT); digitalWrite(DATA1, HIGH); pinMode(DATA1,OUTPUT); String binALT=""; TXstatus=1; for (int i=0; i"; currentPIN=""; } else if (dos==1) { activeTX="Denial of Service mode active...
"; } else { activeTX="Transmitting...
"; } } else { activeTX="INACTIVE
"; } server.send(200, "text/html", String()+ F( "" "" "" "Experimental TX Mode" "" "" )+experimentalStatus+"

" +F( "Transmit Status: ")+activeTX+F("

" "<- BACK TO INDEX
" "

" "

Experimental TX Mode

" "
" "" "Warning: This mode is highly experimental, use at your own risk!
" "Note: Timings for the Wiegand Data Pulse Width and Wiegand Data Interval may be changed on the settings page." "
" "
" "
" "
" "
" "Binary Data:
" "Typically no need to include preamble
" "
" "
" "
" "
" "
" "
" "
" "Transmit PIN:
" "Available keys 0-9, * or A, # or B, F1 or C, F2 or D, F3 or E, F4 or F
" "PIN:
" "Delay between \"keypresses\": ms
" " 4bit Wiegand PIN Format " " 8bit Wiegand PIN Format
" "
" "
" "
" "
" "
" "
" "Bruteforce PIN:
" "Delay between \"keypresses\": ms
" "Delay between entering complete PINs: ms
" "PIN begins with character(s):
" "PIN start position:
" "PIN end position:
" "PIN ends with character(s):
" "NOTE: The advanced timing settings listed below override the \"Delay between entering complete PINs\" setting(listed above) when the conditions listed below are met.
" "Number of failed PIN attempts(X) before a delay:
" "Delay in seconds(Y) after [X] failed PINs: s
" "Multiply delay [Y] by after every failed pin attempts
" " 4bit Wiegand PIN Format " " 8bit Wiegand PIN Format
" "

" "
" "
" "
" "Fuzzing:

" "
" "Number of bits:" "
" //" 0, must not be empty \" minlength=\"1\" size=\"32\">
" " Transmit a bit simultaneously on D0 and D1 (X bits per each line)
" " Transmit X bits alternating between D0 and D1 each bit (01010101,etc)
" "
" "
" "
" "
" "
" "Denial Of Service Mode:

" "
" "Type of Attack:" "
" " Transmit a bit simultaneously on D0 and D1 until stopped
" " Transmit bits alternating between D0 and D1 each bit (01010101,etc) until stopped
" "
" "
" "
" "
" "
" "Push Button for Door Open:
" "Connect \"Push to Open\" wire from the reader to the RX pin(GPIO3) on the programming header on ESP-RFID-Tool.
" "Warning! Selecting the wrong trigger signal type may cause damage to the connected hardware.

" "
" "Time in ms to push the door open button:" " 0, must not be empty\" minlength=\"1\" size=\"32\">
" "Does the wire expect a High or Low signal to open the door:" " Low Signal[Ground] " " High Signal[3.3V]
" "
" "
" "
" "
" "
" "

" "" "" ) ); if (server.args()>=1) { if (safemode==1) { delay(50); ESP.restart(); } } }); server.begin(); WiFiClient client; client.setNoDelay(1); // Serial.println("Web Server Started"); MDNS.begin("ESP"); httpUpdater.setup(&httpServer, update_path, update_username, update_password); httpServer.begin(); MDNS.addService("http", "tcp", 1337); if (ftpenabled==1){ ftpSrv.begin(String(ftp_username),String(ftp_password)); } //Start RFID Reader pinMode(LED_BUILTIN, OUTPUT); // LED if (ledenabled==1){ digitalWrite(LED_BUILTIN, LOW); } else{ digitalWrite(LED_BUILTIN, HIGH); } } // //Do It! /////////////////////////////////////////////////////// // LOOP function void loop() { if (ftpenabled==1){ ftpSrv.handleFTP(); } server.handleClient(); httpServer.handleClient(); while (Serial.available()) { String cmd = Serial.readStringUntil(':'); if(cmd == "ResetDefaultConfig"){ loadDefaults(); ESP.restart(); } } //Serial.print("Free heap-"); //Serial.println(ESP.getFreeHeap(),DEC); if(wg.available()) { wg.pause(); // pause Wiegand pin interrupts LogWiegand(wg); wg.clear(); // compulsory to call clear() to enable interrupts for subsequent data if (safemode==1) { ESP.restart(); } } } ================================================ FILE: Source Code/esprfidtool/pinSEND.h ================================================ void pinSEND(int pinDELAY,String pinBIN) { for (int i=0; i<=pinBIN.length(); i++) { if (pinBIN.charAt(i) == '0') { digitalWrite(DATA0, LOW); delayMicroseconds(txdelayus); digitalWrite(DATA0, HIGH); } else if (pinBIN.charAt(i) == '1') { digitalWrite(DATA1, LOW); delayMicroseconds(txdelayus); digitalWrite(DATA1, HIGH); } delay(txdelayms); } yield(); delay(pinDELAY); pinBIN=""; pinDELAY=100; } ================================================ FILE: Source Code/esprfidtool/strrev.h ================================================ /* Copyright (c) 2007 Dmitry Xmelkov All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * 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. * Neither the name of the copyright holders nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT OWNER 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. */ /* $Id$ */ char * strrev (char *s) { char *p1, *p2; for (p2 = s; *p2; ) p2++; p1 = s; while (p1 < p2) { char c1 = *p1; char c2 = *--p2; *p1++ = c2; *p2 = c1; } return s; } ================================================ FILE: Source Code/esprfidtool/version.h ================================================ String version = "1.2.1"; String APIversion = "1.0.4";