├── .gitignore ├── LICENSE ├── README.md ├── examples ├── customcallback.py ├── helloworld.py └── helloworld_file.py ├── fakeap ├── __init__.py ├── arp.py ├── callbacks.py ├── conf.py ├── constants.py ├── eap.py ├── fakeap.py ├── rpyutils │ ├── LICENSE │ ├── __init__.py │ └── rpyutils.py └── tint.py └── setup.py /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | scapy_fakeap.egg-info/ 3 | TODO 4 | pull_trees.sh 5 | push_trees.sh 6 | examples/dev.py 7 | *.pyc 8 | *.conf 9 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | {description} 294 | Copyright (C) {year} {fullname} 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | {signature of Ty Coon}, 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | scapy-fakeap 2 | ============ 3 | 4 | Fake wireless Access Point (AP) implementation using Python and Scapy, intended for convenient testing of 802.11 protocols and implementations. This library is a work in progress, and currently only supports open 802.11 networks. 5 | 6 | 7 | Motivation 8 | ---------- 9 | 10 | Testing 802.11 protocols and implementations for bugs or security vulnerabilities requires a simple and flexible AP implementation. This library aims to provide these features by using the popular packet manipulation program 'Scapy' for data transmission and reception. 11 | 12 | 13 | Installation 14 | ------------ 15 | 16 | You will need to have the following packages installed: 17 | - ```scapy``` 18 | - ```ip``` 19 | - ```airmon-ng``` 20 | - ```dnsmasq``` (optional) 21 | 22 | Then, run ```python2 setup.py install``` to install ```scapy-fakeap```. 23 | 24 | 25 | Examples 26 | -------- 27 | 28 | First, set up your device in monitor mode. You can use ```airmon-ng``` or ```iw```: 29 | 30 | ``` 31 | # iw dev wlan0 interface add mon0 type monitor 32 | # ifconfig mon0 up 33 | ``` 34 | 35 | From there, setting up a basic AP with ```scapy-fakeap``` is extremely simple, as shown in the example below: 36 | 37 | ```python 38 | # This example is a simple 'hello world' for scapy-fakeap. 39 | # An open network will be created that can be joined by 802.11 enabled devices. 40 | 41 | from fakeap import * 42 | 43 | ap = FakeAccessPoint('mon0', 'Hello scapy-fakeap world!') 44 | ap.run() 45 | ``` 46 | 47 | For more examples, please see the 'examples' folder. 48 | 49 | 50 | Callbacks 51 | --------- 52 | 53 | The behaviour of the AP can be completely customized by changing the callbacks associated with a certain event. To do this, pass a custom ```Callbacks()``` object to the ```FakeAccessPoint``` constructor or to an instance during runtime. Currently, the following callbacks are provided: 54 | 55 | - ```cb_recv_pkt```: Triggered every time a packet is received. This callback defines when all other callbacks are triggered. 56 | - ```cb_dot11_probe_req```: Triggered on reception of a Probe Request frame. The default behaviour is to reply with a Probe Response frame. 57 | - ```cb_dot11_beacon```: Triggered every 0.1 seconds. The default behaviour is to send a Beacon frame. 58 | - ```cb_dot11_auth```: Triggered on reception of an Authentication Request frame. The default behaviour is to reply with an Authentication Response frame. 59 | - ```cb_dot11_assoc_req```: Triggered on reception of an Association Request frame. The default behaviour is to reply with an Association Response frame. 60 | - ```cb_dot11_rts```: Triggered on reception of an RTS frame. The default behaviour is to reply with a CTS frame. 61 | - ```cb_arp_req```: Triggered on reception of an ARP Request. The default behaviour is to reply with an ARP Response. 62 | - ```cb_dot1X_eap_req```: Triggered on reception of an 802.1X EAP Request frame. The default behaviour is to reply with an 802.1X EAP Response frame. 63 | - ```cb_dhcp_discover```: Triggered on reception of a DHCP Discover message. The default behaviour is to forward the message to ```dnsmasq```. 64 | - ```cb_dhcp_request```: Triggered on reception of a DHCP Request message. The default behaviour is to forward the message to ```dnsmasq```. 65 | - ```cb_dns_request```: Triggered on reception of a DNS Request message. The default behaviour is to forward the message to ```dnsmasq```. 66 | - ```cb_tint_read```: Triggered on reception of a packet from the ```fakeap``` virtual interface. This callback defines when callbacks related to this interface are triggered. 67 | 68 | 69 | ### Writing your own callback: 70 | The following example shows how a custom callback for a ```Callbacks()``` instance can be easily created: 71 | 72 | ```python 73 | # This example demonstrates how to create a new callback for a specific Callbacks() instance. 74 | # The callback will trigger each time an EAPOL packet is sniffed. 75 | 76 | from types import MethodType 77 | from scapy.layers.dot11 import EAPOL 78 | from fakeap import * 79 | 80 | 81 | def do_something(self): # Our custom callback 82 | print("Got EAPOL packet!") 83 | 84 | 85 | def my_recv_pkt(self, packet): # We override recv_pkt to include a trigger for our callback 86 | if EAPOL in packet: 87 | self.cb_do_something() 88 | self.recv_pkt(packet) 89 | 90 | ap = FakeAccessPoint('mon0', 'My first callback!') 91 | ap.wpa = AP_WLAN_TYPE_WPA2 # Enable WPA2 92 | ap.ieee8021x = 1 # Enable 802.1X (WPA-Enterprise) 93 | my_callbacks = Callbacks(ap) 94 | my_callbacks.cb_recv_pkt = MethodType(my_recv_pkt, my_callbacks) 95 | my_callbacks.cb_do_something = MethodType(do_something, my_callbacks) 96 | ap.callbacks = my_callbacks 97 | 98 | ap.run() 99 | ``` 100 | 101 | 102 | Service interaction 103 | ------------------- 104 | 105 | Upon instantiation of a ```FakeAccessPoint``` object, scapy-fakeap automatically creates the ```fakeap``` virtual interface, which may be used for interacting with other services. For example, you can set it as the listen interface for ```dnsmasq``` to use a DHCP server for your fake AP. -------------------------------------------------------------------------------- /examples/customcallback.py: -------------------------------------------------------------------------------- 1 | # This example demonstrates how to create a new callback for a specific Callbacks() instance. 2 | # The callback will trigger each time an EAPOL packet is sniffed. 3 | 4 | from types import MethodType 5 | from scapy.layers.dot11 import EAPOL 6 | from fakeap import * 7 | 8 | 9 | def do_something(self): # Our custom callback 10 | print("Got EAPOL packet!") 11 | 12 | 13 | def my_recv_pkt(self, pkt): # We override recv_pkt to include a trigger for our callback 14 | if EAPOL in pkt: 15 | self.cb_do_something() 16 | self.recv_pkt(pkt) 17 | 18 | ap = FakeAccessPoint('mon0', 'My first callback!') 19 | ap.wpa = AP_WLAN_TYPE_WPA2 # Enable WPA2 20 | ap.ieee8021x = 1 # Enable 802.1X (WPA-Enterprise) 21 | my_callbacks = Callbacks(ap) 22 | my_callbacks.cb_recv_pkt = MethodType(my_recv_pkt, my_callbacks) 23 | my_callbacks.cb_do_something = MethodType(do_something, my_callbacks) 24 | ap.callbacks = my_callbacks 25 | 26 | ap.run() -------------------------------------------------------------------------------- /examples/helloworld.py: -------------------------------------------------------------------------------- 1 | # This example is a simple 'hello world' for scapy-fakeap. 2 | # An open network will be created that can be joined by 802.11 enabled devices. 3 | 4 | from fakeap import * 5 | 6 | ap = FakeAccessPoint('mon0', 'github.com/rpp0/scapy-fakeap') 7 | ap.run() -------------------------------------------------------------------------------- /examples/helloworld_file.py: -------------------------------------------------------------------------------- 1 | # This example is a simple 'hello world' for scapy-fakeap. 2 | # An open network will be created that can be joined by 802.11 enabled devices. 3 | # The AP configuration is specified in 'example.conf'. 4 | 5 | from fakeap import FakeAccessPoint 6 | 7 | ap = FakeAccessPoint.from_file('example.conf') 8 | ap.run() -------------------------------------------------------------------------------- /fakeap/__init__.py: -------------------------------------------------------------------------------- 1 | from .fakeap import FakeAccessPoint 2 | from .callbacks import Callbacks 3 | from .constants import AP_WLAN_TYPE_OPEN, AP_WLAN_TYPE_WPA, AP_WLAN_TYPE_WPA2, \ 4 | AP_WLAN_TYPE_WPA_WPA2 5 | -------------------------------------------------------------------------------- /fakeap/arp.py: -------------------------------------------------------------------------------- 1 | import threading 2 | from rpyutils import printd, Level 3 | 4 | 5 | class ARPHandler(): 6 | def __init__(self): 7 | self.mutex = threading.Lock() 8 | self.arp_table = {} 9 | 10 | def add_entry(self, client_ip, client_mac): 11 | self.mutex.acquire() 12 | if client_ip not in self.arp_table: 13 | self.arp_table[client_ip] = client_mac 14 | self.mutex.release() 15 | 16 | def get_entry(self, client_ip): 17 | self.mutex.acquire() 18 | try: 19 | temp = self.arp_table[client_ip] 20 | except KeyError: 21 | temp = None 22 | printd("Could not find IP %s in ARP table." % client_ip, Level.WARNING) 23 | self.mutex.release() 24 | 25 | return temp 26 | -------------------------------------------------------------------------------- /fakeap/callbacks.py: -------------------------------------------------------------------------------- 1 | from .eap import * 2 | from rpyutils import * 3 | from .constants import * 4 | 5 | from scapy.layers.dot11 import * 6 | from scapy.layers.dhcp import * 7 | from scapy.layers.dns import DNS 8 | from scapy.layers.inet import TCP, UDP 9 | 10 | 11 | class Callbacks(object): 12 | def __init__(self, ap): 13 | self.ap = ap 14 | 15 | self.cb_recv_pkt = self.recv_pkt 16 | self.cb_dot11_probe_req = self.dot11_probe_resp 17 | self.cb_dot11_beacon = self.dot11_beacon 18 | self.cb_dot11_auth = self.dot11_auth 19 | self.cb_dot11_ack = self.dot11_ack 20 | self.cb_dot11_assoc_req = self.dot11_assoc_resp 21 | self.cb_dot11_rts = self.dot11_cts 22 | 23 | self.cb_dot1X_eap_req = self.dot1x_eap_resp 24 | 25 | self.cb_arp_req = self.arp_resp 26 | 27 | self.cb_dhcp_discover = self.dot11_to_tint 28 | self.cb_dhcp_request = self.dot11_to_tint 29 | self.cb_dns_request = self.dot11_to_tint 30 | self.cb_other_request = self.dot11_to_tint 31 | 32 | self.cb_tint_read = self.recv_pkt_tint 33 | 34 | def recv_pkt(self, packet): 35 | try: 36 | if len(packet.notdecoded[8:9]) > 0: # Driver sent radiotap header flags 37 | # This means it doesn't drop packets with a bad FCS itself 38 | flags = ord(packet.notdecoded[8:9]) 39 | if flags & 64 != 0: # BAD_FCS flag is set 40 | # Print a warning if we haven't already discovered this MAC 41 | if not packet.addr2 is None: 42 | printd("Dropping corrupt packet from %s" % packet.addr2, Level.BLOAT) 43 | # Drop this packet 44 | return 45 | 46 | # Management 47 | if packet.type == DOT11_TYPE_MANAGEMENT: 48 | if packet.subtype == DOT11_SUBTYPE_PROBE_REQ: # Probe request 49 | if Dot11Elt in packet: 50 | ssid = packet[Dot11Elt].info 51 | 52 | printd("Probe request for SSID %s by MAC %s" % (ssid, packet.addr2), Level.DEBUG) 53 | 54 | # Only send a probe response if one of our own SSIDs is probed 55 | if ssid in self.ap.ssids or (Dot11Elt in packet and packet[Dot11Elt].len == 0): 56 | if not (self.ap.hidden and ssid != self.ap.get_ssid()): 57 | self.cb_dot11_probe_req(packet.addr2, self.ap.get_ssid()) 58 | elif packet.subtype == DOT11_SUBTYPE_AUTH_REQ: # Authentication 59 | if packet.addr1 == self.ap.mac: # We are the receivers 60 | self.ap.sc = -1 # Reset sequence number 61 | self.cb_dot11_auth(packet.addr2) 62 | elif packet.subtype == DOT11_SUBTYPE_ASSOC_REQ or packet.subtype == DOT11_SUBTYPE_REASSOC_REQ: 63 | if packet.addr1 == self.ap.mac: 64 | self.cb_dot11_assoc_req(packet.addr2, packet.subtype) 65 | 66 | # After association, start EAP session if enabled 67 | if self.ap.ieee8021x: 68 | self.cb_dot1X_eap_req(packet.addr2, EAPCode.REQUEST, EAPType.IDENTITY, None) 69 | 70 | # Data packet 71 | if packet.type == DOT11_TYPE_DATA: 72 | if EAPOL in packet: 73 | if packet.addr1 == self.ap.mac: 74 | # EAPOL Start 75 | if packet[EAPOL].type == 0x01: 76 | self.ap.eap.reset_id() 77 | self.dot1x_eap_resp(packet.addr2, EAPCode.REQUEST, EAPType.IDENTITY, None) 78 | if EAP in packet: 79 | if packet[EAP].code == EAPCode.RESPONSE: # Responses 80 | if packet[EAP].type == EAPType.IDENTITY: 81 | identity = str(packet[Raw]) 82 | if packet.addr1 == self.ap.mac: 83 | # EAP Identity Response 84 | printd("Got identity: " + identity[0:len(identity) - 4], Level.INFO) 85 | 86 | # Send auth method LEAP 87 | self.dot1x_eap_resp(packet.addr2, EAPCode.REQUEST, EAPType.EAP_LEAP, "\x01\x00\x08" + "\x00\x00\x00\x00\x00\x00\x00\x00" + str(identity[0:len(identity) - 4])) 88 | if packet[EAP].type == EAPType.NAK: # NAK 89 | method = str(packet[Raw]) 90 | method = method[0:len(method) - 4] 91 | method = ord(method.strip("x\\")) 92 | printd("NAK suggested method " + EAPType.convert_type(method), Level.INFO) 93 | 94 | elif ARP in packet: 95 | if packet[ARP].pdst == self.ap.ip.split('/')[0]: 96 | self.cb_arp_req(packet.addr2, packet[ARP].psrc) 97 | elif DHCP in packet: 98 | if packet.addr1 == self.ap.mac: 99 | if packet[DHCP].options[0][1] == 1: 100 | self.cb_dhcp_discover(packet) 101 | 102 | if packet[DHCP].options[0][1] == 3: 103 | self.cb_dhcp_request(packet) 104 | elif DNS in packet: 105 | self.cb_dns_request(packet) 106 | elif IP in packet: 107 | self.cb_other_request(packet) 108 | 109 | except Exception as err: 110 | print("Unknown error at monitor interface: %s" % repr(err)) 111 | 112 | def recv_pkt_tint(self, packet): 113 | try: 114 | packet = IP(packet) # We expect an IP packet from the external interface 115 | if BOOTP in packet: 116 | client_mac = bytes_to_mac(packet[BOOTP].chaddr[:6]) 117 | 118 | if DHCP in packet and packet[DHCP].options[0][1] == 5: # DHCP ACK 119 | client_ip = packet[BOOTP].yiaddr 120 | self.ap.arp.add_entry(client_ip, client_mac) 121 | printd("IP %s -> %s" % (client_ip, client_mac), Level.INFO) 122 | 123 | # Forward our message to the client 124 | self.dot11_encapsulate_ip(client_mac, packet) 125 | else: 126 | client_ip = packet[IP].dst 127 | self.dot11_encapsulate_ip(self.ap.arp.get_entry(client_ip), packet) 128 | 129 | except Exception as err: 130 | print("Unknown error at tun interface: %s" % repr(err)) 131 | 132 | def dot11_probe_resp(self, source, ssid): 133 | probe_response_packet = self.ap.get_radiotap_header() \ 134 | / Dot11(subtype=5, addr1=source, addr2=self.ap.mac, addr3=self.ap.mac, SC=self.ap.next_sc()) \ 135 | / Dot11ProbeResp(timestamp=self.ap.current_timestamp(), beacon_interval=0x0064, cap=0x2104) \ 136 | / Dot11Elt(ID='SSID', info=ssid) \ 137 | / Dot11Elt(ID='Rates', info=AP_RATES) \ 138 | / Dot11Elt(ID='DSset', info=chr(self.ap.channel)) 139 | 140 | # If we are an RSN network, add RSN data to response 141 | if self.ap.ieee8021x: 142 | probe_response_packet[Dot11ProbeResp].cap = 0x3101 143 | rsn_info = Dot11Elt(ID='RSNinfo', info=RSN) 144 | probe_response_packet = probe_response_packet / rsn_info 145 | 146 | sendp(probe_response_packet, iface=self.ap.interface, verbose=False) 147 | 148 | def dot11_beacon(self, ssid): 149 | # Create beacon packet 150 | beacon_packet = self.ap.get_radiotap_header() \ 151 | / Dot11(subtype=8, addr1='ff:ff:ff:ff:ff:ff', addr2=self.ap.mac, addr3=self.ap.mac) \ 152 | / Dot11Beacon(cap=0x2105) \ 153 | / Dot11Elt(ID='SSID', info=ssid) \ 154 | / Dot11Elt(ID='Rates', info=AP_RATES) \ 155 | / Dot11Elt(ID='DSset', info=chr(self.ap.channel)) 156 | 157 | if self.ap.ieee8021x: 158 | beacon_packet[Dot11Beacon].cap = 0x3101 159 | rsn_info = Dot11Elt(ID='RSNinfo', info=RSN) 160 | beacon_packet = beacon_packet / rsn_info 161 | 162 | # Update sequence number 163 | beacon_packet.SC = self.ap.next_sc() 164 | 165 | # Update timestamp 166 | beacon_packet[Dot11Beacon].timestamp = self.ap.current_timestamp() 167 | 168 | # Send 169 | sendp(beacon_packet, iface=self.ap.interface, verbose=False) 170 | 171 | def dot11_auth(self, receiver): 172 | auth_packet = self.ap.get_radiotap_header() \ 173 | / Dot11(subtype=0x0B, addr1=receiver, addr2=self.ap.mac, addr3=self.ap.mac, SC=self.ap.next_sc()) \ 174 | / Dot11Auth(seqnum=0x02) 175 | 176 | printd("Sending Authentication (0x0B)...", Level.DEBUG) 177 | sendp(auth_packet, iface=self.ap.interface, verbose=False) 178 | 179 | def dot11_ack(self, receiver): 180 | ack_packet = self.ap.get_radiotap_header() \ 181 | / Dot11(type='Control', subtype=0x1D, addr1=receiver) 182 | 183 | print("Sending ACK (0x1D) to %s ..." % receiver) 184 | sendp(ack_packet, iface=self.ap.interface, verbose=False) 185 | 186 | def dot11_assoc_resp(self, receiver, reassoc): 187 | response_subtype = 0x01 188 | if reassoc == 0x02: 189 | response_subtype = 0x03 190 | assoc_packet = self.ap.get_radiotap_header() \ 191 | / Dot11(subtype=response_subtype, addr1=receiver, addr2=self.ap.mac, addr3=self.ap.mac, SC=self.ap.next_sc()) \ 192 | / Dot11AssoResp(cap=0x2104, status=0, AID=self.ap.next_aid()) \ 193 | / Dot11Elt(ID='Rates', info=AP_RATES) 194 | 195 | printd("Sending Association Response (0x01)...", Level.DEBUG) 196 | sendp(assoc_packet, iface=self.ap.interface, verbose=False) 197 | 198 | def dot11_cts(self, receiver): 199 | cts_packet = self.ap.get_radiotap_header() \ 200 | / Dot11(ID=0x99, type='Control', subtype=12, addr1=receiver, addr2=self.ap.mac, SC=self.ap.next_sc()) 201 | 202 | printd("Sending CTS (0x0C)...", Level.DEBUG) 203 | sendp(cts_packet, iface=self.ap.interface, verbose=False) 204 | 205 | def arp_resp(self, receiver_mac, receiver_ip): 206 | arp_packet = self.ap.get_radiotap_header() \ 207 | / Dot11(type="Data", subtype=0, addr1=receiver_mac, addr2=self.ap.mac, addr3=self.ap.mac, SC=self.ap.next_sc(), FCfield='from-DS') \ 208 | / LLC(dsap=0xaa, ssap=0xaa, ctrl=0x03) \ 209 | / SNAP(OUI=0x000000, code=ETH_P_ARP) \ 210 | / ARP(psrc=self.ap.ip.split('/')[0], pdst=receiver_ip, op="is-at", hwsrc=self.ap.mac, hwdst=receiver_mac) 211 | 212 | printd("Sending ARP Response...", Level.DEBUG) 213 | sendp(arp_packet, iface=self.ap.interface, verbose=False) 214 | 215 | def dot1x_eap_resp(self, receiver, eap_code, eap_type, eap_data): 216 | eap_packet = self.ap.get_radiotap_header() \ 217 | / Dot11(type="Data", subtype=0, addr1=receiver, addr2=self.ap.mac, addr3=self.ap.mac, SC=self.ap.next_sc(), FCfield='from-DS') \ 218 | / LLC(dsap=0xaa, ssap=0xaa, ctrl=0x03) \ 219 | / SNAP(OUI=0x000000, code=0x888e) \ 220 | / EAPOL(version=1, type=0) \ 221 | / EAP(code=eap_code, id=self.ap.eap.next_id(), type=eap_type) 222 | 223 | if not eap_data is None: 224 | eap_packet = eap_packet / str(eap_data) 225 | 226 | printd("Sending EAP Packet (code = %d, type = %d, data = %s)..." % (eap_code, eap_type, eap_data), Level.DEBUG) 227 | sendp(eap_packet, iface=self.ap.interface, verbose=False) 228 | 229 | def unspecified_raw(self, raw_data): 230 | raw_packet = str(raw_data) 231 | 232 | printd("Sending RAW packet...", Level.DEBUG) 233 | sendp(raw_packet, iface=self.ap.interface, verbose=False) 234 | 235 | def dhcp_offer(self, client_mac, client_ip, xid): 236 | dhcp_offer_packet = self.ap.get_radiotap_header() \ 237 | / Dot11(type="Data", subtype=0, addr1="ff:ff:ff:ff:ff:ff", addr2=self.ap.mac, SC=self.ap.next_sc(), FCfield='from-DS') \ 238 | / LLC(dsap=0xaa, ssap=0xaa, ctrl=0x03) \ 239 | / SNAP(OUI=0x000000, code=ETH_P_IP) \ 240 | / IP(src=self.ap.ip, dst=client_ip) \ 241 | / UDP(sport=67, dport=68) \ 242 | / BOOTP(op=2, yiaddr=client_ip, siaddr=self.ap.ip, giaddr=self.ap.ip, chaddr=mac_to_bytes(client_mac), xid=xid) \ 243 | / DHCP(options=[('message-type', 'offer')]) \ 244 | / DHCP(options=[('subnet_mask', '255.255.255.0')]) \ 245 | / DHCP(options=[('server_id', self.ap.ip), 'end']) 246 | 247 | sendp(dhcp_offer_packet, iface=self.ap.interface, verbose=False) 248 | 249 | def dhcp_ack(self, client_mac, client_ip, xid): 250 | dhcp_ack_packet = self.ap.get_radiotap_header() \ 251 | / Dot11(type="Data", subtype=0, addr1="ff:ff:ff:ff:ff:ff", addr2=self.ap.mac, SC=self.ap.next_sc(), FCfield='from-DS') \ 252 | / LLC(dsap=0xaa, ssap=0xaa, ctrl=0x03) \ 253 | / SNAP(OUI=0x000000, code=ETH_P_IP) \ 254 | / IP(src=self.ap.ip, dst=client_ip) \ 255 | / UDP(sport=67,dport=68) \ 256 | / BOOTP(op=2, yiaddr=client_ip, siaddr=self.ap.ip, giaddr=self.ap.ip, chaddr=mac_to_bytes(client_mac), xid=xid) \ 257 | / DHCP(options=[('message-type','ack')]) \ 258 | / DHCP(options=[('server_id', self.ap.ip)]) \ 259 | / DHCP(options=[('lease_time', 43200)]) \ 260 | / DHCP(options=[('subnet_mask', '255.255.255.0')]) \ 261 | / DHCP(options=[('router', self.ap.ip)]) \ 262 | / DHCP(options=[('name_server', DEFAULT_DNS_SERVER)]) \ 263 | / DHCP(options=[('domain', "localdomain")]) \ 264 | / DHCP(options=['end']) 265 | sendp(dhcp_ack_packet, iface=self.ap.interface, verbose=False) 266 | 267 | def dot11_encapsulate_ip(self, client_mac, ip_packet): 268 | if IP in ip_packet: 269 | del ip_packet[IP].chksum 270 | del ip_packet[IP].len 271 | else: 272 | raise Exception("Attempted to encapsulate non-IP packet.") 273 | 274 | if UDP in ip_packet: 275 | del ip_packet[UDP].len 276 | 277 | response_packet = self.ap.get_radiotap_header() \ 278 | / Dot11(type="Data", subtype=0, addr1=client_mac, addr2=self.ap.mac, SC=self.ap.next_sc(), FCfield='from-DS') \ 279 | / LLC(dsap=0xaa, ssap=0xaa, ctrl=0x03) \ 280 | / SNAP(OUI=0x000000, code=ETH_P_IP) \ 281 | / str(ip_packet) 282 | 283 | sendp(response_packet, iface=self.ap.interface, verbose=False) 284 | 285 | def dot11_to_tint(self, pkt): 286 | self.ap.tint.write(pkt) # Pass to third party application for handling -------------------------------------------------------------------------------- /fakeap/conf.py: -------------------------------------------------------------------------------- 1 | from ConfigParser import ConfigParser, NoOptionError 2 | from rpyutils import printd, Level 3 | 4 | 5 | class ConfigHeader(object): 6 | def __init__(self, fp): 7 | self.fp = fp 8 | self.first_line = True 9 | self.dummy_section = '[fakeap]\n' 10 | 11 | def readline(self): 12 | if self.first_line: 13 | self.first_line = False 14 | return self.dummy_section 15 | else: 16 | return self.fp.readline() 17 | 18 | 19 | class Conf(ConfigParser): 20 | def __init__(self, path): 21 | ConfigParser.__init__(self) # ConfigParser is an old-style class... Can't user 'super' 22 | self.path = path 23 | self.readfp(ConfigHeader(open(path))) 24 | 25 | def get(self, key, default=None): 26 | value = None 27 | try: 28 | value = ConfigParser.get(self, 'fakeap', key) 29 | except NoOptionError as e: 30 | value = default 31 | printd("Option '%s' not specified in config file. Using default." % e.option, Level.WARNING) 32 | 33 | printd("%s -> %s" % (key, value), Level.INFO) 34 | 35 | return value 36 | -------------------------------------------------------------------------------- /fakeap/constants.py: -------------------------------------------------------------------------------- 1 | import platform 2 | 3 | RUNNING_ON_PI = platform.machine() == 'armv6l' 4 | DEFAULT_DNS_SERVER = "8.8.8.8" 5 | RSN = "\x01\x00\x00\x0f\xac\x04\x01\x00\x00\x0f\xac\x04\x01\x00\x00\x0f\xac\x01\x28\x00" 6 | 7 | AP_WLAN_TYPE_OPEN = 0 8 | AP_WLAN_TYPE_WPA = 1 9 | AP_WLAN_TYPE_WPA2 = 2 10 | AP_WLAN_TYPE_WPA_WPA2 = 3 11 | AP_AUTH_TYPE_OPEN = 0 12 | AP_AUTH_TYPE_SHARED = 1 13 | AP_RATES = "\x0c\x12\x18\x24\x30\x48\x60\x6c" 14 | 15 | DOT11_MTU = 4096 16 | 17 | DOT11_TYPE_MANAGEMENT = 0 18 | DOT11_TYPE_CONTROL = 1 19 | DOT11_TYPE_DATA = 2 20 | 21 | DOT11_SUBTYPE_DATA = 0x00 22 | DOT11_SUBTYPE_PROBE_REQ = 0x04 23 | DOT11_SUBTYPE_AUTH_REQ = 0x0B 24 | DOT11_SUBTYPE_ASSOC_REQ = 0x00 25 | DOT11_SUBTYPE_REASSOC_REQ = 0x02 26 | DOT11_SUBTYPE_QOS_DATA = 0x28 27 | 28 | 29 | IFNAMSIZ = 16 30 | IFF_TUN = 0x0001 31 | IFF_TAP = 0x0002 # Should we want to tunnel layer 2... 32 | IFF_NO_PI = 0x1000 33 | TUNSETIFF = 0x400454ca -------------------------------------------------------------------------------- /fakeap/eap.py: -------------------------------------------------------------------------------- 1 | import threading 2 | 3 | 4 | class EAPCode: 5 | REQUEST = 1 6 | RESPONSE = 2 7 | SUCCESS = 3 8 | FAILURE = 4 9 | 10 | 11 | class EAPType: 12 | IDENTITY = 1 13 | NOTIFICATION = 2 14 | NAK = 3 15 | MD5_CHALLENGE = 4 16 | OTP = 5 17 | GENERIC_TOKEN_CARD = 6 18 | EAP_TLS = 13 19 | EAP_LEAP = 17 20 | EAP_SIM = 18 21 | TTLS = 21 22 | PEAP = 25 23 | MSCHAP_V2 = 29 24 | EAP_CISCO_FAST = 43 25 | 26 | @classmethod 27 | def convert_type(cls, type_value): 28 | for key, value in vars(cls).iteritems(): 29 | if value == type_value: 30 | return str(key) 31 | 32 | 33 | class EAPHandler(): 34 | def __init__(self): 35 | self.id = 0 36 | self.mutex = threading.Lock() 37 | 38 | def next_id(self): 39 | self.mutex.acquire() 40 | self.id = (self.id + 1) 41 | temp = self.id 42 | self.mutex.release() 43 | 44 | return temp 45 | 46 | def reset_id(self): 47 | self.mutex.acquire() 48 | self.id = 0 49 | self.mutex.release() -------------------------------------------------------------------------------- /fakeap/fakeap.py: -------------------------------------------------------------------------------- 1 | 2 | import subprocess 3 | from scapy.all import sniff 4 | from .eap import * 5 | from .arp import * 6 | from rpyutils import check_root, get_frequency, if_hwaddr, clear_ip_tables 7 | from .callbacks import Callbacks 8 | from .tint import TunInterface 9 | from .conf import Conf 10 | from time import time, sleep 11 | from scapy.layers.dot11 import RadioTap, conf as scapyconf 12 | from scapy.layers.inet import TCP 13 | 14 | 15 | class FakeAccessPoint(object): 16 | class FakeBeaconTransmitter(threading.Thread): 17 | def __init__(self, ap): 18 | threading.Thread.__init__(self) 19 | self.ap = ap 20 | self.setDaemon(True) 21 | self.interval = 0.1 22 | 23 | def run(self): 24 | while True: 25 | for ssid in self.ap.ssids: 26 | self.ap.callbacks.cb_dot11_beacon(ssid) 27 | 28 | # Sleep 29 | sleep(self.interval) 30 | 31 | @classmethod 32 | def from_file(cls, path): 33 | conf = Conf(path) 34 | 35 | # Required 36 | interface = conf.get('interface', 'mon0') 37 | ssid = conf.get('ssid', 'github.com/rpp0/scapy-fakeap') 38 | bpffilter = conf.get('filter', "") 39 | 40 | # Apply required settings 41 | ap = FakeAccessPoint(interface, ssid, bpffilter=bpffilter) 42 | 43 | # Apply optional settings 44 | ap.channel = int(conf.get('channel', 1)) 45 | ap.mac = conf.get('mac', if_hwaddr(interface)) 46 | ap.wpa = conf.get('wpa', 0) 47 | ap.ieee8021x = conf.get('ieee8021x', 0) 48 | ap.ip = conf.get('ip', '10.0.0.1/24') 49 | 50 | return ap 51 | 52 | def __init__(self, interface, ssid, bpffilter=""): 53 | self.callbacks = Callbacks(self) 54 | self.ssids = [] 55 | self.current_ssid_index = 0 56 | 57 | self.interface = interface 58 | self.inet_interface = None 59 | self.channel = 1 60 | self.mac = if_hwaddr(interface) 61 | self.wpa = 0 62 | self.ieee8021x = 0 63 | self.lfilter = None 64 | self.hidden = False 65 | if bpffilter == "": 66 | self.bpffilter = "not ( wlan type mgt subtype beacon ) and ((ether dst host " + self.mac + ") or (ether dst host ff:ff:ff:ff:ff:ff))" 67 | else: 68 | self.bpffilter = bpffilter 69 | self.ip = '10.0.0.1/24' 70 | self.boottime = time() 71 | self.sc = 0 72 | self.aid = 0 73 | self.mutex = threading.Lock() 74 | 75 | # Protocol handlers 76 | self.eap = EAPHandler() 77 | self.arp = ARPHandler() 78 | 79 | self.add_ssid(ssid) 80 | self.beaconTransmitter = self.FakeBeaconTransmitter(self) 81 | 82 | self.tint = None 83 | 84 | def share_internet(self, dev): 85 | TCP.payload_guess = [] 86 | clear_ip_tables() 87 | 88 | # Postrouting 89 | if subprocess.call(['iptables', '--table', 'nat', '--append', 'POSTROUTING', '--out-interface', dev, '-j', 'MASQUERADE']): 90 | printd("Failed to setup postrouting for interface %s." % dev, Level.CRITICAL) 91 | 92 | # Forward 93 | if subprocess.call(['iptables', '--append', 'FORWARD', '--in-interface', self.tint.name, '-j', 'ACCEPT']): 94 | printd("Failed to setup forwarding for interface %s." % self.tint.name, Level.CRITICAL) 95 | 96 | # Enable IP forwarding 97 | if subprocess.call(['sysctl', '-w', 'net.ipv4.ip_forward=1']): 98 | printd("Failed to enable IP forwarding.", Level.CRITICAL) 99 | 100 | printd("IP packets will be routed through %s." % dev, Level.INFO) 101 | 102 | def add_ssid(self, ssid): 103 | if not ssid in self.ssids and ssid != '': 104 | self.ssids.append(ssid) 105 | 106 | def remove_ssid(self, ssid): 107 | if ssid in self.ssids: 108 | self.ssids.remove(ssid) 109 | 110 | def get_ssid(self): 111 | if len(self.ssids) > 0: 112 | return self.ssids[self.current_ssid_index] 113 | 114 | def cycle_ssid(self): 115 | maxidx = len(self.ssids) 116 | self.current_ssid_index = ((self.current_ssid_index + 1) % maxidx) 117 | 118 | def current_timestamp(self): 119 | return (time() - self.boottime) * 1000000 120 | 121 | def next_sc(self): 122 | self.mutex.acquire() 123 | self.sc = (self.sc + 1) % 4096 124 | temp = self.sc 125 | self.mutex.release() 126 | 127 | return temp * 16 # Fragment number -> right 4 bits 128 | 129 | def next_aid(self): 130 | self.mutex.acquire() 131 | self.aid = (self.aid + 1) % 2008 132 | temp = self.aid 133 | self.mutex.release() 134 | 135 | return temp 136 | 137 | def get_radiotap_header(self): 138 | radiotap_packet = RadioTap(len=18, present='Flags+Rate+Channel+dBm_AntSignal+Antenna', notdecoded='\x00\x6c' + get_frequency(self.channel) + '\xc0\x00\xc0\x01\x00\x00') 139 | return radiotap_packet 140 | 141 | def run(self): 142 | check_root() 143 | if not self.hidden: 144 | self.beaconTransmitter.start() 145 | 146 | self.tint = TunInterface(self) 147 | self.tint.start() 148 | 149 | if self.inet_interface is not None: 150 | self.share_internet(self.inet_interface) 151 | scapyconf.iface = self.interface 152 | sniff(iface=self.interface, prn=self.callbacks.cb_recv_pkt, store=0, filter=self.bpffilter) -------------------------------------------------------------------------------- /fakeap/rpyutils/LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | {description} 294 | Copyright (C) {year} {fullname} 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | {signature of Ty Coon}, 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. -------------------------------------------------------------------------------- /fakeap/rpyutils/__init__.py: -------------------------------------------------------------------------------- 1 | from rpyutils import * 2 | pass -------------------------------------------------------------------------------- /fakeap/rpyutils/rpyutils.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | import re 3 | import os 4 | import struct 5 | from scapy.arch import str2mac, get_if_raw_hwaddr 6 | 7 | 8 | class Level: 9 | CRITICAL = 0 10 | WARNING = 1 11 | INFO = 2 12 | DEBUG = 3 13 | BLOAT = 4 14 | 15 | VERBOSITY = Level.INFO 16 | 17 | 18 | class Color: 19 | GREY = '\x1b[1;37m' 20 | GREEN = '\x1b[1;32m' 21 | BLUE = '\x1b[1;34m' 22 | YELLOW = '\x1b[1;33m' 23 | RED = '\x1b[1;31m' 24 | MAGENTA = '\x1b[1;35m' 25 | CYAN = '\x1b[1;36m' 26 | 27 | 28 | def clr(color, text): 29 | return color + str(text) + '\x1b[0m' 30 | 31 | 32 | def check_root(): 33 | if not os.geteuid() == 0: 34 | printd(clr(Color.RED, "Run as root."), Level.CRITICAL) 35 | exit(1) 36 | 37 | 38 | def check_root_shadow(): 39 | dev_null = open(os.devnull, 'w') 40 | 41 | try: 42 | subprocess.check_output(['cat', '/etc/shadow'], stderr=dev_null) 43 | except subprocess.CalledProcessError: 44 | printd(clr(Color.RED, "Run as root."), Level.CRITICAL) 45 | exit(1) 46 | 47 | 48 | def set_monitor_mode(wlan_dev, enable=True): 49 | monitor_dev = None 50 | if enable: 51 | result = subprocess.check_output(['airmon-ng', 'start', wlan_dev]) 52 | if not "monitor mode enabled on" in result: 53 | printd(clr(Color.RED, "ERROR: Airmon could not enable monitor mode on device %s. Make sure you are root, and that" \ 54 | "your wlan card supports monitor mode." % wlan_dev), Level.CRITICAL) 55 | exit(1) 56 | monitor_dev = re.search(r"monitor mode enabled on (\w+)", result).group(1) 57 | 58 | printd("Airmon set %s to monitor mode on %s" % (wlan_dev, monitor_dev), Level.INFO) 59 | else: 60 | subprocess.check_output(['airmon-ng', 'stop', wlan_dev]) 61 | 62 | return monitor_dev 63 | 64 | 65 | def set_ip_address(dev, ip): 66 | if subprocess.call(['ip', 'addr', 'add', ip, 'dev', dev]): 67 | printd("Failed to assign IP address %s to %s." % (ip, dev), Level.CRITICAL) 68 | 69 | if subprocess.call(['ip', 'link', 'set', 'dev', dev, 'up']): 70 | printd("Failed to bring device %s up." % dev, Level.CRITICAL) 71 | 72 | 73 | def clear_ip_tables(): 74 | if subprocess.call(['iptables', '--flush']): 75 | printd("Failed to flush iptables.", Level.CRITICAL) 76 | if subprocess.call(['iptables', '--table', 'nat', '--flush']): 77 | printd("Failed to flush iptables NAT.", Level.CRITICAL) 78 | if subprocess.call(['iptables', '--delete-chain']): 79 | printd("Failed to delete iptables chain.", Level.CRITICAL) 80 | if subprocess.call(['iptables', '--table', 'nat', '--delete-chain']): 81 | printd("Failed to delete iptables NAT chain.", Level.CRITICAL) 82 | 83 | 84 | def printd(string, level): 85 | if VERBOSITY >= level: 86 | print(string) 87 | 88 | 89 | def hex_offset_to_string(byte_array): 90 | temp = byte_array.replace("\n", "") 91 | temp = temp.replace(" ", "") 92 | return temp.decode("hex") 93 | 94 | 95 | def get_frequency(channel): 96 | if channel == 14: 97 | freq = 2484 98 | else: 99 | freq = 2407 + (channel * 5) 100 | 101 | freq_string = struct.pack(" IFNAMSIZ: 16 | raise Exception("Tun interface name cannot be larger than " + str(IFNAMSIZ)) 17 | 18 | self.name = name 19 | self.setDaemon(True) 20 | self.ap = ap 21 | 22 | # Virtual interface 23 | self.fd = open('/dev/net/tun', 'r+b') 24 | ifr_flags = IFF_TUN | IFF_NO_PI # Tun device without packet information 25 | ifreq = struct.pack('16sH', name, ifr_flags) 26 | fcntl.ioctl(self.fd, TUNSETIFF, ifreq) # Syscall to create interface 27 | 28 | # Assign IP and bring interface up 29 | set_ip_address(name, self.ap.ip) 30 | 31 | print("Created TUN interface %s at %s. Bind it to your services if needed." % (name, self.ap.ip)) 32 | 33 | def write(self, pkt): 34 | os.write(self.fd.fileno(), str(pkt[IP])) # Strip layer 2 35 | 36 | def read(self): 37 | raw_packet = os.read(self.fd.fileno(), DOT11_MTU) 38 | return raw_packet 39 | 40 | def close(self): 41 | os.close(self.fd.fileno()) 42 | 43 | def run(self): 44 | while True: 45 | raw_packet = self.read() 46 | self.ap.callbacks.cb_tint_read(raw_packet) -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup, find_packages 2 | 3 | setup( 4 | name='scapy-fakeap', 5 | version='0.1', 6 | packages=find_packages(), 7 | url='', 8 | license='GPLv2', 9 | author='rpp0', 10 | author_email='red@nostack.net', 11 | requires=['scapy'], 12 | description='Fake AP implementation using Scapy' 13 | ) 14 | --------------------------------------------------------------------------------