Page 1 of 3 123 LastLast
Results 1 to 10 of 25

Thread: SoftAP scripts

  1. #1
    Senior Member Nick_the_Greek's Avatar
    Join Date
    Jan 2010
    Location
    Greece
    Posts
    181

    Default SoftAP scripts

    Hello everybody
    I would like to share with the BT community 2 scripts. Both are for the creation of a wireless AP with internet from a ppp connection. The 1st one is created with airbase-ng and the 2th with wlanconfig. My wifi card is atheros based.
    The scripts are based on Deathray's and fifo_thekid's scripts.
    here they are:
    Code:
    # installing a small caching DNS proxy and DHCP/TFTP server
    apt-get install dnsmasq-base
    
    # creating dhcpd.pid and changing group and own to dhcpd (no permision denied).
    cat /dev/null > /var/run/dhcpd.pid
    chgrp dhcpd /var/run/dhcpd.pid
    chown dhcpd /var/run/dhcpd.pid
    
    modprobe tun
    
    # stoping all monitor mode wireless interfaces
    # change wlan0 and mon0-1 to whatever your wifi card use 
    airmon-ng stop mon1
    airmon-ng stop mon0
    airmon-ng stop wlan0
    
    # starting monitor mode
    airmon-ng start wlan0
    
    # -=SoftAP Options=- 
    # channel 6
    # essid Home_WIFI
    # MAC 00:14:6C:F0:AD:00
    # (-P) respond to all probes, even when specifying ESSIDs
    # (-C 5) enables beaconing of probed ESSID values
    
    xterm -e airbase-ng -P -C 5 -c 6 -e Home_WIFI -a 00:14:6C:F0:AD:00 mon0 &
    
    sleep 3
    ifconfig at0 up
    ifconfig at0 mtu 1400
    sleep 3
    ifconfig at0 192.168.1.129 netmask 255.255.255.128
    route add -net 192.168.1.128 netmask 255.255.255.128 gw 192.168.1.129
    
    # monitor
    # xterm -e airodump-ng -c 6 --bssid 00:14:6C:F0:AD:00 wlan0 &
    
    # xterm -e wireshark -i 3 "not broadcast and not multicast" & # at0 = 3
    
    
    #kill all dns
    killall dnsmasq
    
    #DHCP KillAll
    killall dhcpd3
    
    # Cleanup our dhcpd.leases
    echo > '/var/lib/dhcp3/dhcpd.leases'
    
    # create custom dhcpd.conf for WLAN
    # My ISP's DNS servers are 195.170.0.1 and 195.170.2.2
    cat > dhcpd.conf << EOF
    ddns-update-style ad-hoc;
    default-lease-time 600;
    max-lease-time 7200;
    subnet 192.168.1.128 netmask 255.255.255.128 {
    option subnet-mask 255.255.255.128;
    option broadcast-address 192.168.1.255;
    option routers 192.168.1.129;
    option domain-name-servers 195.170.0.1, 195.170.2.2;
    range 192.168.1.130 192.168.1.140;
    }
    EOF
    
    # start dhcp server for subnet
    dhcpd3 -cf dhcpd.conf at0
    
    ## solve our dns forwarder
    dnsmasq restart
    
    ###########IP TABLES################
    
    # iptables cleanup
    iptables --flush
    iptables --table nat --flush
    iptables --delete-chain
    iptables --table nat --delete-chain
    
    # iptables
    
    iptables --table nat --append POSTROUTING --out-interface ppp0 -j MASQUERADE # gateway to adsl modem
    iptables --append FORWARD --in-interface at0 -j ACCEPT 
    iptables -t nat -A PREROUTING -s 192.168.1.128/25 -d 192.168.1.0/25 -j DROP # protect LAN from WLAN (DROP/REJECT)
    iptables -t nat -A PREROUTING -p udp --dport 53 -j DNAT --to 94.68.17.60 # my internet IP address 
    echo 1 > /proc/sys/net/ipv4/ip_forward
    My Internet IP in this script is 94.68.17.60 so you have to change it to your's IP.

    The second one is in 2 parts. The 1st installs the madwifi drivers (revision 4073) with aircrack patch.

    Code:
    ifconfig ath0 down
    ifconfig wifi0 down
    ifconfig mon0 down
    ifconfig wlan0 down
    modprobe -r ath5k
    modprobe -r ath9k
    
    cp -r /lib/modules/2.6.29.4/kernel/drivers/net/wireless/ath5k /root/
    cp -r /lib/modules/2.6.29.4/kernel/drivers/net/wireless/ath9k /root/
    rm -r /lib/modules/2.6.29.4/kernel/drivers/net/wireless/ath5k
    rm -r /lib/modules/2.6.29.4/kernel/drivers/net/wireless/ath9k
    
    # installing a small caching DNS proxy and DHCP/TFTP server
    apt-get install dnsmasq-base
    
    svn -r 4073 checkout http://svn.madwifi-project.org/madwifi/trunk/ madwifi-ng
    wget http://patches.aircrack-ng.org/madwifi-ng-r4073.patch
    patch -N -p 0 -i madwifi-ng-r4073.patch
    cd madwifi-ng 
    ./scripts/madwifi-unload
    make
    make install
    depmod -ae
    modprobe ath_pci
    This one is for the creation of the AP.
    Code:
    modprobe tun
    wlanconfig ath0 destroy
    wlanconfig ath0 create wlandev wifi0 wlanmode ap
    # essid Home_wifi, channel 11 at 54mbps
    iwconfig ath0 essid Home_wifi
    iwconfig ath0 channel 11
    iwconfig ath0 rate 54M
    sleep 3
    ifconfig ath0 up
    ifconfig ath0 mtu 1400
    cd /root/
    # creating dhcpd.pid and changing group and own to dhcpd (no permision denied).
    cat /dev/null > /var/run/dhcpd.pid
    chgrp dhcpd /var/run/dhcpd.pid
    chown dhcpd /var/run/dhcpd.pid
    
    sleep 3
    ifconfig ath0 192.168.1.129 netmask 255.255.255.128
    route add -net 192.168.1.128 netmask 255.255.255.128 gw 192.168.1.129
    
    #kill all dns
    killall dnsmasq
    
    #DHCP KillAll
    killall dhcpd3
    
    # Cleanup our dhcpd.leases
    echo > '/var/lib/dhcp3/dhcpd.leases'
    
    # create custom dhcpd.conf for WLAN
    cat > dhcpd.conf << EOF
    ddns-update-style ad-hoc;
    default-lease-time 600;
    max-lease-time 7200;
    subnet 192.168.1.128 netmask 255.255.255.128 {
    option subnet-mask 255.255.255.128;
    option broadcast-address 192.168.1.255;
    option routers 192.168.1.129;
    option domain-name-servers 195.170.0.1, 195.170.2.2;
    range 192.168.1.130 192.168.1.140;
    }
    EOF
    
    # start dhcp server for subnet
    dhcpd3 -cf dhcpd.conf ath0
    
    ## solve our dns forwarder
    dnsmasq restart
    
    ###########IP TABLES################
    
    # iptables cleanup
    iptables --flush
    iptables --table nat --flush
    iptables --delete-chain
    iptables --table nat --delete-chain
    
    # iptables
    iptables --table nat --append POSTROUTING --out-interface ppp0 -j MASQUERADE # gateway to ext. router
    iptables --append FORWARD --in-interface ath0 -j ACCEPT # rogue gateway
    iptables -t nat -A PREROUTING -s 192.168.1.128/25 -d 192.168.1.0/25 -j DROP # protect LAN from WLAN (DROP/REJECT)
    iptables -t nat -A PREROUTING -p udp --dport 53 -j DNAT --to 94.68.56.91
    echo 1 > /proc/sys/net/ipv4/ip_forward
    You must change all red marked line to your configuration.
    This one works much better then the 1st and I get higher data rates. I don't know if it is card related prob or airbase-ng. I believe that the airbase created AP's are a little bit problematic.
    Keep up the good work.

  2. #2
    Senior Member
    Join Date
    Jun 2007
    Location
    UK
    Posts
    175

    Default dhpc not running

    hi
    been trying for months to set up soft AP and just tried your second script.
    My windows box does not receive ip address
    Are you using BT4?
    to start my dhcp
    /etc/init.d/dhcpd3-server start
    thanks

  3. #3
    Very good friend of the forum Gitsnik's Avatar
    Join Date
    Jan 2010
    Location
    The Crystal Wind
    Posts
    851

    Default

    Nick, just a quick speed up for you, replace:
    Code:
    cat > /var/run/dhcpd.pid << EOF
    EOF
    With:
    Code:
    cat /dev/null > /var/run/dhcpd.pid
    Saves you an extra line
    Still not underestimating the power...

    There is no such thing as bad information - There is truth in the data, so you sift it all, even the crap stuff.

  4. #4
    Senior Member Nick_the_Greek's Avatar
    Join Date
    Jan 2010
    Location
    Greece
    Posts
    181

    Default

    @parrotface
    Yes, I am running BT4 pre final and dhcpd starts in line:
    Code:
    # start dhcp server for subnet
    dhcpd3 -cf dhcpd.conf ath0
    If you are not getting IP then sure there is a dhcpd problem. Can you provide more infos about your problem? You can "play" a litle bit with dhcpd to see how and why.
    There are alot softAP scripts here in the forum that you can experiment with them.
    @Gitsnik
    One guy, some years ago told me that "Programming is an art". Corrections are allways welcome.

  5. #5
    Senior Member
    Join Date
    Jun 2007
    Location
    UK
    Posts
    175

    Default intermittent IP

    thanks for response
    running your script on eeepc - client is a vista box say's
    Successfully connected to Home_wifi
    Have managed to get an IP a couple of times but not always.
    when I get an IP, I ran a IP scan on the vista box and cant find the AP IP.
    Tried to ping from AP - no response from client
    any ideas to debug the problem
    many thanks

  6. #6
    Senior Member Nick_the_Greek's Avatar
    Join Date
    Jan 2010
    Location
    Greece
    Posts
    181

    Default

    hi, parrotface
    My client box is running XP pro, but I don't believe this is a prob for you since your client is running vista. Have you change this lines to your configurations ?
    Code:
    iptables --table nat --append POSTROUTING --out-interface ppp0 -j MASQUERADE # gateway to ext. router
    If you are getting internet via a ethernet card you must change ppp0 to eth1.
    Or if you are getting internet via a wireless card you must change it to wlan0 or whatever your interface is called.
    And finally :
    Code:
    iptables -t nat -A PREROUTING -p udp --dport 53 -j DNAT --to 94.68.56.91
    Change 94.68.56.91 to your internet gateway IP.
    I don't believe there is a dhcpd problem since you are getting IP from your client.
    Also since you have a atheros based card, maybe the drivers for your card can't support correctly master mode. But since injection is supported you can try to setup a softAP with airebase-ng.
    You can also use Roguev3.sh from fifo_thekid.This script is more ease to use:
    hxxp://rapidshare.com/files/251982682/Video11.zip
    Hope I helped

  7. #7
    Senior Member
    Join Date
    Jun 2007
    Location
    UK
    Posts
    175

    Default can't ping

    Hi
    still can't connect
    Vista box receives IP address OK
    IP scan on vista box shows box IP but not the AP IP
    can't ping in either direction
    I guess that it is not connected properly

    set up
    eeepc running BT4 pf - wifi using ath0 (madwifi) internet eth0

    Thanks for your previous info, just trying to get boxes talking first then we can try to get internet connected or does the IP tables affect the basic connection (have changed them)

    also how do you recommend the easiest way to stop AP during testing?
    thanks for your help

  8. #8
    Member
    Join Date
    Feb 2010
    Posts
    204

    Default

    try connecting with an xp machine

    if it works then its a vista issue, could be to do with ipv6 and forwarding

  9. #9
    Senior Member Nick_the_Greek's Avatar
    Join Date
    Jan 2010
    Location
    Greece
    Posts
    181

    Default

    Hi
    As hm2075 suggested, you can try with a XP client. Maybe I am stupid, but what do you mean by saying:
    Vista box receives IP address OK
    IP scan on vista box shows box IP but not the AP IP
    At what range do you get IPs? 192.168.1.130-192.168.1.140?
    What IP do you expect to receive? what do you mean AP IP? Do you expect to receive your internet IP from softAP?
    As you can see in dhcpd.conf the range of IPs that you will get will be in range from 192.168.1.130 to 192.168.1.140 (10 clients)
    You must notice that the 1st and the 2nd script works very well for me with atheros based card and ppp or wireless connection for internet, but with airbase-ng created AP I have had problems when I tried them with zydas based cards. Still trying to solve em out. So, maybe is drivers or card related problem. You may notice ,as I now, that the purpose of airbase-ng isn't to act as an AP as we know. It's for testing.Finally,
    also how do you recommend the easiest way to stop AP during testing?
    ifconfig ath0 down ,or
    wlanconfig ath0 destroy
    Have you tried Roguev3.sh script?
    Two suggestions : Read more about wlanconfig and madwifi drivers, dhcpd and iptables. The solution will come out by it self.
    If nothing works come to Greece and go in a island and the solution again will come out by it self.

  10. #10
    Senior Member
    Join Date
    Jun 2007
    Location
    UK
    Posts
    175

    Default

    hi
    tried xp box this connects but No internet
    Vista box connect at same time again No internet
    If I run IP scanner on both vista and XP it shows the IP address of the other but the AP IP address does not show like it does when connected to a normal AP.
    The soft AP is issuing the IP's in the correct range.
    If I run route print the gw is NOT correct.
    Tried Route Add the gw still cant connect to internet.
    Could this still be a DHCP problem by not issuing the gateway IP correctly
    The XP box pings Vista box and visa versa all OK.
    Can't ping AP or from AP

    Have tried the Rouguev3.sh also not working. similar problems but having problems with at0, needs changes

    many thanks again

Page 1 of 3 123 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •