├── .gitignore ├── Connector-Adapter-Options ├── Punchdown-Adapter-1 │ ├── BOM │ ├── Image-Credits.txt │ ├── bottom-adapter.png │ ├── punchdown-adapter-Gerber.zip │ └── top-adapter.png ├── Punchdown-Adapter-2 │ ├── BOM │ ├── Image-Credits.txt │ ├── bottom-adapter2.png │ ├── punchdown-adapter2-Gerber.zip │ └── top-adapter2.png ├── README.md ├── pd2-custom.jpg ├── portable-5375.jpg ├── punchdown.jpg ├── screwdown.jpg ├── tsplice1.jpg └── wirenuts.jpg ├── Images ├── 5355keypad-bin2pin.jpg ├── README.md ├── board.jpg ├── logo.png ├── programmer.jpg ├── webint.png └── wiring.jpg ├── Installation-Schematics ├── 2-rfid-tool-units.png ├── README.md ├── benchtop-psu.png ├── implant.png ├── portable-standalone.png └── unsupported-voltages.png ├── 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 /.gitignore: -------------------------------------------------------------------------------- 1 | *bin -------------------------------------------------------------------------------- /Connector-Adapter-Options/Punchdown-Adapter-1/BOM: -------------------------------------------------------------------------------- 1 | Choose the wire gauge, purchase (2) of the "2 WAY" terminals and purchase the appropriate punch down tool. 2 | The combination of parts below are currently untested. 3 | 4 | Tool Punch Down Tool Hand Tools ASSEMBLY BIT INSUL DIA 1.60; Mfr. #: 069176701602000 ; Mouser Part #: 581-069176701602000 5 | 6 | Choose your targets wiring size below. 7 | * 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. 8 | Research is still ongoing regarding an officially recommended connector. 9 | 10 | 18AWG IDC Punch Down Block 11 | (D0),(D1) IDC Terminal - 2 way Desc.: 2 WAY WIRE TO BD 18 AWG STRANDED ; Mfr. #: 009176002001006; Mouser Part #: 581-009176002001006 12 | (+),(-) IDC Terminal - 2 way Desc.: 2 WAY WIRE TO BD 18 AWG STRANDED ; Mfr. #: 009176002001006; Mouser Part #: 581-009176002001006 13 | 14 | 20AWG IDC Punch Down Block * 15 | (D0),(D1) IDC Terminal - 2 way Desc.: 2 WAY WIRE TO BD 20 AWG STRANDED ; Mfr. #: 009176002011006; Mouser Part #: 581-009176002011006 16 | (+),(-) IDC Terminal - 2 way Desc.: 2 WAY WIRE TO BD 20 AWG STRANDED ; Mfr. #: 009176002011006; Mouser Part #: 581-009176002011006 17 | 18 | 22AWG IDC Punch Down 19 | (D0),(D1) IDC Terminal - 2 way Desc.: 2 WAY WIRE TO BD 22 AWG STRANDED; Mfr. #: 009176002022006; Mouser Part #: 581-009176002022006 20 | (+),(-) IDC Terminal - 2 way Desc.: 2 WAY WIRE TO BD 22 AWG STRANDED; Mfr. #: 009176002022006; Mouser Part #: 581-009176002022006 21 | 22 | 24AWG IDC Punch Down 23 | (D0),(D1) IDC Terminal - 2 way Desc.: 2 WAY WIRE TO BD 24 AWG STRANDED; Mfr. #: 009176002032006; Mouser Part #: 581-009176002032006 24 | (+),(-) IDC Terminal - 2 way Desc.: 2 WAY WIRE TO BD 24 AWG STRANDED; Mfr. #: 009176002032006; Mouser Part #: 581-009176002032006 -------------------------------------------------------------------------------- /Connector-Adapter-Options/Punchdown-Adapter-1/Image-Credits.txt: -------------------------------------------------------------------------------- 1 | PCB renders generated using https://pcbs.io. -------------------------------------------------------------------------------- /Connector-Adapter-Options/Punchdown-Adapter-1/bottom-adapter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rfidtool/ESP-RFID-Tool/b0bb4cc692afde31613444595f33b282489bf127/Connector-Adapter-Options/Punchdown-Adapter-1/bottom-adapter.png -------------------------------------------------------------------------------- /Connector-Adapter-Options/Punchdown-Adapter-1/punchdown-adapter-Gerber.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rfidtool/ESP-RFID-Tool/b0bb4cc692afde31613444595f33b282489bf127/Connector-Adapter-Options/Punchdown-Adapter-1/punchdown-adapter-Gerber.zip -------------------------------------------------------------------------------- /Connector-Adapter-Options/Punchdown-Adapter-1/top-adapter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rfidtool/ESP-RFID-Tool/b0bb4cc692afde31613444595f33b282489bf127/Connector-Adapter-Options/Punchdown-Adapter-1/top-adapter.png -------------------------------------------------------------------------------- /Connector-Adapter-Options/Punchdown-Adapter-2/BOM: -------------------------------------------------------------------------------- 1 | Choose the wire gauge, purchase (2) of the "2 WAY" terminals and purchase the appropriate punch down tool. 2 | The combination of parts below are currently untested. 3 | 4 | Tool Punch Down Tool Hand Tools ASSEMBLY BIT INSUL DIA 1.60; Mfr. #: 069176701602000 ; Mouser Part #: 581-069176701602000 5 | 6 | Choose your targets wiring size below. 7 | * 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. 8 | Research is still ongoing regarding an officially recommended connector. 9 | 10 | 18AWG IDC Punch Down Block 11 | (D0),(D1) IDC Terminal - 2 way Desc.: 2 WAY WIRE TO BD 18 AWG STRANDED ; Mfr. #: 009176002001006; Mouser Part #: 581-009176002001006 12 | (+),(-) IDC Terminal - 2 way Desc.: 2 WAY WIRE TO BD 18 AWG STRANDED ; Mfr. #: 009176002001006; Mouser Part #: 581-009176002001006 13 | 14 | 20AWG IDC Punch Down Block * 15 | (D0),(D1) IDC Terminal - 2 way Desc.: 2 WAY WIRE TO BD 20 AWG STRANDED ; Mfr. #: 009176002011006; Mouser Part #: 581-009176002011006 16 | (+),(-) IDC Terminal - 2 way Desc.: 2 WAY WIRE TO BD 20 AWG STRANDED ; Mfr. #: 009176002011006; Mouser Part #: 581-009176002011006 17 | 18 | 22AWG IDC Punch Down 19 | (D0),(D1) IDC Terminal - 2 way Desc.: 2 WAY WIRE TO BD 22 AWG STRANDED; Mfr. #: 009176002022006; Mouser Part #: 581-009176002022006 20 | (+),(-) IDC Terminal - 2 way Desc.: 2 WAY WIRE TO BD 22 AWG STRANDED; Mfr. #: 009176002022006; Mouser Part #: 581-009176002022006 21 | 22 | 24AWG IDC Punch Down 23 | (D0),(D1) IDC Terminal - 2 way Desc.: 2 WAY WIRE TO BD 24 AWG STRANDED; Mfr. #: 009176002032006; Mouser Part #: 581-009176002032006 24 | (+),(-) IDC Terminal - 2 way Desc.: 2 WAY WIRE TO BD 24 AWG STRANDED; Mfr. #: 009176002032006; Mouser Part #: 581-009176002032006 -------------------------------------------------------------------------------- /Connector-Adapter-Options/Punchdown-Adapter-2/Image-Credits.txt: -------------------------------------------------------------------------------- 1 | PCB renders generated using https://pcbs.io. -------------------------------------------------------------------------------- /Connector-Adapter-Options/Punchdown-Adapter-2/bottom-adapter2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rfidtool/ESP-RFID-Tool/b0bb4cc692afde31613444595f33b282489bf127/Connector-Adapter-Options/Punchdown-Adapter-2/bottom-adapter2.png -------------------------------------------------------------------------------- /Connector-Adapter-Options/Punchdown-Adapter-2/punchdown-adapter2-Gerber.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rfidtool/ESP-RFID-Tool/b0bb4cc692afde31613444595f33b282489bf127/Connector-Adapter-Options/Punchdown-Adapter-2/punchdown-adapter2-Gerber.zip -------------------------------------------------------------------------------- /Connector-Adapter-Options/Punchdown-Adapter-2/top-adapter2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rfidtool/ESP-RFID-Tool/b0bb4cc692afde31613444595f33b282489bf127/Connector-Adapter-Options/Punchdown-Adapter-2/top-adapter2.png -------------------------------------------------------------------------------- /Connector-Adapter-Options/README.md: -------------------------------------------------------------------------------- 1 | ## Connector Options 2 | 3 | ### Standard Screwdown Connection 4 | ![ScrewDown](screwdown.jpg?raw=true) 5 | ![ScrewDown-Portable-5375](portable-5375.jpg?raw=true) 6 | 7 | ### Gray Wire Nuts 22-16AWG 8 | 9 | ![Wire-Nuts](wirenuts.jpg?raw=true) 10 | ##### 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. 11 | 12 | ### Screwdown to T-Taps (Wire Splices) 13 | 14 | #### T-Tap Example 1 15 | ![T-Tap1](tsplice1.jpg?raw=true) 16 | * Uxcell T-Tap Male Insulated Wire Terminal Quick Connector Combo Set 10 Piece, Red 17 | * by Uxcell 18 | [$6.82 on Amazon](http://a.co/6joYNzS) 19 | ##### 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. 20 | 21 | #### T-Tap Example 2 22 | * Brightfour Quick Wire Splice Connector-T type 1 Pin solderless- Compatible with 22 - 20 AWG Cable for Some Tight-fitting Automotive Uses 23 | * by Brightfour 24 | [$8.44 on Amazon](http://a.co/bAw7Fdw) 25 | ##### 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. 26 | 27 | ### Screwdown to Punchdown Adapter 28 | 29 | ##### PCB renders generated using https://pcbs.io. 30 | 31 | #### Side by Side 32 | * [Gerber File](Punchdown-Adapter-1/punchdown-adapter-Gerber.zip) 33 | * [BOM File](Punchdown-Adapter-1/BOM) 34 | * [Order PCB](https://pcbs.io/share/4KXmA) 35 | ![Punchdown1](punchdown.jpg?raw=true) 36 | ![Punchdown1-top](Punchdown-Adapter-1/top-adapter.png?raw=true) ![Punchdown1-bottom](Punchdown-Adapter-1/bottom-adapter.png?raw=true) 37 | 38 | #### Perpendicular 39 | * [Gerber File](Punchdown-Adapter-2/punchdown-adapter2-Gerber.zip) 40 | * [BOM File](Punchdown-Adapter-2/BOM) 41 | * [Order PCB](https://pcbs.io/share/zy0jg) 42 | 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. 43 | ![Punchdown2-Custom](pd2-custom.jpg?raw=true) 44 | ![Punchdown2-top](Punchdown-Adapter-2/top-adapter2.png?raw=true) ![Punchdown2-bottom](Punchdown-Adapter-2/bottom-adapter2.png?raw=true) -------------------------------------------------------------------------------- /Connector-Adapter-Options/pd2-custom.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rfidtool/ESP-RFID-Tool/b0bb4cc692afde31613444595f33b282489bf127/Connector-Adapter-Options/pd2-custom.jpg -------------------------------------------------------------------------------- /Connector-Adapter-Options/portable-5375.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rfidtool/ESP-RFID-Tool/b0bb4cc692afde31613444595f33b282489bf127/Connector-Adapter-Options/portable-5375.jpg -------------------------------------------------------------------------------- /Connector-Adapter-Options/punchdown.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rfidtool/ESP-RFID-Tool/b0bb4cc692afde31613444595f33b282489bf127/Connector-Adapter-Options/punchdown.jpg -------------------------------------------------------------------------------- /Connector-Adapter-Options/screwdown.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rfidtool/ESP-RFID-Tool/b0bb4cc692afde31613444595f33b282489bf127/Connector-Adapter-Options/screwdown.jpg -------------------------------------------------------------------------------- /Connector-Adapter-Options/tsplice1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rfidtool/ESP-RFID-Tool/b0bb4cc692afde31613444595f33b282489bf127/Connector-Adapter-Options/tsplice1.jpg -------------------------------------------------------------------------------- /Connector-Adapter-Options/wirenuts.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rfidtool/ESP-RFID-Tool/b0bb4cc692afde31613444595f33b282489bf127/Connector-Adapter-Options/wirenuts.jpg -------------------------------------------------------------------------------- /Images/5355keypad-bin2pin.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rfidtool/ESP-RFID-Tool/b0bb4cc692afde31613444595f33b282489bf127/Images/5355keypad-bin2pin.jpg -------------------------------------------------------------------------------- /Images/README.md: -------------------------------------------------------------------------------- 1 | ![Logo](logo.png?raw=true) 2 | ![Board](board.jpg?raw=true) 3 | ![Wiring](wiring.jpg?raw=true) 4 | ![Programmer](programmer.jpg?raw=true) -------------------------------------------------------------------------------- /Images/board.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rfidtool/ESP-RFID-Tool/b0bb4cc692afde31613444595f33b282489bf127/Images/board.jpg -------------------------------------------------------------------------------- /Images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rfidtool/ESP-RFID-Tool/b0bb4cc692afde31613444595f33b282489bf127/Images/logo.png -------------------------------------------------------------------------------- /Images/programmer.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rfidtool/ESP-RFID-Tool/b0bb4cc692afde31613444595f33b282489bf127/Images/programmer.jpg -------------------------------------------------------------------------------- /Images/webint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rfidtool/ESP-RFID-Tool/b0bb4cc692afde31613444595f33b282489bf127/Images/webint.png -------------------------------------------------------------------------------- /Images/wiring.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rfidtool/ESP-RFID-Tool/b0bb4cc692afde31613444595f33b282489bf127/Images/wiring.jpg -------------------------------------------------------------------------------- /Installation-Schematics/2-rfid-tool-units.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rfidtool/ESP-RFID-Tool/b0bb4cc692afde31613444595f33b282489bf127/Installation-Schematics/2-rfid-tool-units.png -------------------------------------------------------------------------------- /Installation-Schematics/README.md: -------------------------------------------------------------------------------- 1 | ![Implant](implant.png?raw=true) 2 | ![Portable-Standalone](portable-standalone.png?raw=true) 3 | ![Benchtop-PSU-Standalone](benchtop-psu.png?raw=true) 4 | ![Unsupported-Voltages](unsupported-voltages.png?raw=true) 5 | ![2-RFID-Tool-Units](2-rfid-tool-units.png?raw=true) -------------------------------------------------------------------------------- /Installation-Schematics/benchtop-psu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rfidtool/ESP-RFID-Tool/b0bb4cc692afde31613444595f33b282489bf127/Installation-Schematics/benchtop-psu.png -------------------------------------------------------------------------------- /Installation-Schematics/implant.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rfidtool/ESP-RFID-Tool/b0bb4cc692afde31613444595f33b282489bf127/Installation-Schematics/implant.png -------------------------------------------------------------------------------- /Installation-Schematics/portable-standalone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rfidtool/ESP-RFID-Tool/b0bb4cc692afde31613444595f33b282489bf127/Installation-Schematics/portable-standalone.png -------------------------------------------------------------------------------- /Installation-Schematics/unsupported-voltages.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rfidtool/ESP-RFID-Tool/b0bb4cc692afde31613444595f33b282489bf127/Installation-Schematics/unsupported-voltages.png -------------------------------------------------------------------------------- /Keypad/README.md: -------------------------------------------------------------------------------- 1 | ![HID-5355-Bin2Pin-Reference](../Images/5355keypad-bin2pin.jpg?raw=true) -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) [2018] [Corey Harding] 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Magstripe/README.md: -------------------------------------------------------------------------------- 1 | ## ABA Encoding 2 | 3 | Wiegand Magstripe Readers Tested: 4 | * HID 3110-6445 Magstripe Pass-Through Reader 5 | * set to rotary position B (Raw Data - All Bits Wiegand) 6 | * HID multiCLASS RM40 iCLASS/Magstripe Reader 6220CKN000B 7 | * purchase a reader with the last digit B in item # (ex: 6220CKN000**B**) 8 | 9 | RFID-Tool Specific Settings 10 | * set buffer size to 256 bits or greater 11 | 12 | See [aba-decode.php](aba-decode.php) script for converting binary card data to ascii (Script by: AndrewMohawk) 13 | * Command Line: /usr/bin/php aba-decode.php 1101000001100000100011001001001010101101111000001010011101101111100010 14 | * Web: https://www.LegacySecurityGroup.com/aba-decode.php 15 | 16 | Binary: 17 | 5 bits 18 | Little Endian Format 19 | 20 | LRC(Longitudinal Redundancy Check): 21 | Count # of set bits(1's) in column 22 | EVEN = 0 23 | ODD = 1 24 | 25 | Track 2 Debit/Credit Card Format(for example, as I could not find actual magstripe access control cards): 26 | ;1234567890123456=YYMMSSSDDDDDDDDDDDDDD?* 27 | ; = Start Sentinel 28 | 1234567890123456 = 16 Digit Card # 29 | = = End Card # 30 | YY = Expiration Year 31 | MM = Expiration Month 32 | 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) 33 | DDDDDDDDDDDDDD = Discretionary Data 34 | ? = End Sentinel 35 | *=LRC 36 | 37 | Binary Reference: 38 | 11010 ; - Start Sentinel 39 | 00001 0 40 | 10000 1 41 | 01000 2 42 | 11001 3 43 | 00100 4 44 | 10101 5 45 | 01101 6 46 | 11100 7 47 | 00010 8 48 | 10011 9 49 | 00111 < 50 | 01110 > 51 | 01011 : 52 | 10110 = - End Card Number 53 | 11111 ? - End Sentinel 54 | 00010 LRC 55 | -------------------------------------------------------------------------------- /Magstripe/aba-decode.php: -------------------------------------------------------------------------------- 1 | "); 21 | } 22 | if (empty($binary)) { 23 | $binary = "1101000001100000100011001001001010101101111000001010011101101111100010"; 24 | } 25 | 26 | echo "https://github.com/rfidtool/ESP-RFID-Tool/blob/master/Magstripe/aba-decode.php" . LINEBREAK; 27 | echo "For converting Track 2 Magstripe ABA Binary data to ASCII" . LINEBREAK . LINEBREAK; 28 | 29 | echo "Original script by: AndrewMohawk" . LINEBREAK; 30 | // andrew@andrewmohawk.com 31 | echo "http://www.andrewmohawk.com" . LINEBREAK . LINEBREAK; 32 | 33 | echo "Modified slightly by: Corey Harding" . LINEBREAK; 34 | echo "www.LegacySecurityGroup.com / www.Exploit.Agency" . LINEBREAK . LINEBREAK; 35 | 36 | if (!defined('STDIN')) { 37 | ?> 38 | 39 | 40 |
41 | 42 | 43 |
44 | 45 | 46 | strlen($haystack)) 53 | trigger_error(sprintf("%s: length of argument 2 must be <= argument 1", __FUNCTION__), E_USER_WARNING); 54 | 55 | $seeks = array(); 56 | while($seek = strrpos($haystack, $needle)) 57 | { 58 | array_push($seeks, $seek); 59 | $haystack = substr($haystack, 0, $seek); 60 | } 61 | return $seeks; 62 | } 63 | 64 | function processBinary($binary) 65 | { 66 | $AsciiOutput = ""; 67 | 68 | //find start sentinel 69 | $start_sentinel = strpos($binary,"11010"); 70 | if($start_sentinel === false) 71 | { 72 | echo "Could not find start sentinel" . LINEBREAK; 73 | return false; 74 | } 75 | 76 | //find end sentinel 77 | $end_sentinel = false; 78 | $end_sentinel = strrpos($binary,"11111"); 79 | if(count($end_sentinel) == 0) 80 | { 81 | echo "Could not find end sentinel" . LINEBREAK; 82 | return false; 83 | } 84 | 85 | //Lets decode the data: 86 | $bit_length = 5; // 4 bits for data, 1 bit for odd-parity or LRC checking 87 | 88 | 89 | $data = substr($binary,$start_sentinel,($end_sentinel-$start_sentinel+5)); 90 | 91 | $currentBits = ""; 92 | $currentNum = 0; 93 | $finalString = ""; 94 | 95 | for($i=0;$i=1.1.0 are compiled with esp8266 board manager package 2.4.1 31 | * Releases < 1.1.0 are compiled with esp8266 board manager package 2.3.0 32 | * Unofficial 33 | * Port of Tastic RFID Thief: https://github.com/exploitagency/ESP-RFID-Thief/releases 34 | 35 | ## Intended use cases 36 | * Security researchers performing red team assessments. 37 | * Capturing card values to later be cloned. 38 | * Replaying raw binary captures.*(see note below) 39 | * Fuzzing access control systems.*(see note below) 40 | * Brute forcing PIN codes.*(see note below) 41 | * Denial of Service mode.*(see note below) 42 | * To create a standalone device for capturing credentials or testing badges and or card readers without the need for a Wiegand Controller. 43 | * Add a battery and a card reader to make the unit portable. 44 | * Add a benchtop power supply to use for testing hardware. 45 | * Installers troubleshooting issues with a card reader, the data lines, or even testing for a faulty card. 46 | * Useful for merchants or surplus resellers who are testing if access control equipment is functional. 47 | * Hobbyist experimenting with various systems that utilize a Wiegand Interface. 48 | * Simulating an access control system using multiple units of ESP-RFID-Tool. 49 | * RFID-Tool is not intended to be used in any unlawful manner. 50 | 51 | ## What is it? 52 | 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. 53 | 54 | ## How do you install it? 55 | 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) 56 | 57 | ## How do you access the logs? 58 | 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. 59 | 60 | ## I want to know a little more... 61 | 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. 62 | 63 | ## *Experimental TX Mode 64 | 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) 65 | **Use transmit mode at your own risk, it is not officially supported. Consider it a bonus in the software.** 66 | 67 | ## **Installation Notes 68 | [Click here for wiring diagrams](Installation-Schematics/README.md) 69 | [Click here to see connector options](/Connector-Adapter-Options/README.md) 70 | * Make sure the reader outputs data in the Wiegand format 71 | * Connect D0 on device to D0 on reader 72 | * Connect D1 on device to D1 on reader 73 | * Connect + on device to + on reader 74 | * Connect - on device to - on reader 75 | * 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. 76 | * 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. 77 | * 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 -)   78 | * NOTE: At a minimum D0, D1, and GND(-) must be connected to the reader for proper function, no matter the power source. 79 | * Configure settings 80 | * See Below 81 | 82 | ## Making Sense of the Binary Data 83 | [Keypads](Keypad/README.md) 84 | [Magstripe/ABA Format](Magstripe/README.md) 85 | 86 | ## Flashing Firmware 87 | OPTION 1: OTA via the Web Interface: 88 | * Download one of the latest releases from 89 | * https://github.com/rfidtool/ESP-RFID-Tool/releases 90 | * Login to the device's admin panel and upgrade the firmware. 91 | 92 | OPTION 2: Arduino IDE: 93 | * Use the ESP Flasher R4 by April Brother: 94 | * https://blog.aprbrother.com/product/esp-flasher-r4 95 | * Clone/download the source. 96 | * Add these libraries: 97 | * ArduinoJson library 5.13.1 by Benoit Blanchon 98 | * https://github.com/bblanchon/ArduinoJson 99 | * ESP8266FtpServer.h 100 | * https://github.com/exploitagency/esp8266FTPServer/tree/feature/bbx10_speedup 101 | * Choose the board NodeMCU 1.0. 102 | * Upload. 103 | 104 | ## Software Help 105 | 106 | ### Accessing ESP-RFID-Tool Web Interface 107 | 108 | SSID: "ESP-RFID-Tool" 109 | URL: http://192.168.1.1 110 | 111 | ### Configure ESP-RFID-Tool 112 | 113 | #### Default credentials to access the configuration page: 114 | * Username: "admin" 115 | * Password: "rfidtool" 116 | 117 | #### Default credentials for ftp server: 118 | * Username: "ftp-admin" 119 | * Password: "rfidtool" 120 | 121 | #### WiFi Configuration: 122 | 123 | Network Type: 124 | * Access Point Mode: Create a standalone access point(No Internet Connectivity-Requires Close Proximity) 125 | * Join Existing Network: Join an existing network(Possible Internet Connectivity-Could use Device Remotely) 126 | 127 | Hidden: Choose whether or not to use a hidden SSID when creating an access point 128 | 129 | SSID: SSID of the access point to create or of the network you are choosing to join 130 | Password: Password of the access point which you wish to create or of the network you are choosing to join 131 | Channel: Channel of the access point you are creating 132 | 133 | IP: IP to set for device 134 | 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 135 | Subnet: Typically set to 255.255.255.0 136 | 137 | #### Web Interface Administration Settings: 138 | 139 | Username: Username to configure/upgrade ESP-RFID-Tool 140 | Password: Password to configure/upgrade ESP-RFID-Tool 141 | 142 | FTP Server Settings: 143 | 144 | Note: Supports Passive(PASV) Mode Only! 145 | * Enabled: Turn FTP Server ON 146 | * Disabled: Turn FTP Server OFF 147 | Username: Username to login to ftp server 148 | Password: Password to login to ftp server 149 | 150 | Power LED: 151 | 152 | * Enabled: Turn ON Power LED 153 | * Disabled: Turn OFF Power LED 154 | 155 | RFID Capture Log: 156 | 157 | Useful to change this value to differentiate between facilities during various security assessments. 158 | File Name: File name to save captured RFID tags to for the current security assessment. 159 | 160 | #### List Exfiltrated Data 161 | 162 | Displays all log files containing RFID tag captures. 163 | 164 | #### Format File System 165 | 166 | This will erase the contents of the SPIFFS file system including ALL RFID tag captures. 167 | Formatting may take up to 90 seconds. 168 | All current settings will be retained unless you reboot your device during this process. 169 | 170 | #### Upgrade ESP-RFID-Tool Firmware 171 | 172 | Authenticate using your username and password set in the configuration page. 173 | 174 | Default credentials to access the firmware upgrade page: 175 | * Username: "admin" 176 | * Password: "rfidtool" 177 | 178 | Select "Browse" choose the new firmware to be uploaded and then click "Upgrade". 179 | 180 | You will need to manually reset the device upon the browser alerting you that the upgrade was successful. 181 | 182 | #### Jumpers 183 | 184 | * J1: Bridge to reset the board(your FTDI doesn't have a reset button?) 185 | * J2: Cut the trace to disable DTR pin after programming then use it as an additional IO(continue updating firmware via web interface) 186 | * J3: Bridge this during a power cycle to restore default configuration without losing your log files. 187 | 188 | #### Restore Default Settings 189 | 190 | * Option 1: Go to settings under web interface and choose restore default configuration. 191 | * Option 2: Bridge J3 before booting the device. (Either before powering on or bridge it and reset the device) 192 | * Option 3: Connect via serial(9600 baud) and send the command "ResetDefaultConfig:" without quotes. 193 | 194 | ## History 195 | 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. 196 | 197 | ## Licensing Information 198 | 199 | Created by Corey Harding 200 | https://github.com/rfidtool/ESP-RFID-Tool 201 | ESP-RFID-Tool software is licensed under the MIT License 202 | 203 | #### Libraries/borrowed code being used 204 | 205 | ##### Arduino and ESP8266 core libraries 206 | * Typically: GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 207 | * Assorted Authors 208 | 209 | ##### ArduinoJson.h 210 | * The MIT License (MIT) 211 | * Copyright (c) 2014-2017 Benoit BLANCHON 212 | 213 | ##### ESP8266FtpServer.h 214 | * GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 215 | * Originally by nailbuster, later modified by bbx10 and apullin 216 | 217 | ##### WiegandNG.h 218 | * GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 219 | * JP Liew 220 | 221 | ##### Wiegand Preamble Calculator Code 222 | * No License Specified 223 | * Fran Brown of Bishop Fox 224 | 225 | ##### strrev.h 226 | * Custom License(see file) 227 | * Copyright (c) 2007 Dmitry Xmelkov 228 | 229 | ##### aba-decode.py 230 | * No License Specified 231 | * Andrew MacPherson(andrewmohawk) 232 | -------------------------------------------------------------------------------- /Source Code/esprfidtool/HelpText.h: -------------------------------------------------------------------------------- 1 | const char HelpText[] PROGMEM = R"=====( 2 | 3 | 4 | ESP-RFID-Tool Help Page 5 | 6 | <- BACK TO INDEX

7 | -----
8 | HELP
9 | -----
10 |
11 | ESP-RFID-Tool
12 |
13 | Created by Corey Harding
14 | www.LegacySecurityGroup.com / www.Exploit.Agency
15 | https://github.com/rfidtool/ESP-RFID-Tool - See Link for Updated Firmware or for more detailed Help
16 |
17 | 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.
18 |
19 | 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.
20 |
21 | -----
22 | Accessing ESP-RFID-Tool Web Interface
23 | -----
24 |
25 | SSID: "ESP-RFID-Tool"
26 | URL: http://192.168.1.1
27 |
28 | -----
29 | Configure ESP-RFID-Tool
30 | -----
31 |
32 | Default credentials to access the configuration page:
33 | Username: "admin"
34 | Password: "rfidtool"
35 |
36 | Default credentials for ftp server:
37 | Username: "ftp-admin"
38 | Password: "rfidtool"
39 |
40 | WiFi Configuration:
41 |
42 | Network Type:
43 | Access Point Mode: Create a standalone access point(No Internet Connectivity-Requires Close Proximity)
44 | Join Existing Network: Join an existing network(Possible Internet Connectivity-Could use Device Remotely)
45 |
46 | Hidden: Choose whether or not to use a hidden SSID when creating an access point
47 |
48 | SSID: SSID of the access point to create or of the network you are choosing to join
49 | Password: Password of the access point which you wish to create or of the network you are choosing to join
50 | Channel: Channel of the access point you are creating
51 |
52 | IP: IP to set for device
53 | 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
54 | Subnet: Typically set to 255.255.255.0
55 |
56 | Web Interface Administration Settings:
57 |
58 | Username: Username to configure/upgrade ESP-RFID-Tool
59 | Password: Password to configure/upgrade ESP-RFID-Tool
60 |
61 | FTP Server Settings:
62 |
63 | Note: Supports Passive(PASV) Mode Only!
64 | Enabled: Turn FTP Server ON
65 | Disabled: Turn FTP Server OFF
66 | Username: Username to login to ftp server
67 | Password: Password to login to ftp server
68 |
69 | Power LED:
70 |
71 | Enabled: Turn ON Power LED
72 | Disabled: Turn OFF Power LED
73 |
74 | RFID Capture Log:
75 |
76 | Useful to change this value to differentiate between facilities during various security assessments.
77 | File Name: File name to save captured RFID tags to for the current security assessment.
78 |
79 | -----
80 | List Exfiltrated Data
81 | -----
82 |
83 | Displays all log files containing RFID tag captures.
84 |
85 | -----
86 | Format File System
87 | -----
88 |
89 | This will erase the contents of the SPIFFS file system including ALL RFID tag captures.
90 | Formatting may take up to 90 seconds.
91 | All current settings will be retained unless you reboot your device during this process.
92 |
93 | -----
94 | Upgrade ESP-RFID-Tool Firmware
95 | -----
96 |
97 | Authenticate using your username and password set in the configuration page.
98 |
99 | Default credentials to access the firmware upgrade page:
100 | Username: "admin"
101 | Password: "rfidtool"
102 |
103 | Select "Browse" choose the new firmware to be uploaded and then click "Upgrade".
104 |
105 | You will need to manually reset the device upon the browser alerting you that the upgrade was successful.
106 |
107 | -----
108 | Licensing Information
109 | -----
110 |
111 | Created by Corey Harding
112 | https://github.com/rfidtool/ESP-RFID-Tool
113 | ESP-RFID-Tool software is licensed under the MIT License
114 | /*
115 | MIT License
116 |
117 | Copyright (c) [2018] [Corey Harding]
118 |
119 | Permission is hereby granted, free of charge, to any person obtaining a copy
120 | of this software and associated documentation files (the "Software"), to deal
121 | in the Software without restriction, including without limitation the rights
122 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
123 | copies of the Software, and to permit persons to whom the Software is
124 | furnished to do so, subject to the following conditions:
125 |
126 | The above copyright notice and this permission notice shall be included in all
127 | copies or substantial portions of the Software.
128 |
129 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
130 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
131 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
132 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
133 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
134 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
135 | SOFTWARE.
136 | */

137 | Click here for additional licensing information 138 | 139 | 140 | )====="; 141 | -------------------------------------------------------------------------------- /Source Code/esprfidtool/LICENSE: -------------------------------------------------------------------------------- 1 | SOFTWARE LICENSE 2 | 3 | MIT License 4 | 5 | Copyright (c) [2018] [Corey Harding] 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | -------------------------------------------------------------------------------- /Source Code/esprfidtool/License.h: -------------------------------------------------------------------------------- 1 | const char License[] PROGMEM = R"=====( 2 | 3 | 4 | ESP-RFID-Tool Licensing Page 5 | 6 | <- BACK TO INDEX

7 |
  8 | ESP-RFID-Tool by Corey Harding: https://www.LegacySecurityGroup.com
  9 | Code available at: https://github.com/rfidtool/ESP-RFID-Tool
 10 | 
 11 | ESP-RFID-Tool Hardware was created by Corey Harding
 12 | ESP-RFID-Tool Software is licensed under the MIT License
 13 | /*
 14 |  MIT License
 15 | 
 16 |  Copyright (c) [2018] [Corey Harding]
 17 | 
 18 |  Permission is hereby granted, free of charge, to any person obtaining a copy
 19 |  of this software and associated documentation files (the "Software"), to deal
 20 |  in the Software without restriction, including without limitation the rights
 21 |  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 22 |  copies of the Software, and to permit persons to whom the Software is
 23 |  furnished to do so, subject to the following conditions:
 24 | 
 25 |  The above copyright notice and this permission notice shall be included in all
 26 |  copies or substantial portions of the Software.
 27 | 
 28 |  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 29 |  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 30 |  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 31 |  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 32 |  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 33 |  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 34 |  SOFTWARE.
 35 | */
 36 | 
 37 | Core libraries used:
 38 | 
 39 | /*
 40 |  Arduino.h - Main include file for the Arduino SDK
 41 |  Copyright (c) 2005-2013 Arduino Team. All right reserved.
 42 |  This library is free software; you can redistribute it and/or
 43 |  modify it under the terms of the GNU Lesser General Public
 44 |  License as published by the Free Software Foundation; either
 45 |  version 2.1 of the License, or (at your option) any later version.
 46 |  This library is distributed in the hope that it will be useful,
 47 |  but WITHOUT ANY WARRANTY; without even the implied warranty of
 48 |  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 49 |  Lesser General Public License for more details.
 50 |  You should have received a copy of the GNU Lesser General Public
 51 |  License along with this library; if not, write to the Free Software
 52 |  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 53 | */
 54 | 
 55 | /*
 56 |  ESP8266WiFi.h - esp8266 Wifi support.
 57 |  Based on WiFi.h from Arduino WiFi shield library.
 58 |  Copyright (c) 2011-2014 Arduino. All right reserved.
 59 |  Modified by Ivan Grokhotkov, December 2014
 60 |  This library is free software; you can redistribute it and/or
 61 |  modify it under the terms of the GNU Lesser General Public
 62 |  License as published by the Free Software Foundation; either
 63 |  version 2.1 of the License, or (at your option) any later version.
 64 |  This library is distributed in the hope that it will be useful,
 65 |  but WITHOUT ANY WARRANTY; without even the implied warranty of
 66 |  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 67 |  Lesser General Public License for more details.
 68 |  You should have received a copy of the GNU Lesser General Public
 69 |  License along with this library; if not, write to the Free Software
 70 |  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 71 | */
 72 | 
 73 | /*
 74 |  WiFiClient.h - Library for Arduino Wifi shield.
 75 |  Copyright (c) 2011-2014 Arduino. All right reserved.
 76 |  This library is free software; you can redistribute it and/or
 77 |  modify it under the terms of the GNU Lesser General Public
 78 |  License as published by the Free Software Foundation; either
 79 |  version 2.1 of the License, or (at your option) any later version.
 80 |  This library is distributed in the hope that it will be useful,
 81 |  but WITHOUT ANY WARRANTY; without even the implied warranty of
 82 |  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 83 |  Lesser General Public License for more details.
 84 |  You should have received a copy of the GNU Lesser General Public
 85 |  License along with this library; if not, write to the Free Software
 86 |  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 87 |  Modified by Ivan Grokhotkov, December 2014 - esp8266 support
 88 | */
 89 | 
 90 | /*
 91 |  ESP8266WebServer.h - Dead simple web-server.
 92 |  Supports only one simultaneous client, knows how to handle GET and POST.
 93 |  Copyright (c) 2014 Ivan Grokhotkov. All rights reserved.
 94 |  This library is free software; you can redistribute it and/or
 95 |  modify it under the terms of the GNU Lesser General Public
 96 |  License as published by the Free Software Foundation; either
 97 |  version 2.1 of the License, or (at your option) any later version.
 98 |  This library is distributed in the hope that it will be useful,
 99 |  but WITHOUT ANY WARRANTY; without even the implied warranty of
100 |  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
101 |  Lesser General Public License for more details.
102 |  You should have received a copy of the GNU Lesser General Public
103 |  License along with this library; if not, write to the Free Software
104 |  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
105 |  Modified 8 May 2015 by Hristo Gochkov (proper post and file upload handling)
106 | */
107 | 
108 | /*
109 |  Esp8266httpupdateserver.h No license information available.
110 | */
111 | 
112 | /*
113 |  ESP8266mDNS.h
114 |  ESP8266 Multicast DNS (port of CC3000 Multicast DNS library)
115 |  Version 1.1
116 |  Copyright (c) 2013 Tony DiCola (tony@tonydicola.com)
117 |  ESP8266 port (c) 2015 Ivan Grokhotkov (ivan@esp8266.com)
118 |  Extended MDNS-SD support 2016 Lars Englund (lars.englund@gmail.com)
119 |  This is a simple implementation of multicast DNS query support for an Arduino
120 |  running on ESP8266 chip. Only support for resolving address queries is currently
121 |  implemented.
122 |  License (MIT license):
123 |  Permission is hereby granted, free of charge, to any person obtaining a copy
124 |  of this software and associated documentation files (the "Software"), to deal
125 |  in the Software without restriction, including without limitation the rights
126 |  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
127 |  copies of the Software, and to permit persons to whom the Software is
128 |  furnished to do so, subject to the following conditions:
129 |  The above copyright notice and this permission notice shall be included in
130 |  all copies or substantial portions of the Software.
131 |  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
132 |  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
133 |  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
134 |  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
135 |  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
136 |  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
137 |  THE SOFTWARE.
138 | */
139 | 
140 | /*
141 |  FS.h - file system wrapper
142 |  Copyright (c) 2015 Ivan Grokhotkov. All rights reserved.
143 |  This file is part of the esp8266 core for Arduino environment.
144 |  This library is free software; you can redistribute it and/or
145 |  modify it under the terms of the GNU Lesser General Public
146 |  License as published by the Free Software Foundation; either
147 |  version 2.1 of the License, or (at your option) any later version.
148 |  This library is distributed in the hope that it will be useful,
149 |  but WITHOUT ANY WARRANTY; without even the implied warranty of
150 |  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
151 |  Lesser General Public License for more details.
152 |  You should have received a copy of the GNU Lesser General Public
153 |  License along with this library; if not, write to the Free Software
154 |  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
155 | */
156 | 
157 | /*
158 |  ArduinoJson.h
159 |  The MIT License (MIT)
160 |  ---------------------
161 | 
162 |  Copyright (c) 2014-2017 Benoit BLANCHON
163 | 
164 |  Permission is hereby granted, free of charge, to any person obtaining a copy
165 |  of this software and associated documentation files (the "Software"), to deal
166 |  in the Software without restriction, including without limitation the rights
167 |  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
168 |  copies of the Software, and to permit persons to whom the Software is
169 |  furnished to do so, subject to the following conditions:
170 | 
171 |  The above copyright notice and this permission notice shall be included in all
172 |  copies or substantial portions of the Software.
173 | 
174 |  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
175 |  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
176 |  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
177 |  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
178 |  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
179 |  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
180 |  SOFTWARE.
181 | */
182 | 
183 | /*
184 |  ESP8266FtpServer.h - by nailbuster, later modified by bbx10 and apullin
185 |                    GNU LESSER GENERAL PUBLIC LICENSE
186 |                        Version 2.1, February 1999
187 |  https://github.com/apullin/esp8266FTPServer/blob/feature/bbx10_speedup/LICENSE
188 | */
189 | 
190 | /*
191 |   WiegandNG.h by JP Liew
192 |   https://github.com/jpliew/Wiegand-NG-Multi-Bit-Wiegand-Library-for-Arduino
193 |   GNU LGPL License 2.1
194 |   
195 |   This library is free software; you can redistribute it and/or modify it under
196 |   the terms of the GNU Lesser General Public License as published by the
197 |   Free Software Foundation; either version 2.1 of the License, or (at your option)
198 |   any later version.
199 | 
200 |   This library is distributed in the hope that it will be useful, but
201 |   WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
202 |   FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
203 |   more details.
204 | */
205 | 
206 | /*
207 |   Wiegand Preamble Calculator Code from the Tastic RFID Thief byFran Brown of Bishop Fox
208 |   https://www.bishopfox.com/resources/tools/rfid-hacking/attack-tools/
209 | */
210 | 
211 | /*
212 |   Original source for aba-decode.py by Andrew MacPherson(andrewmohawk)
213 |   https://andrewmohawk.com/2012/05/29/magnetic-stripes-part-1/
214 |   https://pastebin.com/h9eVqRxz
215 | */
216 | 
217 | /*
218 |   strrev.h by Dmitry Xmelkov
219 |   Copyright (c) 2007  Dmitry Xmelkov
220 |    All rights reserved.
221 |    Redistribution and use in source and binary forms, with or without
222 |    modification, are permitted provided that the following conditions are met:
223 |    * Redistributions of source code must retain the above copyright
224 |      notice, this list of conditions and the following disclaimer.
225 |    * Redistributions in binary form must reproduce the above copyright
226 |      notice, this list of conditions and the following disclaimer in
227 |      the documentation and/or other materials provided with the
228 |      distribution.
229 |    * Neither the name of the copyright holders nor the names of
230 |      contributors may be used to endorse or promote products derived
231 |      from this software without specific prior written permission.
232 |    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
233 |    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
234 |    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
235 |    ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
236 |    LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
237 |    CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
238 |    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
239 |    INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
240 |    CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
241 |    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
242 |    POSSIBILITY OF SUCH DAMAGE.
243 | */
244 | 
245 | This is not a comprehensive list, these "Core Libraries" may depend on additional
246 | libraries, more information can be obtained by viewing the source code of the main libraries.
247 | 
248 | 249 | 250 | )====="; 251 | -------------------------------------------------------------------------------- /Source Code/esprfidtool/WiegandNG.cpp: -------------------------------------------------------------------------------- 1 | #include "WiegandNG.h" 2 | 3 | // pcintbranch 4 | 5 | volatile unsigned long WiegandNG::_lastPulseTime; // time last bit pulse received 6 | volatile unsigned int WiegandNG::_bitCounted; // number of bits arrived at Interrupt pins 7 | volatile unsigned char *WiegandNG::_buffer; // buffer for data retention 8 | unsigned int WiegandNG::_bufferSize; // memory (bytes) allocated for buffer 9 | 10 | 11 | void shift_left(volatile unsigned char *ar, int size, int shift) 12 | { 13 | while (shift--) { // for each bit to shift ... 14 | int carry = 0; // clear the initial carry bit. 15 | int lastElement = size-1; 16 | for (int i = 0; i < size; i++) { // for each element of the array, from low byte to high byte 17 | if (i!=lastElement) { 18 | // condition ? valueIfTrue : valueIfFalse 19 | carry = (ar[i+1] & 0x80) ? 1 : 0; 20 | ar[i] = carry | (ar[i]<<1); 21 | } 22 | else { 23 | ar[i] <<=1; 24 | } 25 | } 26 | } 27 | } 28 | 29 | void WiegandNG::clear() { // reset variables to start new capture 30 | _bitCounted=0; 31 | _lastPulseTime = millis(); 32 | memset((unsigned char *)_buffer,0,_bufferSize); 33 | interrupts(); // allow interrupt 34 | } 35 | 36 | void WiegandNG::pause() { 37 | noInterrupts(); // disable interrupt so that user can process data 38 | } 39 | 40 | volatile unsigned char * WiegandNG::getRawData() { 41 | return _buffer; // return pointer of the buffer 42 | } 43 | 44 | unsigned int WiegandNG::getPacketGap() { 45 | return _packetGap; 46 | } 47 | 48 | unsigned int WiegandNG::getBitAllocated() { 49 | return _bitAllocated; 50 | } 51 | 52 | unsigned int WiegandNG::getBitCounted() { 53 | return _bitCounted; 54 | } 55 | 56 | unsigned int WiegandNG::getBufferSize() { 57 | return _bufferSize; 58 | } 59 | 60 | bool WiegandNG::available() { 61 | bool ret=false; 62 | noInterrupts(); 63 | unsigned long tempLastPulseTime = _lastPulseTime; 64 | interrupts(); 65 | 66 | unsigned long sysTick = millis(); 67 | // if ((sysTick - _lastPulseTime) > _packetGap) { // _packetGap (ms) laps 68 | if ((sysTick - tempLastPulseTime) > _packetGap) { // _packetGap (ms) laps 69 | if(_bitCounted>0) { // bits found, must have data, return true 70 | /*if(_bitCounted<8) { 71 | Serial.print(_bitCounted); 72 | Serial.print(", "); 73 | Serial.print(sysTick); 74 | Serial.print(", "); 75 | Serial.print(_lastPulseTime); 76 | Serial.print(","); 77 | Serial.println(tempLastPulseTime); 78 | }*/ 79 | ret=true; 80 | } 81 | else 82 | { 83 | _lastPulseTime = millis(); 84 | } 85 | } 86 | return ret; 87 | } 88 | 89 | void WiegandNG::ReadD0 () { 90 | _bitCounted++; // increment bit count for Interrupt connected to D0 91 | shift_left(_buffer,_bufferSize,1); // shift 0 into buffer 92 | _lastPulseTime = millis(); // keep track of time last wiegand bit received 93 | } 94 | 95 | void WiegandNG::ReadD1() { 96 | _bitCounted++; // increment bit count for Interrupt connected to D1 97 | if (_bitCounted > (_bufferSize * 8)) { 98 | _bitCounted=0; // overflowed, 99 | } else { 100 | shift_left(_buffer,_bufferSize,1); // shift 1 into buffer 101 | _buffer[_bufferSize-1] |=1; // set last bit 1 102 | _lastPulseTime = millis(); // keep track of time last wiegand bit received 103 | } 104 | } 105 | 106 | bool WiegandNG::begin(unsigned int allocateBits, unsigned int packetGap) { 107 | bool ret; 108 | // newer versions of Arduino provide pin to interrupt mapping 109 | ret=begin(2, 3, allocateBits, packetGap); 110 | return ret; 111 | } 112 | 113 | bool WiegandNG::begin(uint8_t pinD0, uint8_t pinD1, unsigned int allocateBits, unsigned int packetGap) { 114 | if (_buffer != NULL) { 115 | delete [] _buffer; 116 | } 117 | _packetGap = packetGap; 118 | _bitAllocated = allocateBits; 119 | 120 | _bufferSize=(_bitAllocated/8); // calculate the number of bytes required to store wiegand bits 121 | if((_bitAllocated % 8) >0) _bufferSize++; // add 1 extra byte to cater for bits that are not divisible by 8 122 | _buffer = new unsigned char [_bufferSize]; // allocate memory for buffer 123 | if(_buffer == NULL) return false; // not enough memory, return false 124 | 125 | clear(); 126 | 127 | pinMode(pinD0, INPUT); // set D0 pin as input 128 | pinMode(pinD1, INPUT); // set D1 pin as input 129 | attachInterrupt(digitalPinToInterrupt(pinD0), ReadD0, FALLING); // hardware interrupt - high to low pulse 130 | attachInterrupt(digitalPinToInterrupt(pinD1), ReadD1, FALLING); // hardware interrupt - high to low pulse 131 | return true; 132 | } 133 | 134 | WiegandNG::WiegandNG() { 135 | 136 | } 137 | 138 | WiegandNG::~WiegandNG() { 139 | if (_buffer != NULL) { 140 | delete [] _buffer; 141 | } 142 | } 143 | -------------------------------------------------------------------------------- /Source Code/esprfidtool/WiegandNG.h: -------------------------------------------------------------------------------- 1 | #ifndef _WIEGAND_NG_H 2 | #define _WIEGAND_NG_H 3 | 4 | #if defined(ARDUINO) && ARDUINO >= 100 5 | #include "Arduino.h" 6 | #else 7 | #include "WProgram.h" 8 | #endif 9 | 10 | class WiegandNG { 11 | 12 | private: 13 | static void ReadD0(); 14 | static void ReadD1(); 15 | static volatile unsigned long _lastPulseTime; // time last bits received 16 | static volatile unsigned int _bitCounted; // number of bits arrived at Interrupt pins 17 | static unsigned int _bufferSize; // memory (bytes) allocated for buffer 18 | unsigned int _bitAllocated; // wiegand bits required 19 | unsigned int _packetGap; // gap between wiegand packet in millisecond 20 | static volatile unsigned char * _buffer; // buffer for data retention 21 | 22 | public: 23 | bool begin(unsigned int bits, unsigned int packetGap=25); // default packetGap is 25ms 24 | bool begin(uint8_t pinD0, uint8_t pinD1, unsigned int bits, unsigned int packetGap); 25 | bool available(); 26 | void clear(); 27 | void pause(); 28 | unsigned int getBitCounted(); 29 | unsigned int getBitAllocated(); 30 | unsigned int getBufferSize(); 31 | unsigned int getPacketGap(); 32 | volatile unsigned char *getRawData(); 33 | WiegandNG(); 34 | ~WiegandNG(); 35 | }; 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /Source Code/esprfidtool/aba2str.h: -------------------------------------------------------------------------------- 1 | String aba2str (String magstripe, int magStart, int magEnd, String swipeDirection) { 2 | //f.println(String()+"Start pos:"+magStart); 3 | //f.println(String()+"Start pos:"+magEnd); 4 | String ABA=""; 5 | String aba2str=""; 6 | int magCount=abs(magEnd-magStart); 7 | //f.println(String()+"magCount:"+magCount); 8 | aba2str=(String()+"\"Cleaned\" Binary:"+magstripe.substring(magStart,magEnd)+"\n"); 9 | aba2str+=(String()+" * Possible "+swipeDirection+" Card Data\(ASCII\):"); 10 | while (magCount>0) { 11 | ABA=magstripe.substring(magStart,magStart+4); 12 | if (ABA=="1101") {aba2str+=(";");} 13 | else if (ABA=="0000") {aba2str+=("0");} 14 | else if (ABA=="1000") {aba2str+=("1");} 15 | else if (ABA=="0100") {aba2str+=("2");} 16 | else if (ABA=="1100") {aba2str+=("3");} 17 | else if (ABA=="0010") {aba2str+=("4");} 18 | else if (ABA=="1010") {aba2str+=("5");} 19 | else if (ABA=="0110") {aba2str+=("6");} 20 | else if (ABA=="1110") {aba2str+=("7");} 21 | else if (ABA=="0001") {aba2str+=("8");} 22 | else if (ABA=="1001") {aba2str+=("9");} 23 | else if (ABA=="0011") {aba2str+=("<");} 24 | else if (ABA=="0111") {aba2str+=(">");} 25 | else if (ABA=="0101") {aba2str+=(":");} 26 | else if (ABA=="1011") {aba2str+=("=");} 27 | else if (ABA=="1111") {aba2str+=("?");} 28 | else {aba2str+=("_UNKNOWN-CHARACTER_");} 29 | magStart=magStart+5; 30 | magCount=magCount-5; 31 | } 32 | return aba2str; 33 | } 34 | -------------------------------------------------------------------------------- /Source Code/esprfidtool/api.h: -------------------------------------------------------------------------------- 1 | void apiTX(String apiBIN, int apipulsewidth, int apidatainterval, int wait) { 2 | wg.pause(); 3 | digitalWrite(DATA0, HIGH); 4 | pinMode(DATA0,OUTPUT); 5 | digitalWrite(DATA1, HIGH); 6 | pinMode(DATA1,OUTPUT); 7 | for (int i=0; i<=apiBIN.length(); i++) { 8 | if (apiBIN.charAt(i) == '0') { 9 | digitalWrite(DATA0, LOW); 10 | delayMicroseconds(apipulsewidth); 11 | digitalWrite(DATA0, HIGH); 12 | } 13 | else if (apiBIN.charAt(i) == '1') { 14 | digitalWrite(DATA1, LOW); 15 | delayMicroseconds(apipulsewidth); 16 | digitalWrite(DATA1, HIGH); 17 | } 18 | if (apiBIN.charAt(i) == ',') { 19 | delayMicroseconds(wait); 20 | } 21 | else { 22 | delayMicroseconds(apidatainterval); 23 | } 24 | } 25 | apiBIN=""; 26 | pinMode(DATA0, INPUT); 27 | pinMode(DATA1, INPUT); 28 | wg.clear(); 29 | } 30 | 31 | void apiinfo(int prettify) { 32 | 33 | FSInfo fs_info; 34 | SPIFFS.info(fs_info); 35 | String total; 36 | total=fs_info.totalBytes; 37 | String used; 38 | used=fs_info.usedBytes; 39 | String freespace; 40 | freespace=fs_info.totalBytes-fs_info.usedBytes; 41 | 42 | const size_t bufferSize = JSON_ARRAY_SIZE(5) + JSON_OBJECT_SIZE(3); 43 | DynamicJsonBuffer jsonAPIbuffer(bufferSize); 44 | JsonObject& apilog = jsonAPIbuffer.createObject(); 45 | 46 | apilog["Device"] = "ESP-RFID-Tool"; 47 | apilog["Firmware"] = version; 48 | apilog["API"] = APIversion; 49 | JsonObject& apifs = apilog.createNestedObject("File System"); 50 | apifs["Total Space"]=total; 51 | apifs["Used Space"]=used; 52 | apifs["Free Space"]=freespace; 53 | apilog["Free Memory"] = String(ESP.getFreeHeap(),DEC); 54 | 55 | String API_Response=""; 56 | if (prettify==1) { 57 | apilog.prettyPrintTo(API_Response); 58 | } 59 | else { 60 | apilog.printTo(API_Response); 61 | } 62 | server.send(200, "application/json", API_Response); 63 | delay(50); 64 | jsonAPIbuffer.clear(); 65 | } 66 | 67 | void apilistlogs(int prettify) { 68 | Dir dir = SPIFFS.openDir("/"); 69 | String FileList = ""; 70 | int logcount=0; 71 | 72 | while (dir.next()) { 73 | File f = dir.openFile("r"); 74 | String FileName = dir.fileName(); 75 | if((!FileName.startsWith("/payloads/"))&&(!FileName.startsWith("/esploit.json"))&&(!FileName.startsWith("/esportal.json"))&&(!FileName.startsWith("/esprfidtool.json"))&&(!FileName.startsWith("/config.json"))) { 76 | logcount++; 77 | } 78 | f.close(); 79 | } 80 | 81 | const size_t bufferSize = JSON_ARRAY_SIZE(5) + JSON_OBJECT_SIZE(1); 82 | DynamicJsonBuffer jsonAPIbuffer(bufferSize); 83 | JsonObject& apilog = jsonAPIbuffer.createObject(); 84 | 85 | apilog["Device"] = "ESP-RFID-Tool"; 86 | apilog["Firmware"] = version; 87 | apilog["API"] = APIversion; 88 | apilog["Log Count"] = logcount; 89 | 90 | int currentlog=0; 91 | Dir dir2ndrun = SPIFFS.openDir("/"); 92 | while (dir2ndrun.next()) { 93 | File f = dir2ndrun.openFile("r"); 94 | String FileName = dir2ndrun.fileName(); 95 | if ((!FileName.startsWith("/payloads/"))&&(!FileName.startsWith("/esploit.json"))&&(!FileName.startsWith("/esportal.json"))&&(!FileName.startsWith("/esprfidtool.json"))&&(!FileName.startsWith("/config.json"))) { 96 | currentlog++; 97 | FileName.remove(0,1); 98 | JsonObject& apilistlogs = apilog.createNestedObject(String(currentlog)); 99 | apilistlogs["File Name"]=FileName; 100 | } 101 | f.close(); 102 | } 103 | 104 | String API_Response=""; 105 | if (prettify==1) { 106 | apilog.prettyPrintTo(API_Response); 107 | } 108 | else { 109 | apilog.printTo(API_Response); 110 | } 111 | server.send(200, "application/json", API_Response); 112 | delay(50); 113 | jsonAPIbuffer.clear(); 114 | } 115 | 116 | void apilog(String logfile,int prettify) { 117 | File f = SPIFFS.open(String()+"/"+logfile, "r"); 118 | if (!f) { 119 | server.send(200, "application/json", "Log file not found"); 120 | delay(50); 121 | } 122 | else { 123 | int apiCAPTUREcount=0; 124 | while(f.available()) { 125 | String line = f.readStringUntil('\n'); 126 | if(line.indexOf(",Binary:") > 0) { 127 | apiCAPTUREcount++; 128 | int firstIndex = line.indexOf(",Binary:"); 129 | int secondIndex = line.indexOf(",", firstIndex + 1); 130 | String binaryCaptureLINE=line.substring(firstIndex+8, secondIndex); 131 | } 132 | } 133 | f.close(); 134 | const size_t bufferSize = JSON_ARRAY_SIZE(6) + JSON_OBJECT_SIZE(4); 135 | DynamicJsonBuffer jsonAPIbuffer(bufferSize); 136 | JsonObject& apilog = jsonAPIbuffer.createObject(); 137 | 138 | apilog["Device"] = "ESP-RFID-Tool"; 139 | apilog["Firmware"] = version; 140 | apilog["API"] = APIversion; 141 | apilog["Log File"] = logfile; 142 | apilog["Captures"] = apiCAPTUREcount; 143 | 144 | int apiCURRENTcapture=0; 145 | File f = SPIFFS.open(String()+"/"+logfile, "r"); 146 | while(f.available()) { 147 | String line = f.readStringUntil('\n'); 148 | 149 | if(line.indexOf(",Binary:") > 0) { 150 | apiCURRENTcapture++; 151 | int firstIndex = line.indexOf(",Binary:"); 152 | int secondIndex = line.indexOf(",", firstIndex + 1); 153 | String binaryCaptureLINE=line.substring(firstIndex+8, secondIndex); 154 | if ( binaryCaptureLINE.indexOf(" ") > 0 ) { 155 | binaryCaptureLINE=binaryCaptureLINE.substring(binaryCaptureLINE.indexOf(" ")+1); 156 | } 157 | binaryCaptureLINE.replace("\r",""); 158 | JsonObject& apiCURRENTcaptureOBJECT = apilog.createNestedObject(String(apiCURRENTcapture)); 159 | apiCURRENTcaptureOBJECT["Bit Count"]=binaryCaptureLINE.length(); 160 | apiCURRENTcaptureOBJECT["Binary"]=binaryCaptureLINE; 161 | if(line.indexOf(",HEX:") > 0) { 162 | int hfirstIndex = line.indexOf(",HEX:"); 163 | int hsecondIndex = line.indexOf(",", hfirstIndex + 1); 164 | String hexCURRENT=line.substring(hfirstIndex+5, hsecondIndex); 165 | hexCURRENT.replace("\r",""); 166 | apiCURRENTcaptureOBJECT["Hexadecimal"]=hexCURRENT; 167 | } 168 | if(line.indexOf(",Keypad Code:") > 0) { 169 | int kfirstIndex = line.indexOf(",Keypad Code:"); 170 | int ksecondIndex = line.indexOf(",", kfirstIndex + 1); 171 | String pinCURRENT=line.substring(kfirstIndex+13, ksecondIndex); 172 | pinCURRENT.replace("\r",""); 173 | apiCURRENTcaptureOBJECT["Keypad Press"]=pinCURRENT; 174 | } 175 | } 176 | } 177 | f.close(); 178 | String API_Response=""; 179 | if (prettify==1) { 180 | apilog.prettyPrintTo(API_Response); 181 | } 182 | else { 183 | apilog.printTo(API_Response); 184 | } 185 | server.send(200, "application/json", API_Response); 186 | delay(50); 187 | jsonAPIbuffer.clear(); 188 | } 189 | } 190 | -------------------------------------------------------------------------------- /Source Code/esprfidtool/api_server.h: -------------------------------------------------------------------------------- 1 | server.on("/api/tx/bin", [](){ 2 | String api_binary=""; 3 | int api_pulsewidth=txdelayus; 4 | int api_datainterval=(txdelayms*1000); 5 | int prettify=0; 6 | int api_wait=100000; 7 | if (server.hasArg("binary")) { 8 | api_binary=(server.arg("binary")); 9 | } 10 | if (server.hasArg("pulsewidth")) { 11 | api_pulsewidth=(server.arg("pulsewidth").toInt()); 12 | } 13 | if (server.hasArg("interval")) { 14 | api_datainterval=(server.arg("interval").toInt()); 15 | } 16 | if (server.hasArg("wait")) { 17 | api_wait=(server.arg("wait").toInt()); 18 | } 19 | if (server.hasArg("prettify")) { 20 | prettify=1; 21 | } 22 | 23 | const size_t bufferSize = JSON_ARRAY_SIZE(4) + JSON_OBJECT_SIZE(5); 24 | DynamicJsonBuffer jsonAPIbuffer(bufferSize); 25 | JsonObject& apitxbin = jsonAPIbuffer.createObject(); 26 | 27 | apitxbin["Device"] = "ESP-RFID-Tool"; 28 | apitxbin["Firmware"] = version; 29 | apitxbin["API"] = APIversion; 30 | 31 | JsonObject& apitxbinary = apitxbin.createNestedObject("Transmission"); 32 | int commacount=0; 33 | for (int commalook=0; commalook<=api_binary.length(); commalook++) { 34 | if (api_binary.charAt(commalook)==',') { 35 | commacount++; 36 | } 37 | } 38 | apitxbinary["Bit Count"]=api_binary.length()-commacount; 39 | apitxbinary["Binary"]=api_binary; 40 | apitxbinary["Wiegand Data Pulse Width"]=String()+api_pulsewidth+"us"; 41 | apitxbinary["Wiegand Data Interval"]=String()+api_datainterval+"us"; 42 | apitxbinary["Delay Between Packets"]=String()+api_wait+"us"; 43 | 44 | if (api_binary=="") { 45 | server.send(200, "text/html", F( 46 | "Binary to tx not specified.
" 47 | "Usage: [server]/api/tx/bin?binary=[binary]&pulsewidth=[delay_us]&interval=[delay_us]&wait=[delay_us_between_packets]
" 48 | "Use commas to separate the binary for transmitting multiple packets(useful for sending multiple keypresses for imitating keypads)
" 49 | "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
" 50 | )); 51 | } 52 | else { 53 | String API_Response=""; 54 | if (prettify==1) { 55 | apitxbin.prettyPrintTo(API_Response); 56 | } 57 | else { 58 | apitxbin.printTo(API_Response); 59 | } 60 | server.send(200, "application/json", API_Response); 61 | delay(50); 62 | jsonAPIbuffer.clear(); 63 | apiTX(api_binary,api_pulsewidth,api_datainterval,api_wait); 64 | } 65 | }); 66 | 67 | server.on("/api/help", [](){ 68 | String apihelpHTML=String()+F( 69 | "<- BACK TO INDEX

" 70 | "API Version: " 71 | )+APIversion+F( 72 | "

" 73 | "/api/info
" 74 | "Usage: [server]/api/info
" 75 | "
" 76 | "/api/viewlog
" 79 | "Usage: [server]/api/viewlog?logfile=[log.txt]
" 80 | "
" 81 | "/api/listlogs
" 82 | "Usage: [server]/api/listlogs
" 83 | "
" 84 | "/api/tx/bin
" 85 | "Usage: [server]/api/tx/bin?binary=[binary]&pulsewidth=[delay_us]&interval=[delay_us]&wait=[delay_us_between_packets]
" 86 | "Use commas to separate the binary for transmitting multiple packets(useful for sending multiple keypresses for imitating keypads)
" 87 | "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
" 88 | "
" 89 | "Universal Arguments
" 90 | "Prettify: [api-url]?[args]&prettify=1
" 91 | ); 92 | server.send(200, "text/html", apihelpHTML); 93 | }); 94 | 95 | server.on("/api/info", [](){ 96 | int prettify=0; 97 | if (server.hasArg("prettify")) { 98 | prettify=1; 99 | } 100 | apiinfo(prettify); 101 | }); 102 | 103 | server.on("/api/listlogs", [](){ 104 | int prettify=0; 105 | if (server.hasArg("prettify")) { 106 | prettify=1; 107 | } 108 | apilistlogs(prettify); 109 | }); 110 | 111 | server.on("/api/viewlog", [](){ 112 | int prettify=0; 113 | if (server.hasArg("prettify")) { 114 | prettify=1; 115 | } 116 | if (server.hasArg("logfile")) { 117 | apilog(server.arg("logfile"),prettify); 118 | } 119 | else { 120 | server.send(200, "application/json", F("Usage: [server]/api/viewlog?logfile=[logfile.txt]")); 121 | } 122 | }); 123 | -------------------------------------------------------------------------------- /Source Code/esprfidtool/esprfidtool.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * ESP-RFID-Tool 3 | * by Corey Harding of www.Exploit.Agency / www.LegacySecurityGroup.com 4 | * 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. 5 | * MIT License 6 | 7 | Copyright (c) [2018] [Corey Harding] 8 | 9 | Permission is hereby granted, free of charge, to any person obtaining a copy 10 | of this software and associated documentation files (the "Software"), to deal 11 | in the Software without restriction, including without limitation the rights 12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | copies of the Software, and to permit persons to whom the Software is 14 | furnished to do so, subject to the following conditions: 15 | 16 | The above copyright notice and this permission notice shall be included in all 17 | copies or substantial portions of the Software. 18 | 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | SOFTWARE. 25 | */ 26 | #include "HelpText.h" 27 | #include "License.h" 28 | #include "version.h" 29 | #include "strrev.h" 30 | #include "aba2str.h" 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include // ArduinoJson library 5.11.0 by Benoit Blanchon https://github.com/bblanchon/ArduinoJson 40 | #include // https://github.com/exploitagency/esp8266FTPServer/tree/feature/bbx10_speedup 41 | #include 42 | #include 43 | 44 | #define DATA0 14 45 | #define DATA1 12 46 | 47 | #define LED_BUILTIN 2 48 | #define RESTORE_DEFAULTS_PIN 4 //GPIO 4 49 | int jumperState = 0; //For restoring default settings 50 | #include "WiegandNG.h" //https://github.com/jpliew/Wiegand-NG-Multi-Bit-Wiegand-Library-for-Arduino 51 | 52 | // Port for web server 53 | ESP8266WebServer server(80); 54 | ESP8266WebServer httpServer(1337); 55 | ESP8266HTTPUpdateServer httpUpdater; 56 | FtpServer ftpSrv; 57 | const byte DNS_PORT = 53; 58 | DNSServer dnsServer; 59 | 60 | HTTPClient http; 61 | 62 | const char* update_path = "/update"; 63 | int accesspointmode; 64 | char ssid[32]; 65 | char password[64]; 66 | int channel; 67 | int hidden; 68 | char local_IPstr[16]; 69 | char gatewaystr[16]; 70 | char subnetstr[16]; 71 | char update_username[32]; 72 | char update_password[64]; 73 | char ftp_username[32]; 74 | char ftp_password[64]; 75 | int ftpenabled; 76 | int ledenabled; 77 | char logname[31]; 78 | unsigned int bufferlength; 79 | unsigned int rxpacketgap; 80 | int txdelayus; 81 | int txdelayms; 82 | int safemode; 83 | 84 | int dos=0; 85 | int TXstatus=0; 86 | String pinHTML; 87 | 88 | #include "pinSEND.h" 89 | 90 | String dataCONVERSION=""; 91 | 92 | WiegandNG wg; 93 | 94 | void LogWiegand(WiegandNG &tempwg) { 95 | volatile unsigned char *buffer=tempwg.getRawData(); 96 | unsigned int bufferSize = tempwg.getBufferSize(); 97 | unsigned int countedBits = tempwg.getBitCounted(); 98 | 99 | unsigned int countedBytes = (countedBits/8); 100 | if ((countedBits % 8)>0) countedBytes++; 101 | //unsigned int bitsUsed = countedBytes * 8; 102 | 103 | bool binChunk2exists=false; 104 | volatile unsigned long cardChunk1 = 0; 105 | volatile unsigned long cardChunk2 = 0; 106 | volatile unsigned long binChunk2 = 0; 107 | volatile unsigned long binChunk1 = 0; 108 | String binChunk3=""; 109 | bool unknown=false; 110 | binChunk2exists=false; 111 | int binChunk2len=0; 112 | int j=0; 113 | 114 | for (unsigned int i=bufferSize-countedBytes; i< bufferSize;i++) { 115 | unsigned char bufByte=buffer[i]; 116 | for(int x=0; x<8;x++) { 117 | if ( (((bufferSize-i) *8)-x) <= countedBits) { 118 | j++; 119 | if((bufByte & 0x80)) { //write 1 120 | if(j<23) { 121 | binChunk1 = binChunk1 << 1; 122 | binChunk1 |= 1; 123 | } 124 | else if(j<=52) { 125 | binChunk2exists=true; 126 | binChunk2len++; 127 | binChunk2 = binChunk2 << 1; 128 | binChunk2 |= 1; 129 | } 130 | else if(j>52){ 131 | binChunk3=binChunk3+"1"; 132 | } 133 | } 134 | else { //write 0 135 | if(j<23) { 136 | binChunk1 = binChunk1 << 1; 137 | } 138 | else if(j<=52){ 139 | binChunk2exists=true; 140 | binChunk2len++; 141 | binChunk2 = binChunk2 << 1; 142 | } 143 | else if(j>52){ 144 | binChunk3=binChunk3+"0"; 145 | } 146 | } 147 | } 148 | bufByte<<=1; 149 | } 150 | } 151 | j=0; 152 | 153 | switch (countedBits) { //Add the preamble to known cards 154 | case 26: 155 | for(int i = 19; i >= 0; i--) { 156 | if(i == 13 || i == 2){ 157 | bitWrite(cardChunk1, i, 1); // Write preamble 1's to the 13th and 2nd bits 158 | } 159 | else if(i > 2) { 160 | bitWrite(cardChunk1, i, 0); // Write preamble 0's to all other bits above 1 161 | } 162 | else { 163 | bitWrite(cardChunk1, i, bitRead(binChunk1, i + 20)); // Write remaining bits to cardChunk1 from binChunk1 164 | } 165 | if(i < 20) { 166 | bitWrite(cardChunk2, i + 4, bitRead(binChunk1, i)); // Write the remaining bits of binChunk1 to cardChunk2 167 | } 168 | if(i < 4) { 169 | bitWrite(cardChunk2, i, bitRead(binChunk2, i)); // Write the remaining bit of cardChunk2 with binChunk2 bits 170 | } 171 | } 172 | break; 173 | case 27: 174 | for(int i = 19; i >= 0; i--) { 175 | if(i == 13 || i == 3){ 176 | bitWrite(cardChunk1, i, 1); 177 | } 178 | else if(i > 3) { 179 | bitWrite(cardChunk1, i, 0); 180 | } 181 | else { 182 | bitWrite(cardChunk1, i, bitRead(binChunk1, i + 19)); 183 | } 184 | if(i < 19) { 185 | bitWrite(cardChunk2, i + 5, bitRead(binChunk1, i)); 186 | } 187 | if(i < 5) { 188 | bitWrite(cardChunk2, i, bitRead(binChunk2, i)); 189 | } 190 | } 191 | break; 192 | case 28: 193 | for(int i = 19; i >= 0; i--) { 194 | if(i == 13 || i == 4){ 195 | bitWrite(cardChunk1, i, 1); 196 | } 197 | else if(i > 4) { 198 | bitWrite(cardChunk1, i, 0); 199 | } 200 | else { 201 | bitWrite(cardChunk1, i, bitRead(binChunk1, i + 18)); 202 | } 203 | if(i < 18) { 204 | bitWrite(cardChunk2, i + 6, bitRead(binChunk1, i)); 205 | } 206 | if(i < 6) { 207 | bitWrite(cardChunk2, i, bitRead(binChunk2, i)); 208 | } 209 | } 210 | break; 211 | case 29: 212 | for(int i = 19; i >= 0; i--) { 213 | if(i == 13 || i == 5){ 214 | bitWrite(cardChunk1, i, 1); 215 | } 216 | else if(i > 5) { 217 | bitWrite(cardChunk1, i, 0); 218 | } 219 | else { 220 | bitWrite(cardChunk1, i, bitRead(binChunk1, i + 17)); 221 | } 222 | if(i < 17) { 223 | bitWrite(cardChunk2, i + 7, bitRead(binChunk1, i)); 224 | } 225 | if(i < 7) { 226 | bitWrite(cardChunk2, i, bitRead(binChunk2, i)); 227 | } 228 | } 229 | break; 230 | case 30: 231 | for(int i = 19; i >= 0; i--) { 232 | if(i == 13 || i == 6){ 233 | bitWrite(cardChunk1, i, 1); 234 | } 235 | else if(i > 6) { 236 | bitWrite(cardChunk1, i, 0); 237 | } 238 | else { 239 | bitWrite(cardChunk1, i, bitRead(binChunk1, i + 16)); 240 | } 241 | if(i < 16) { 242 | bitWrite(cardChunk2, i + 8, bitRead(binChunk1, i)); 243 | } 244 | if(i < 8) { 245 | bitWrite(cardChunk2, i, bitRead(binChunk2, i)); 246 | } 247 | } 248 | break; 249 | case 31: 250 | for(int i = 19; i >= 0; i--) { 251 | if(i == 13 || i == 7){ 252 | bitWrite(cardChunk1, i, 1); 253 | } 254 | else if(i > 7) { 255 | bitWrite(cardChunk1, i, 0); 256 | } 257 | else { 258 | bitWrite(cardChunk1, i, bitRead(binChunk1, i + 15)); 259 | } 260 | if(i < 15) { 261 | bitWrite(cardChunk2, i + 9, bitRead(binChunk1, i)); 262 | } 263 | if(i < 9) { 264 | bitWrite(cardChunk2, i, bitRead(binChunk2, i)); 265 | } 266 | } 267 | break; 268 | case 32: 269 | for(int i = 19; i >= 0; i--) { 270 | if(i == 13 || i == 8){ 271 | bitWrite(cardChunk1, i, 1); 272 | } 273 | else if(i > 8) { 274 | bitWrite(cardChunk1, i, 0); 275 | } 276 | else { 277 | bitWrite(cardChunk1, i, bitRead(binChunk1, i + 14)); 278 | } 279 | if(i < 14) { 280 | bitWrite(cardChunk2, i + 10, bitRead(binChunk1, i)); 281 | } 282 | if(i < 10) { 283 | bitWrite(cardChunk2, i, bitRead(binChunk2, i)); 284 | } 285 | } 286 | break; 287 | case 33: 288 | for(int i = 19; i >= 0; i--) { 289 | if(i == 13 || i == 9){ 290 | bitWrite(cardChunk1, i, 1); 291 | } 292 | else if(i > 9) { 293 | bitWrite(cardChunk1, i, 0); 294 | } 295 | else { 296 | bitWrite(cardChunk1, i, bitRead(binChunk1, i + 13)); 297 | } 298 | if(i < 13) { 299 | bitWrite(cardChunk2, i + 11, bitRead(binChunk1, i)); 300 | } 301 | if(i < 11) { 302 | bitWrite(cardChunk2, i, bitRead(binChunk2, i)); 303 | } 304 | } 305 | break; 306 | case 34: 307 | for(int i = 19; i >= 0; i--) { 308 | if(i == 13 || i == 10){ 309 | bitWrite(cardChunk1, i, 1); 310 | } 311 | else if(i > 10) { 312 | bitWrite(cardChunk1, i, 0); 313 | } 314 | else { 315 | bitWrite(cardChunk1, i, bitRead(binChunk1, i + 12)); 316 | } 317 | if(i < 12) { 318 | bitWrite(cardChunk2, i + 12, bitRead(binChunk1, i)); 319 | } 320 | if(i < 12) { 321 | bitWrite(cardChunk2, i, bitRead(binChunk2, i)); 322 | } 323 | } 324 | break; 325 | case 35: 326 | for(int i = 19; i >= 0; i--) { 327 | if(i == 13 || i == 11){ 328 | bitWrite(cardChunk1, i, 1); 329 | } 330 | else if(i > 11) { 331 | bitWrite(cardChunk1, i, 0); 332 | } 333 | else { 334 | bitWrite(cardChunk1, i, bitRead(binChunk1, i + 11)); 335 | } 336 | if(i < 11) { 337 | bitWrite(cardChunk2, i + 13, bitRead(binChunk1, i)); 338 | } 339 | if(i < 13) { 340 | bitWrite(cardChunk2, i, bitRead(binChunk2, i)); 341 | } 342 | } 343 | break; 344 | case 36: 345 | for(int i = 19; i >= 0; i--) { 346 | if(i == 13 || i == 12){ 347 | bitWrite(cardChunk1, i, 1); 348 | } 349 | else if(i > 12) { 350 | bitWrite(cardChunk1, i, 0); 351 | } 352 | else { 353 | bitWrite(cardChunk1, i, bitRead(binChunk1, i + 10)); 354 | } 355 | if(i < 10) { 356 | bitWrite(cardChunk2, i + 14, bitRead(binChunk1, i)); 357 | } 358 | if(i < 14) { 359 | bitWrite(cardChunk2, i, bitRead(binChunk2, i)); 360 | } 361 | } 362 | break; 363 | case 37: 364 | for(int i = 19; i >= 0; i--) { 365 | if(i == 13){ 366 | bitWrite(cardChunk1, i, 0); 367 | } 368 | else { 369 | bitWrite(cardChunk1, i, bitRead(binChunk1, i + 9)); 370 | } 371 | if(i < 9) { 372 | bitWrite(cardChunk2, i + 15, bitRead(binChunk1, i)); 373 | } 374 | if(i < 15) { 375 | bitWrite(cardChunk2, i, bitRead(binChunk2, i)); 376 | } 377 | } 378 | break; 379 | default: //unknown card 380 | unknown=true; 381 | //String binChunk3 is like cardChunk0 382 | cardChunk1=binChunk2; 383 | cardChunk2=binChunk1; 384 | break; 385 | } 386 | 387 | File f = SPIFFS.open("/"+String(logname), "a"); //Open the log in append mode to store capture 388 | int preambleLen; 389 | if (unknown==true && countedBits!=4 && countedBits!=8 && countedBits!=248) { 390 | f.print(F("Unknown ")); 391 | preambleLen=0; 392 | } 393 | else { 394 | preambleLen=(44-countedBits); 395 | } 396 | 397 | f.print(String()+countedBits+F(" bit card,")); 398 | 399 | if (countedBits==4||countedBits==8) { 400 | f.print(F("Possible keypad entry,")); 401 | } 402 | 403 | if (countedBits==248) { 404 | f.print(F("possible magstripe card,")); 405 | } 406 | String magstripe=""; 407 | 408 | if (unknown!=true) { 409 | f.print(String()+preambleLen+F(" bit preamble,")); 410 | } 411 | 412 | f.print(F("Binary:")); 413 | 414 | //f.print(" "); //debug line 415 | if (binChunk2exists==true && unknown!=true) { 416 | for(int i = (((countedBits+preambleLen)-countedBits)+(countedBits-24)); i--;) { 417 | if (i==((((countedBits+preambleLen)-countedBits)+(countedBits-24))-preambleLen-1) && unknown!=true) { 418 | f.print(" "); 419 | } 420 | f.print(bitRead(cardChunk1, i)); 421 | if(i == 0){ 422 | break; 423 | } 424 | } 425 | } 426 | 427 | if ((countedBits>=24) && unknown!=true) { 428 | for(int i = 24; i--;) { 429 | f.print(bitRead(cardChunk2, i)); 430 | if(i == 0){ 431 | break; 432 | } 433 | } 434 | } 435 | else if ((countedBits>=23) && unknown==true) { 436 | int i; 437 | if (countedBits>=52) { 438 | i=22; 439 | } 440 | else { 441 | i =(countedBits-binChunk2len); 442 | } 443 | for(i; i--;) { 444 | f.print(bitRead(binChunk1, i)); 445 | if (countedBits==248) { 446 | magstripe+=bitRead(binChunk1, i); 447 | } 448 | if(i == 0){ 449 | break; 450 | } 451 | } 452 | } 453 | else { 454 | for(int i = countedBits; i--;) { 455 | f.print(bitRead(binChunk1, i)); 456 | if(i == 0){ 457 | break; 458 | } 459 | } 460 | } 461 | 462 | if (binChunk2exists==true && unknown==true) { 463 | int i; 464 | if (countedBits>=52) { 465 | i=30; 466 | } 467 | else { 468 | i=(binChunk2len); 469 | } 470 | for(i; i--;) { 471 | f.print(bitRead(binChunk2, i)); 472 | if (countedBits==248) { 473 | magstripe+=bitRead(binChunk2, i); 474 | } 475 | if(i == 0){ 476 | break; 477 | } 478 | } 479 | } 480 | 481 | if (countedBits>52) { 482 | f.print(binChunk3); 483 | if (countedBits==248) { 484 | magstripe+=binChunk3; 485 | } 486 | } 487 | 488 | if (countedBits<=52 && unknown!=true) { 489 | f.print(",HEX:"); 490 | if (binChunk2exists==true) { 491 | f.print(cardChunk1, HEX); 492 | } 493 | //f.print(" "); //debug line 494 | f.println(cardChunk2, HEX); 495 | } 496 | else if (countedBits==4||countedBits==8) { 497 | f.print(",Keypad Code:"); 498 | if (binChunk1 == 0B0000||binChunk1 == 0b11110000) { 499 | f.print("0"); 500 | } 501 | else if (binChunk1 == 0B0001||binChunk1 == 0b11100001) { 502 | f.print("1"); 503 | } 504 | else if (binChunk1 == 0B0010||binChunk1 == 0b11010010) { 505 | f.print("2"); 506 | } 507 | else if (binChunk1 == 0B0011||binChunk1 == 0b11000011) { 508 | f.print("3"); 509 | } 510 | else if (binChunk1 == 0B0100||binChunk1 == 0b10110100) { 511 | f.print("4"); 512 | } 513 | else if (binChunk1 == 0B0101||binChunk1 == 0b10100101) { 514 | f.print("5"); 515 | } 516 | else if (binChunk1 == 0B0110||binChunk1 == 0b10010110) { 517 | f.print("6"); 518 | } 519 | else if (binChunk1 == 0B0111||binChunk1 == 0b10000111) { 520 | f.print("7"); 521 | } 522 | else if (binChunk1 == 0B1000||binChunk1 == 0b01111000) { 523 | f.print("8"); 524 | } 525 | else if (binChunk1 == 0B1001||binChunk1 == 0b01101001) { 526 | f.print("9"); 527 | } 528 | else if (binChunk1 == 0B1010||binChunk1 == 0b01011010) { 529 | f.print("*"); 530 | } 531 | else if (binChunk1 == 0B1011||binChunk1 == 0b01001011) { 532 | f.print("#"); 533 | } 534 | else if (binChunk1 == 0b1100||binChunk1 == 0b00111100) { 535 | f.print("F1"); 536 | } 537 | else if (binChunk1 == 0b1101||binChunk1 == 0b00101101) { 538 | f.print("F2"); 539 | } 540 | else if (binChunk1 == 0b1110||binChunk1 == 0b00011110) { 541 | f.print("F3"); 542 | } 543 | else if (binChunk1 == 0b1111||binChunk1 == 0b00001111) { 544 | f.print("F4"); 545 | } 546 | else { 547 | f.print("?"); 548 | } 549 | f.print(",HEX:"); 550 | if (countedBits==8) { 551 | char hexCHAR[3]; 552 | sprintf(hexCHAR, "%02X", binChunk1); 553 | f.println(hexCHAR); 554 | } 555 | else if (countedBits==4) { 556 | f.println(binChunk1, HEX); 557 | } 558 | } 559 | else if (countedBits==248) { 560 | f.println(","); 561 | } 562 | else { 563 | f.println(""); 564 | } 565 | 566 | if (countedBits==248) { 567 | int startSentinel=magstripe.indexOf("11010"); 568 | int endSentinel=(magstripe.lastIndexOf("11111")+4); 569 | int magStart=0; 570 | int magEnd=1; 571 | //f.print("
");
 572 |   
 573 |     f.print(" * Trying \"Forward\" Swipe,");
 574 |     magStart=startSentinel;
 575 |     magEnd=endSentinel;
 576 |     f.println(aba2str(magstripe,magStart,magEnd,"\"Forward\" Swipe"));
 577 |     
 578 |     f.print(" * Trying \"Reverse\" Swipe,");
 579 |     char magchar[249];
 580 |     magstripe.toCharArray(magchar,249);
 581 |     magstripe=String(strrev(magchar));
 582 |     //f.println(String()+"Reverse: "+magstripe);
 583 |     magStart=magstripe.indexOf("11010");
 584 |     magEnd=(magstripe.lastIndexOf("11111")+4);
 585 |     f.println(aba2str(magstripe,magStart,magEnd,"\"Reverse\" Swipe"));
 586 |   
 587 |     //f.print("
"); 588 | //f.println(String()+F(" * You can verify the data at the following URL: https://www.legacysecuritygroup.com/aba-decode.php?binary=")+magstripe+F("")); 589 | } 590 | 591 | //Debug 592 | // f.print(F("Free heap:")); 593 | // f.println(ESP.getFreeHeap(),DEC); 594 | 595 | unknown=false; 596 | binChunk3=""; 597 | binChunk2exists=false; 598 | binChunk1 = 0; binChunk2 = 0; 599 | cardChunk1 = 0; cardChunk2 = 0; 600 | binChunk2len=0; 601 | 602 | f.close(); //done 603 | } 604 | 605 | #include "api.h" 606 | 607 | void settingsPage() 608 | { 609 | if(!server.authenticate(update_username, update_password)) 610 | return server.requestAuthentication(); 611 | String accesspointmodeyes; 612 | String accesspointmodeno; 613 | if (accesspointmode==1){ 614 | accesspointmodeyes=" checked=\"checked\""; 615 | accesspointmodeno=""; 616 | } 617 | else { 618 | accesspointmodeyes=""; 619 | accesspointmodeno=" checked=\"checked\""; 620 | } 621 | String ftpenabledyes; 622 | String ftpenabledno; 623 | if (ftpenabled==1){ 624 | ftpenabledyes=" checked=\"checked\""; 625 | ftpenabledno=""; 626 | } 627 | else { 628 | ftpenabledyes=""; 629 | ftpenabledno=" checked=\"checked\""; 630 | } 631 | String ledenabledyes; 632 | String ledenabledno; 633 | if (ledenabled==1){ 634 | ledenabledyes=" checked=\"checked\""; 635 | ledenabledno=""; 636 | } 637 | else { 638 | ledenabledyes=""; 639 | ledenabledno=" checked=\"checked\""; 640 | } 641 | String hiddenyes; 642 | String hiddenno; 643 | if (hidden==1){ 644 | hiddenyes=" checked=\"checked\""; 645 | hiddenno=""; 646 | } 647 | else { 648 | hiddenyes=""; 649 | hiddenno=" checked=\"checked\""; 650 | } 651 | String safemodeyes; 652 | String safemodeno; 653 | if (safemode==1){ 654 | safemodeyes=" checked=\"checked\""; 655 | safemodeno=""; 656 | } 657 | else { 658 | safemodeyes=""; 659 | safemodeno=" checked=\"checked\""; 660 | } 661 | server.send(200, "text/html", 662 | String()+ 663 | F( 664 | "" 665 | "" 666 | "" 667 | "" 668 | "ESP-RFID-Tool Settings" 669 | "" 672 | "" 673 | "" 674 | "<- BACK TO INDEX

" 675 | "

ESP-RFID-Tool Settings

" 676 | "" 677 | "
" 678 | "
" 679 | "

" 680 | "WiFi Configuration:

" 681 | "Network Type
" 682 | )+ 683 | F("Access Point Mode:
" 684 | "Join Existing Network:

" 685 | "Hidden
" 686 | "Yes
" 687 | "No

" 688 | "SSID:
" 689 | "Password:
" 690 | "Channel:

" 691 | "IP:
" 692 | "Gateway:
" 693 | "Subnet:

" 694 | "


" 695 | "Web Interface Administration Settings:

" 696 | "Username:
" 697 | "Password:

" 698 | "
" 699 | "FTP Server Settings
" 700 | "Changes require a reboot.
" 701 | "Enabled
" 702 | "Disabled
" 703 | "FTP Username:
" 704 | "FTP Password:

" 705 | "
" 706 | "Power LED:
" 707 | "Changes require a reboot.
" 708 | "Enabled
" 709 | "Disabled

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

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

" 727 | "Enabled
" 728 | "Disabled

" 729 | "
" 730 | "" 731 | "" 732 | "
" 733 | "
" 734 | "

" 735 | "" 736 | "" 737 | ) 738 | ); 739 | } 740 | 741 | void handleSettings() 742 | { 743 | if (server.hasArg("SETTINGS")) { 744 | handleSubmitSettings(); 745 | } 746 | else { 747 | settingsPage(); 748 | } 749 | } 750 | 751 | void returnFail(String msg) 752 | { 753 | server.sendHeader("Connection", "close"); 754 | server.sendHeader("Access-Control-Allow-Origin", "*"); 755 | server.send(500, "text/plain", msg + "\r\n"); 756 | } 757 | 758 | void handleSubmitSettings() 759 | { 760 | String SETTINGSvalue; 761 | 762 | if (!server.hasArg("SETTINGS")) return returnFail("BAD ARGS"); 763 | 764 | SETTINGSvalue = server.arg("SETTINGS"); 765 | accesspointmode = server.arg("accesspointmode").toInt(); 766 | server.arg("ssid").toCharArray(ssid, 32); 767 | server.arg("password").toCharArray(password, 64); 768 | channel = server.arg("channel").toInt(); 769 | hidden = server.arg("hidden").toInt(); 770 | server.arg("local_IPstr").toCharArray(local_IPstr, 16); 771 | server.arg("gatewaystr").toCharArray(gatewaystr, 16); 772 | server.arg("subnetstr").toCharArray(subnetstr, 16); 773 | server.arg("update_username").toCharArray(update_username, 32); 774 | server.arg("update_password").toCharArray(update_password, 64); 775 | server.arg("ftp_username").toCharArray(ftp_username, 32); 776 | server.arg("ftp_password").toCharArray(ftp_password, 64); 777 | ftpenabled = server.arg("ftpenabled").toInt(); 778 | ledenabled = server.arg("ledenabled").toInt(); 779 | server.arg("logname").toCharArray(logname, 31); 780 | bufferlength = server.arg("bufferlength").toInt(); 781 | rxpacketgap = server.arg("rxpacketgap").toInt(); 782 | txdelayus = server.arg("txdelayus").toInt(); 783 | txdelayms = server.arg("txdelayms").toInt(); 784 | safemode = server.arg("safemode").toInt(); 785 | 786 | if (SETTINGSvalue == "1") { 787 | saveConfig(); 788 | 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.")); 789 | delay(50); 790 | loadConfig(); 791 | } 792 | else if (SETTINGSvalue == "0") { 793 | settingsPage(); 794 | } 795 | else { 796 | returnFail("Bad SETTINGS value"); 797 | } 798 | } 799 | 800 | bool loadDefaults() { 801 | StaticJsonBuffer<500> jsonBuffer; 802 | JsonObject& json = jsonBuffer.createObject(); 803 | json["version"] = version; 804 | json["accesspointmode"] = "1"; 805 | json["ssid"] = "ESP-RFID-Tool"; 806 | json["password"] = ""; 807 | json["channel"] = "6"; 808 | json["hidden"] = "0"; 809 | json["local_IP"] = "192.168.1.1"; 810 | json["gateway"] = "192.168.1.1"; 811 | json["subnet"] = "255.255.255.0"; 812 | json["update_username"] = "admin"; 813 | json["update_password"] = "rfidtool"; 814 | json["ftp_username"] = "ftp-admin"; 815 | json["ftp_password"] = "rfidtool"; 816 | json["ftpenabled"] = "0"; 817 | json["ledenabled"] = "1"; 818 | json["logname"] = "log.txt"; 819 | json["bufferlength"] = "256"; 820 | json["rxpacketgap"] = "15"; 821 | json["txdelayus"] = "40"; 822 | json["txdelayms"] = "2"; 823 | json["safemode"] = "0"; 824 | File configFile = SPIFFS.open("/esprfidtool.json", "w"); 825 | json.printTo(configFile); 826 | configFile.close(); 827 | jsonBuffer.clear(); 828 | loadConfig(); 829 | } 830 | 831 | bool loadConfig() { 832 | File configFile = SPIFFS.open("/esprfidtool.json", "r"); 833 | if (!configFile) { 834 | delay(3500); 835 | loadDefaults(); 836 | } 837 | 838 | size_t size = configFile.size(); 839 | 840 | std::unique_ptr buf(new char[size]); 841 | configFile.readBytes(buf.get(), size); 842 | StaticJsonBuffer<500> jsonBuffer; 843 | JsonObject& json = jsonBuffer.parseObject(buf.get()); 844 | 845 | if (!json["version"]) { 846 | delay(3500); 847 | loadDefaults(); 848 | ESP.restart(); 849 | } 850 | 851 | //Resets config to factory defaults on an update. 852 | if (json["version"]!=version) { 853 | delay(3500); 854 | loadDefaults(); 855 | ESP.restart(); 856 | } 857 | 858 | strcpy(ssid, (const char*)json["ssid"]); 859 | strcpy(password, (const char*)json["password"]); 860 | channel = json["channel"]; 861 | hidden = json["hidden"]; 862 | accesspointmode = json["accesspointmode"]; 863 | strcpy(local_IPstr, (const char*)json["local_IP"]); 864 | strcpy(gatewaystr, (const char*)json["gateway"]); 865 | strcpy(subnetstr, (const char*)json["subnet"]); 866 | 867 | strcpy(update_username, (const char*)json["update_username"]); 868 | strcpy(update_password, (const char*)json["update_password"]); 869 | 870 | strcpy(ftp_username, (const char*)json["ftp_username"]); 871 | strcpy(ftp_password, (const char*)json["ftp_password"]); 872 | ftpenabled = json["ftpenabled"]; 873 | ledenabled = json["ledenabled"]; 874 | strcpy(logname, (const char*)json["logname"]); 875 | bufferlength = json["bufferlength"]; 876 | rxpacketgap = json["rxpacketgap"]; 877 | txdelayus = json["txdelayus"]; 878 | txdelayms = json["txdelayms"]; 879 | safemode = json["safemode"]; 880 | 881 | IPAddress local_IP; 882 | local_IP.fromString(local_IPstr); 883 | IPAddress gateway; 884 | gateway.fromString(gatewaystr); 885 | IPAddress subnet; 886 | subnet.fromString(subnetstr); 887 | 888 | /* 889 | Serial.println(accesspointmode); 890 | Serial.println(ssid); 891 | Serial.println(password); 892 | Serial.println(channel); 893 | Serial.println(hidden); 894 | Serial.println(local_IP); 895 | Serial.println(gateway); 896 | Serial.println(subnet); 897 | */ 898 | WiFi.persistent(false); 899 | //ESP.eraseConfig(); 900 | // Determine if set to Access point mode 901 | if (accesspointmode == 1) { 902 | WiFi.disconnect(true); 903 | WiFi.mode(WIFI_AP); 904 | 905 | // Serial.print("Starting Access Point ... "); 906 | // Serial.println(WiFi.softAP(ssid, password, channel, hidden) ? "Success" : "Failed!"); 907 | WiFi.softAP(ssid, password, channel, hidden); 908 | 909 | // Serial.print("Setting up Network Configuration ... "); 910 | // Serial.println(WiFi.softAPConfig(local_IP, gateway, subnet) ? "Success" : "Failed!"); 911 | WiFi.softAPConfig(local_IP, gateway, subnet); 912 | 913 | // WiFi.reconnect(); 914 | 915 | // Serial.print("IP address = "); 916 | // Serial.println(WiFi.softAPIP()); 917 | } 918 | // or Join existing network 919 | else if (accesspointmode != 1) { 920 | WiFi.disconnect(true); 921 | WiFi.mode(WIFI_STA); 922 | // Serial.print("Setting up Network Configuration ... "); 923 | WiFi.config(local_IP, gateway, subnet); 924 | // WiFi.config(local_IP, gateway, subnet); 925 | 926 | // Serial.print("Connecting to network ... "); 927 | // WiFi.begin(ssid, password); 928 | WiFi.begin(ssid, password); 929 | WiFi.reconnect(); 930 | 931 | // Serial.print("IP address = "); 932 | // Serial.println(WiFi.localIP()); 933 | } 934 | configFile.close(); 935 | jsonBuffer.clear(); 936 | return true; 937 | } 938 | 939 | bool saveConfig() { 940 | StaticJsonBuffer<500> jsonBuffer; 941 | JsonObject& json = jsonBuffer.createObject(); 942 | json["version"] = version; 943 | json["accesspointmode"] = accesspointmode; 944 | json["ssid"] = ssid; 945 | json["password"] = password; 946 | json["channel"] = channel; 947 | json["hidden"] = hidden; 948 | json["local_IP"] = local_IPstr; 949 | json["gateway"] = gatewaystr; 950 | json["subnet"] = subnetstr; 951 | json["update_username"] = update_username; 952 | json["update_password"] = update_password; 953 | json["ftp_username"] = ftp_username; 954 | json["ftp_password"] = ftp_password; 955 | json["ftpenabled"] = ftpenabled; 956 | json["ledenabled"] = ledenabled; 957 | json["logname"] = logname; 958 | json["bufferlength"] = bufferlength; 959 | json["rxpacketgap"] = rxpacketgap; 960 | json["txdelayus"] = txdelayus; 961 | json["txdelayms"] = txdelayms; 962 | json["safemode"] = safemode; 963 | 964 | File configFile = SPIFFS.open("/esprfidtool.json", "w"); 965 | json.printTo(configFile); 966 | configFile.close(); 967 | jsonBuffer.clear(); 968 | return true; 969 | } 970 | 971 | File fsUploadFile; 972 | String webString; 973 | 974 | void ListLogs(){ 975 | String directory; 976 | directory="/"; 977 | FSInfo fs_info; 978 | SPIFFS.info(fs_info); 979 | String total; 980 | total=fs_info.totalBytes; 981 | String used; 982 | used=fs_info.usedBytes; 983 | String freespace; 984 | freespace=fs_info.totalBytes-fs_info.usedBytes; 985 | Dir dir = SPIFFS.openDir(directory); 986 | 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.
"; 987 | while (dir.next()) { 988 | String FileName = dir.fileName(); 989 | File f = dir.openFile("r"); 990 | FileList += " "; 991 | if((!FileName.startsWith("/payloads/"))&&(!FileName.startsWith("/esploit.json"))&&(!FileName.startsWith("/esportal.json"))&&(!FileName.startsWith("/esprfidtool.json"))&&(!FileName.startsWith("/config.json"))) FileList += ""+""; 992 | f.close(); 993 | } 994 | FileList += "
Display File ContentsSize in BytesDownload FileDelete File
"+FileName+""+f.size()+"
"; 995 | server.send(200, "text/html", FileList); 996 | } 997 | 998 | bool RawFile(String rawfile) { 999 | if (SPIFFS.exists(rawfile)) { 1000 | if(!server.authenticate(update_username, update_password)){ 1001 | server.requestAuthentication();} 1002 | File file = SPIFFS.open(rawfile, "r"); 1003 | size_t sent = server.streamFile(file, "application/octet-stream"); 1004 | file.close(); 1005 | return true; 1006 | } 1007 | return false; 1008 | } 1009 | 1010 | void ViewLog(){ 1011 | webString=""; 1012 | String payload; 1013 | String ShowPL; 1014 | payload += server.arg(0); 1015 | File f = SPIFFS.open(payload, "r"); 1016 | String webString = f.readString(); 1017 | f.close(); 1018 | ShowPL = String()+F( 1019 | "" 1020 | "<- BACK TO INDEX

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

" 1022 | "
" 1023 | "Binary: " 1024 | "
" 1025 | "Pulse Width: us " 1026 | "Data Interval: us " 1027 | "Delay Between Packets: us
" 1028 | "" 1029 | "
" 1030 | "Use commas to separate the binary for transmitting multiple packets(useful for sending multiple keypresses for imitating keypads)
" 1031 | "
" 1032 | " - " 1033 | "
")
1034 |     +payload+
1035 |     F("\n"
1036 |     "Note: Preambles shown are only a guess based on card length and may not be accurate for every card format.\n"
1037 |     "-----\n")
1038 |     +webString+
1039 |     F("
") 1040 | ; 1041 | webString=""; 1042 | server.send(200, "text/html", ShowPL); 1043 | } 1044 | 1045 | // Start Networking 1046 | void setup() { 1047 | Serial.begin(9600); 1048 | Serial.println(F(".....")); 1049 | Serial.println(String()+F("ESP-RFID-Tool v")+version); 1050 | //SPIFFS.format(); 1051 | 1052 | SPIFFS.begin(); 1053 | 1054 | //loadDefaults(); //uncomment to restore default settings if double reset fails for some reason 1055 | 1056 | //Jump RESTORE_DEFAULTS_PIN to GND while powering on device to reset the device to factory defaults 1057 | pinMode(RESTORE_DEFAULTS_PIN, INPUT_PULLUP); 1058 | jumperState = digitalRead(RESTORE_DEFAULTS_PIN); 1059 | if (jumperState == LOW) { 1060 | Serial.println(String()+F("Pin ")+RESTORE_DEFAULTS_PIN+F("Grounded")); 1061 | Serial.println(F("Loading default config...")); 1062 | loadDefaults(); 1063 | } 1064 | 1065 | loadConfig(); 1066 | 1067 | if(!wg.begin(DATA0,DATA1,bufferlength,rxpacketgap)) { 1068 | Serial.println(F("Could not begin Wiegand logging,")); 1069 | Serial.println(F("Out of memory!")); 1070 | } 1071 | 1072 | //Set up Web Pages 1073 | server.on("/",[]() { 1074 | FSInfo fs_info; 1075 | SPIFFS.info(fs_info); 1076 | String total; 1077 | total=fs_info.totalBytes; 1078 | String used; 1079 | used=fs_info.usedBytes; 1080 | String freespace; 1081 | freespace=fs_info.totalBytes-fs_info.usedBytes; 1082 | server.send(200, "text/html", String()+F("ESP-RFID-Tool v")+version+F("
" 1083 | "
" 1084 | "by Corey Harding
" 1085 | "www.RFID-Tool.com
" 1086 | "www.LegacySecurityGroup.com / www.Exploit.Agency

" 1087 | "-----
" 1088 | "File System Info Calculated in Bytes
" 1089 | "Total: ")+total+" Free: "+freespace+" "+" Used: "+used+F("
-----
" 1090 | "List Exfiltrated Data
-
" 1091 | "Experimental TX Mode
-
" 1092 | "Data Conversion Tools
-
" 1093 | "Configure Settings
-
" 1094 | "Format File System
-
" 1095 | "Upgrade Firmware
-
" 1096 | "API Info
-
" 1097 | "Help" 1098 | "")); 1099 | }); 1100 | 1101 | server.onNotFound([]() { 1102 | if (!RawFile(server.uri())) 1103 | server.send(404, "text/plain", F("Error 404 File Not Found")); 1104 | }); 1105 | server.on("/settings", handleSettings); 1106 | 1107 | server.on("/firmware", [](){ 1108 | 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.
")); 1109 | }); 1110 | 1111 | server.on("/restoredefaults", [](){ 1112 | server.send(200, "text/html", F("This will restore the device to the default configuration.

Are you sure?

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

Network
---
SSID: ESP-RFID-Tool

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

Are you sure?

YES - NO")); 1128 | }); 1129 | 1130 | server.on("/viewlog", ViewLog); 1131 | 1132 | server.on("/deletelog/yes", [](){ 1133 | if(!server.authenticate(update_username, update_password)) 1134 | return server.requestAuthentication(); 1135 | String deletelog; 1136 | deletelog += server.arg(0); 1137 | if (!deletelog.startsWith("/payloads/")) server.send(200, "text/html", String()+F("<- BACK TO INDEX

List Exfiltrated Data

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

This will reformat the SPIFFS File System.

Are you sure?

YES - NO")); 1144 | }); 1145 | 1146 | server.on("/logs", ListLogs); 1147 | 1148 | server.on("/reboot", [](){ 1149 | if(!server.authenticate(update_username, update_password)) 1150 | return server.requestAuthentication(); 1151 | server.send(200, "text/html", F("<- BACK TO INDEX

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

Formatting file system: This may take up to 90 seconds")); 1160 | delay(50); 1161 | // Serial.print("Formatting file system..."); 1162 | SPIFFS.format(); 1163 | // Serial.println(" Success"); 1164 | saveConfig(); 1165 | }); 1166 | 1167 | server.on("/help", []() { 1168 | server.send_P(200, "text/html", HelpText); 1169 | }); 1170 | 1171 | server.on("/license", []() { 1172 | server.send_P(200, "text/html", License); 1173 | }); 1174 | 1175 | server.on("/data-convert", [](){ 1176 | 1177 | if (server.hasArg("bin2hexHTML")) { 1178 | 1179 | int bin2hexBUFFlen=(((server.arg("bin2hexHTML")).length())+1); 1180 | char bin2hexCHAR[bin2hexBUFFlen]; 1181 | (server.arg("bin2hexHTML")).toCharArray(bin2hexCHAR,bin2hexBUFFlen); 1182 | 1183 | dataCONVERSION+=String()+F("Binary: ")+bin2hexCHAR+F("

"); 1184 | 1185 | String hexTEMP=""; 1186 | 1187 | int binCOUNT=(bin2hexBUFFlen-1); 1188 | 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.

"); 1198 | hexTEMP=""; 1199 | 1200 | dataCONVERSION+=F("

"); 1201 | 1202 | bin2hexBUFFlen=0; 1203 | } 1204 | 1205 | if (server.hasArg("hex2binHTML")) { 1206 | 1207 | int hex2binBUFFlen=(((server.arg("hex2binHTML")).length())+1); 1208 | char hex2binCHAR[hex2binBUFFlen]; 1209 | (server.arg("hex2binHTML")).toCharArray(hex2binCHAR,hex2binBUFFlen); 1210 | 1211 | dataCONVERSION+=String()+F("Hexadecimal: ")+hex2binCHAR+F("

"); 1212 | 1213 | String binTEMP=""; 1214 | 1215 | int charCOUNT=(hex2binBUFFlen-1); 1216 | for (int currentHEXpos=0; currentHEXpos
"); 1232 | binTEMP=""; 1233 | 1234 | dataCONVERSION+=F("

"); 1235 | 1236 | hex2binBUFFlen=0; 1237 | } 1238 | 1239 | if (server.hasArg("abaHTML")) { 1240 | String abaHTML=(server.arg("abaHTML")); 1241 | 1242 | dataCONVERSION="Trying \"Forward\" Swipe
"; 1243 | dataCONVERSION+=("Forward Binary:"+abaHTML+"
"); 1244 | int abaStart=abaHTML.indexOf("11010"); 1245 | int abaEnd=(abaHTML.lastIndexOf("11111")+4); 1246 | dataCONVERSION+=aba2str(abaHTML,abaStart,abaEnd,"\"Forward\" Swipe"); 1247 | 1248 | dataCONVERSION+=" * Trying \"Reverse\" Swipe
"; 1249 | int abaBUFFlen=((abaHTML.length())+1); 1250 | char abachar[abaBUFFlen]; 1251 | abaHTML.toCharArray(abachar,abaBUFFlen); 1252 | abaHTML=String(strrev(abachar)); 1253 | dataCONVERSION+=("Reversed Binary:"+abaHTML+"
"); 1254 | abaStart=abaHTML.indexOf("11010"); 1255 | abaEnd=(abaHTML.lastIndexOf("11111")+4); 1256 | dataCONVERSION+=aba2str(abaHTML,abaStart,abaEnd,"\"Reverse\" Swipe"); 1257 | 1258 | //dataCONVERSION+=(String()+F(" * You can verify the data at the following URL:
https://www.legacysecuritygroup.com/aba-decode.php?binary=")+abaHTML+F("")); 1259 | dataCONVERSION.replace("*", "

"); 1260 | dataCONVERSION.replace(":", ": "); 1261 | 1262 | abaHTML=""; 1263 | abaStart=0; 1264 | abaEnd=0; 1265 | } 1266 | 1267 | server.send(200, "text/html", String()+F( 1268 | "<- BACK TO INDEX

") 1269 | +dataCONVERSION+ 1270 | F( 1271 | "
" 1272 | "
" 1273 | "Convert ABA Binary Data to ASCII:
" 1274 | "
" 1275 | "
" 1276 | "
" 1277 | "
" 1278 | "
" 1279 | "Convert Binary Data to Hexadecimal:
" 1280 | "For use with card cloning, typically includes both the preamble and card data(binary before and after the space in log).
" 1281 | "
" 1282 | "
" 1283 | "
" 1284 | "
" 1285 | "
" 1286 | "Convert Hexadecimal Data to Binary:
" 1287 | "In some situations you may want to add a leading zero to pad the output to come up with the correct number of bits.
" 1288 | "
" 1289 | "
" 1290 | "
" 1291 | ) 1292 | ); 1293 | 1294 | dataCONVERSION=""; 1295 | }); 1296 | 1297 | #include "api_server.h" 1298 | 1299 | server.on("/stoptx", [](){ 1300 | server.send(200, "text/html", F("This will kill any ongoing transmissions.

Are you sure?

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

<- BACK TO EXPERIMENTAL TX MODE

All transmissions have been stopped.")); 1306 | }); 1307 | 1308 | server.on("/experimental", [](){ 1309 | String experimentalStatus="Awaiting Instructions"; 1310 | 1311 | if (server.hasArg("pinHTML")||server.hasArg("bruteEND")) { 1312 | pinHTML=server.arg("pinHTML"); 1313 | int pinBITS=server.arg("pinBITS").toInt(); 1314 | int pinHTMLDELAY=server.arg("pinHTMLDELAY").toInt(); 1315 | int bruteforcing; 1316 | int brutePAD=(server.arg("bruteSTART").length()); 1317 | if (server.hasArg("bruteSTART")) { 1318 | bruteforcing=1; 1319 | } 1320 | else { 1321 | bruteforcing=0; 1322 | } 1323 | 1324 | TXstatus=1; 1325 | 1326 | wg.pause(); 1327 | digitalWrite(DATA0, HIGH); 1328 | pinMode(DATA0,OUTPUT); 1329 | digitalWrite(DATA1, HIGH); 1330 | pinMode(DATA1,OUTPUT); 1331 | 1332 | pinHTML.replace("F1","C"); 1333 | pinHTML.replace("F2","D"); 1334 | pinHTML.replace("F3","E"); 1335 | pinHTML.replace("F4","F"); 1336 | 1337 | experimentalStatus=String()+"Transmitting "+pinBITS+"bit Wiegand Format PIN: "+pinHTML+" with a "+pinHTMLDELAY+"ms delay between \"keypresses\""; 1338 | delay(50); 1339 | 1340 | int bruteSTART; 1341 | int bruteEND; 1342 | if (server.hasArg("bruteSTART")) { 1343 | bruteSTART=server.arg("bruteSTART").toInt(); 1344 | } 1345 | else { 1346 | bruteSTART=0; 1347 | } 1348 | 1349 | if (server.hasArg("bruteEND")) { 1350 | bruteEND=server.arg("bruteEND").toInt(); 1351 | } 1352 | else { 1353 | bruteEND=0; 1354 | } 1355 | 1356 | if (server.hasArg("bruteSTART")) { 1357 | 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\"

"); 1358 | delay(50); 1359 | } 1360 | 1361 | String bruteSTARTchar=""; 1362 | String bruteENDchar=""; 1363 | if (server.hasArg("bruteSTARTchar")&&(server.arg("bruteSTARTchar")!="")) { 1364 | bruteSTARTchar=(server.arg("bruteSTARTchar")); 1365 | bruteSTARTchar.replace("F1","C"); 1366 | bruteSTARTchar.replace("F2","D"); 1367 | bruteSTARTchar.replace("F3","E"); 1368 | bruteSTARTchar.replace("F4","F"); 1369 | } 1370 | if (server.hasArg("bruteENDchar")&&(server.arg("bruteENDchar")!="")) { 1371 | bruteENDchar=(server.arg("bruteENDchar")); 1372 | bruteENDchar=(server.arg("bruteENDchar")); 1373 | bruteENDchar.replace("F1","C"); 1374 | bruteENDchar.replace("F2","D"); 1375 | bruteENDchar.replace("F3","E"); 1376 | bruteENDchar.replace("F4","F"); 1377 | } 1378 | 1379 | unsigned long bruteFAILdelay=0; 1380 | unsigned long bruteFAILS=0; 1381 | int bruteFAILmultiplier=0; 1382 | int bruteFAILmultiplierCURRENT=0; 1383 | int bruteFAILmultiplierAFTER=0; 1384 | int delayAFTERpin=0; 1385 | int bruteFAILSmax=0; 1386 | bruteFAILSmax=(server.arg("bruteFAILSmax")).toInt(); 1387 | delayAFTERpin=(server.arg("delayAFTERpin")).toInt(); 1388 | bruteFAILdelay=(server.arg("bruteFAILdelay")).toInt(); 1389 | bruteFAILmultiplier=(server.arg("bruteFAILmultiplier")).toInt(); 1390 | bruteFAILmultiplierAFTER=(server.arg("bruteFAILmultiplierAFTER")).toInt(); 1391 | 1392 | for (int brute=bruteSTART; brute<=bruteEND; brute++) { 1393 | 1394 | if (bruteforcing==1) { 1395 | pinHTML=String(brute); 1396 | while (pinHTML.length()=4294967000) { 1548 | bruteFAILS=(4294966000); 1549 | } 1550 | if (bruteFAILdelay>=4294967000) { 1551 | bruteFAILdelay=(4294966000); 1552 | } 1553 | 1554 | if (bruteFAILmultiplier!=0) { 1555 | bruteFAILmultiplierCURRENT++; 1556 | if (bruteFAILmultiplierCURRENT>=bruteFAILmultiplierAFTER) { 1557 | bruteFAILmultiplierCURRENT=0; 1558 | bruteFAILdelay=(bruteFAILdelay*bruteFAILmultiplier); 1559 | } 1560 | } 1561 | 1562 | if ((bruteFAILS>=bruteFAILSmax)&&(bruteFAILSmax!=0)) { 1563 | delay(bruteFAILdelay*1000); 1564 | } 1565 | else { 1566 | delay(delayAFTERpin); 1567 | } 1568 | 1569 | } 1570 | pinMode(DATA0, INPUT); 1571 | pinMode(DATA1, INPUT); 1572 | wg.clear(); 1573 | pinHTML=""; 1574 | pinHTMLDELAY=100; 1575 | TXstatus=0; 1576 | bruteforcing=0; 1577 | brutePAD=0; 1578 | bruteSTARTchar=""; 1579 | bruteENDchar=""; 1580 | bruteFAILdelay=0; 1581 | bruteFAILS=0; 1582 | bruteFAILmultiplier=0; 1583 | bruteFAILmultiplierCURRENT=0; 1584 | bruteFAILmultiplierAFTER=0; 1585 | delayAFTERpin=0; 1586 | bruteFAILSmax=0; 1587 | } 1588 | 1589 | 1590 | if (server.hasArg("binHTML")) { 1591 | String binHTML=server.arg("binHTML"); 1592 | wg.pause(); 1593 | digitalWrite(DATA0, HIGH); 1594 | pinMode(DATA0,OUTPUT); 1595 | digitalWrite(DATA1, HIGH); 1596 | pinMode(DATA1,OUTPUT); 1597 | 1598 | for (int i=0; i<=binHTML.length(); i++) { 1599 | if (binHTML.charAt(i) == '0') { 1600 | digitalWrite(DATA0, LOW); 1601 | delayMicroseconds(txdelayus); 1602 | digitalWrite(DATA0, HIGH); 1603 | } 1604 | else if (binHTML.charAt(i) == '1') { 1605 | digitalWrite(DATA1, LOW); 1606 | delayMicroseconds(txdelayus); 1607 | digitalWrite(DATA1, HIGH); 1608 | } 1609 | delay(txdelayms); 1610 | } 1611 | 1612 | pinMode(DATA0, INPUT); 1613 | pinMode(DATA1, INPUT); 1614 | wg.clear(); 1615 | 1616 | experimentalStatus=String()+"Transmitting Binary: "+binHTML; 1617 | binHTML=""; 1618 | } 1619 | 1620 | if (server.arg("fuzzType")=="simultaneous") { 1621 | 1622 | int fuzzTimes=0; 1623 | dos=0; 1624 | if ((server.arg("fuzzTimes"))=="dos") { 1625 | dos=1; 1626 | server.send(200, "text/html", String()+ 1627 | "<- BACK TO INDEX

" 1628 | "<- BACK TO EXPERIMENTAL TX MODE

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

" 1633 | ""); 1634 | delay(50); 1635 | } 1636 | else { 1637 | fuzzTimes=server.arg("fuzzTimes").toInt(); 1638 | server.send(200, "text/html", String()+ 1639 | "<- BACK TO INDEX

" 1640 | "<- BACK TO EXPERIMENTAL TX MODE

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

" 1645 | ""); 1646 | delay(50); 1647 | } 1648 | 1649 | wg.pause(); 1650 | digitalWrite(DATA0, HIGH); 1651 | pinMode(DATA0,OUTPUT); 1652 | digitalWrite(DATA1, HIGH); 1653 | pinMode(DATA1,OUTPUT); 1654 | 1655 | TXstatus=1; 1656 | 1657 | for (int i=0; i<=fuzzTimes || dos==1; i++) { 1658 | digitalWrite(DATA0, LOW); 1659 | digitalWrite(DATA1, LOW); 1660 | delayMicroseconds(txdelayus); 1661 | digitalWrite(DATA0, HIGH); 1662 | digitalWrite(DATA1, HIGH); 1663 | delay(txdelayms); 1664 | server.handleClient(); 1665 | if (TXstatus!=1) { 1666 | break; 1667 | } 1668 | } 1669 | 1670 | pinMode(DATA0, INPUT); 1671 | pinMode(DATA1, INPUT); 1672 | wg.clear(); 1673 | TXstatus=0; 1674 | dos=0; 1675 | 1676 | //experimentalStatus=String()+"Transmitting D0 and D1 bits simultaneously "+fuzzTimes+" times."; 1677 | } 1678 | 1679 | if (server.arg("fuzzType")=="alternating") { 1680 | 1681 | int fuzzTimes=0; 1682 | dos=0; 1683 | if ((server.arg("fuzzTimes"))=="dos") { 1684 | dos=1; 1685 | server.send(200, "text/html", String()+ 1686 | "<- BACK TO INDEX

" 1687 | "<- BACK TO EXPERIMENTAL TX MODE

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

" 1692 | ""); 1693 | delay(50); 1694 | } 1695 | else { 1696 | fuzzTimes=server.arg("fuzzTimes").toInt(); 1697 | server.send(200, "text/html", String()+ 1698 | "<- BACK TO INDEX

" 1699 | "<- BACK TO EXPERIMENTAL TX MODE

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

" 1704 | ""); 1705 | delay(50); 1706 | } 1707 | 1708 | wg.pause(); 1709 | digitalWrite(DATA0, HIGH); 1710 | pinMode(DATA0,OUTPUT); 1711 | digitalWrite(DATA1, HIGH); 1712 | pinMode(DATA1,OUTPUT); 1713 | 1714 | String binALT=""; 1715 | TXstatus=1; 1716 | 1717 | for (int i=0; i"; 1775 | currentPIN=""; 1776 | } 1777 | else if (dos==1) { 1778 | activeTX="Denial of Service mode active...
"; 1779 | } 1780 | else { 1781 | activeTX="Transmitting...
"; 1782 | } 1783 | 1784 | } 1785 | else { 1786 | activeTX="INACTIVE
"; 1787 | } 1788 | 1789 | server.send(200, "text/html", 1790 | String()+ 1791 | F( 1792 | "" 1793 | "" 1794 | "" 1795 | "Experimental TX Mode" 1796 | "" 1797 | "" 1798 | )+experimentalStatus+"

" 1799 | +F( 1800 | "Transmit Status: ")+activeTX+F("

" 1801 | "<- BACK TO INDEX
" 1802 | "

" 1803 | "

Experimental TX Mode

" 1804 | "
" 1805 | "" 1806 | "Warning: This mode is highly experimental, use at your own risk!
" 1807 | "Note: Timings for the Wiegand Data Pulse Width and Wiegand Data Interval may be changed on the settings page." 1808 | "
" 1809 | "
" 1810 | "
" 1811 | "
" 1812 | "
" 1813 | "Binary Data:
" 1814 | "Typically no need to include preamble
" 1815 | "
" 1816 | "
" 1817 | "
" 1818 | "
" 1819 | "
" 1820 | "
" 1821 | "
" 1822 | "Transmit PIN:
" 1823 | "Available keys 0-9, * or A, # or B, F1 or C, F2 or D, F3 or E, F4 or F
" 1824 | "PIN:
" 1825 | "Delay between \"keypresses\": ms
" 1826 | " 4bit Wiegand PIN Format " 1827 | " 8bit Wiegand PIN Format
" 1828 | "
" 1829 | "
" 1830 | "
" 1831 | "
" 1832 | "
" 1833 | "
" 1834 | "Bruteforce PIN:
" 1835 | "Delay between \"keypresses\": ms
" 1836 | "Delay between entering complete PINs: ms
" 1837 | "PIN begins with character(s):
" 1838 | "PIN start position:
" 1839 | "PIN end position:
" 1840 | "PIN ends with character(s):
" 1841 | "NOTE: The advanced timing settings listed below override the \"Delay between entering complete PINs\" setting(listed above) when the conditions listed below are met.
" 1842 | "Number of failed PIN attempts(X) before a delay:
" 1843 | "Delay in seconds(Y) after [X] failed PINs: s
" 1844 | "Multiply delay [Y] by after every failed pin attempts
" 1845 | " 4bit Wiegand PIN Format " 1846 | " 8bit Wiegand PIN Format
" 1847 | "

" 1848 | "
" 1849 | "
" 1850 | "
" 1851 | "Fuzzing:

" 1852 | "
" 1853 | "Number of bits:" 1854 | "
" 1855 | //" 0, must not be empty \" minlength=\"1\" size=\"32\">
" 1856 | " Transmit a bit simultaneously on D0 and D1 (X bits per each line)
" 1857 | " Transmit X bits alternating between D0 and D1 each bit (01010101,etc)
" 1858 | "
" 1859 | "
" 1860 | "
" 1861 | "
" 1862 | "
" 1863 | "Denial Of Service Mode:

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

" 1877 | "
" 1878 | "Time in ms to push the door open button:" 1879 | " 0, must not be empty\" minlength=\"1\" size=\"32\">
" 1880 | "Does the wire expect a High or Low signal to open the door:" 1881 | " Low Signal[Ground] " 1882 | " High Signal[3.3V]
" 1883 | "
" 1884 | "
" 1885 | "
" 1886 | "
" 1887 | "
" 1888 | "

" 1889 | "" 1890 | "" 1891 | ) 1892 | ); 1893 | 1894 | if (server.args()>=1) { 1895 | if (safemode==1) { 1896 | delay(50); 1897 | ESP.restart(); 1898 | } 1899 | } 1900 | 1901 | }); 1902 | 1903 | server.begin(); 1904 | WiFiClient client; 1905 | client.setNoDelay(1); 1906 | 1907 | // Serial.println("Web Server Started"); 1908 | 1909 | MDNS.begin("ESP"); 1910 | 1911 | httpUpdater.setup(&httpServer, update_path, update_username, update_password); 1912 | httpServer.begin(); 1913 | 1914 | MDNS.addService("http", "tcp", 1337); 1915 | 1916 | if (ftpenabled==1){ 1917 | ftpSrv.begin(String(ftp_username),String(ftp_password)); 1918 | } 1919 | 1920 | //Start RFID Reader 1921 | pinMode(LED_BUILTIN, OUTPUT); // LED 1922 | if (ledenabled==1){ 1923 | digitalWrite(LED_BUILTIN, LOW); 1924 | } 1925 | else{ 1926 | digitalWrite(LED_BUILTIN, HIGH); 1927 | } 1928 | 1929 | } 1930 | // 1931 | 1932 | //Do It! 1933 | 1934 | /////////////////////////////////////////////////////// 1935 | // LOOP function 1936 | void loop() 1937 | { 1938 | if (ftpenabled==1){ 1939 | ftpSrv.handleFTP(); 1940 | } 1941 | server.handleClient(); 1942 | httpServer.handleClient(); 1943 | while (Serial.available()) { 1944 | String cmd = Serial.readStringUntil(':'); 1945 | if(cmd == "ResetDefaultConfig"){ 1946 | loadDefaults(); 1947 | ESP.restart(); 1948 | } 1949 | } 1950 | 1951 | //Serial.print("Free heap-"); 1952 | //Serial.println(ESP.getFreeHeap(),DEC); 1953 | 1954 | if(wg.available()) { 1955 | wg.pause(); // pause Wiegand pin interrupts 1956 | LogWiegand(wg); 1957 | wg.clear(); // compulsory to call clear() to enable interrupts for subsequent data 1958 | if (safemode==1) { 1959 | ESP.restart(); 1960 | } 1961 | } 1962 | 1963 | } 1964 | -------------------------------------------------------------------------------- /Source Code/esprfidtool/pinSEND.h: -------------------------------------------------------------------------------- 1 | void pinSEND(int pinDELAY,String pinBIN) { 2 | for (int i=0; i<=pinBIN.length(); i++) { 3 | if (pinBIN.charAt(i) == '0') { 4 | digitalWrite(DATA0, LOW); 5 | delayMicroseconds(txdelayus); 6 | digitalWrite(DATA0, HIGH); 7 | } 8 | else if (pinBIN.charAt(i) == '1') { 9 | digitalWrite(DATA1, LOW); 10 | delayMicroseconds(txdelayus); 11 | digitalWrite(DATA1, HIGH); 12 | } 13 | delay(txdelayms); 14 | } 15 | yield(); 16 | delay(pinDELAY); 17 | pinBIN=""; 18 | pinDELAY=100; 19 | } 20 | -------------------------------------------------------------------------------- /Source Code/esprfidtool/strrev.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2007 Dmitry Xmelkov 2 | All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are met: 5 | * Redistributions of source code must retain the above copyright 6 | notice, this list of conditions and the following disclaimer. 7 | * Redistributions in binary form must reproduce the above copyright 8 | notice, this list of conditions and the following disclaimer in 9 | the documentation and/or other materials provided with the 10 | distribution. 11 | * Neither the name of the copyright holders nor the names of 12 | contributors may be used to endorse or promote products derived 13 | from this software without specific prior written permission. 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 18 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | /* $Id$ */ 28 | char * strrev (char *s) 29 | { 30 | char *p1, *p2; 31 | 32 | for (p2 = s; *p2; ) p2++; 33 | p1 = s; 34 | while (p1 < p2) { 35 | char c1 = *p1; 36 | char c2 = *--p2; 37 | *p1++ = c2; 38 | *p2 = c1; 39 | } 40 | return s; 41 | } 42 | -------------------------------------------------------------------------------- /Source Code/esprfidtool/version.h: -------------------------------------------------------------------------------- 1 | String version = "1.2.1"; 2 | String APIversion = "1.0.4"; 3 | --------------------------------------------------------------------------------