Remote Exploit Forums

Go Back   Remote Exploit Forums > Specialist Topics > Programming


Programming A place for our community to discuss their own security related coding projects.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-01-2009, 02:23 AM
Junior Member
 
Join Date: Mar 2009
Posts: 5
Default Some simple shell scripts

First off, I know its not programming, it's scripting, but I'm learning so cut me some slack.

Anyway, I've got four scripts I'd like to share. These are working on BackTrack 4 beta, haven't had a chance to compare with 4 prerelease, but I'm sure it can be adapted. I use these in specific with an Atheros based chipset (as they are for athX madwifi VAPs). To use these scripts, simply open Kate and copy the code, save to correct dir, then use console to
Code:
root@bt:~# chmod 1777 /usr/sbin/xxxx-sc.sh
for each script. After this has been done, these scripts can be run from konsole root as xxxx-sc-sh. Makes things convienent.

I also use an array in my script, utilizing both monitor + connectivity modes on ath0 and ath1. Ath0 is designated as the monitor, and ath1 is used for connect. The only trick with this script is that the card's modes are bound together by channel, so if you connect on channel 6 you can only monitor on channel 6. If you are monitoring and channel hopping, you will have a hard time associating.
/usr/sbin/dual-sc.sh
Code:
killall wpa_supplicant
killall NetworkManger
killall knetworkmanager
airmon-ng stop ath0
airmon-ng stop ath1
ifconfig wifi0 down
macchanger --mac 00:10:24:00:13:37
ifconfig wifi0 up
airmon-ng start wifi0
wlanconfig ath1 create wlandev wifi0 wlanmode sta -uniquebssid
NetworkManager start
knetworkmanager
This one sets the wifi card in to strictly monitor/passive mode.
/usr/sbin/mon-sc.sh
Code:
airmon-ng stop ath0
airmon-ng stop ath1
killall wpa_supplicant
killall NetworkManager
killall knetworkmanager
ifconfig wifi0 down
macchanger --mac 00:11:22:33:44:55 wifi0
ifconfig wifi0 up
airmon-ng start wifi0
airodump-ng ath0
This sets the wifi card into strictly internet/connectivity mode.
/usr/sbin/con-sc.sh
Code:
airmon-ng stop ath0
airmon-ng stop ath1
ifconfig wifi0 down
macchanger --mac 00:10:24:00:13:37 wifi0
ifconfig wifi0 up
wlanconfig ath0 create wlandev wifi0 wlanmode sta -uniquebssid
NetworkManager start
knetworkmanager
Finally, to flush all wifi connections into the "down" mode.
/usr/sbin/netdown-sc.sh
Code:
killall wpa_supplicant
killall NetworkManger
killall knetworkmanager
airmon-ng stop ath0
airmon-ng stop ath1
Any criticism or comments welcome! Lemme know what you guys think.
Reply With Quote
  #2 (permalink)  
Old 07-01-2009, 04:50 AM
SuspectZero's Avatar
Senior Member
 
Join Date: Dec 2008
Posts: 269
Default

if you want to learn some more. you should try to use the "read" command. this allows for input from the user. for example:


print "what is ur adapter called? example: wlan0, ath0, etc"
read $adapter
airmon-ng start $adapter

in this case $adapter == what ever the user enters as the adapter name.
btw my syntax might be wrong as im not in linux right now and havent scripted in bash for a little bit. but the basic idea is there. :P
__________________
Until they become conscious they will never rebel, and until after they have rebelled they cannot become conscious...
Reply With Quote
  #3 (permalink)  
Old 07-01-2009, 11:06 AM
Member
 
Join Date: May 2009
Posts: 99
Default

Quote:
Originally Posted by vaeldious View Post
First off, I know its not programming, it's scripting, but I'm learning so cut me some slack.
If you will add variables, functions, conditional statements and loops in your script would you still call it just scripting? I wonder what's really the difference. Isn't it a program is some sequential instructions you write for the computer to execute, regardless if you have to compile the it beforehand or just to be read by an interpreter later? When you wrote a very nice shell script that executes various programs and process their output, would you still call yourself a script kiddie? Aren't these shells also considered as programming languages?
Reply With Quote
  #4 (permalink)  
Old 07-01-2009, 01:44 PM
Virchanza's Avatar
Senior Member
 
Join Date: Sep 2008
Location: I am not living
Posts: 728
Default

I judge any sort of programming or scripting language on three things:

1) How much stuff you can do with it (e.g. can you read and write files, can you take input from the user, can you perform looping)
2) How portable it is (e.g. can you write a program that will run on M$Windoze, Mac, Solaris, Linux)
3) The quality of the "executable" file, how small it is in kilobytes, and how quickly it runs.

There's no doubt that you can do some pretty neat stuff with Bash Script, some people have made some marvelous programs with it.

The people who are extremely proficient at Bash Scripting would do very well at full-blown languages like C and C++, I suppose it's just a matter of time before they decide to move on. Bash is great, but you can do a lot more with the likes of C and C++. C++ is pretty much the best language to use (in terms of the 3 criteria I specify above) unless you're looking for extreme portability, in which case C would be the right choice. (By extreme portability, I mean stuff like compiling code for microcontrollers the size of the nail on your baby finger).
__________________
Ask questions on the open forums, that way everybody benefits from the solution, and everybody can be corrected when they make mistakes. Don't send me private messages asking questions that should be asked on the open forums, I won't respond. I decline all "Friend Requests".
Reply With Quote
  #5 (permalink)  
Old 10-31-2009, 05:11 AM
Junior Member
 
Join Date: Mar 2009
Posts: 5
Default

Wrote a couple more. Here's some backtrack universal scanning scripts...once more, add to /usr/sbin/xxx.sh then from shell do "chmod 1777 /usr/sbin/xxx.sh"...then you will be able to run direct from shell as xxx.sh

Makes automated scanning easier :P
longscan.sh
Code:
echo "**************************"
echo "**  Mr Penguin's Long   **"
echo "** Range Artillery Scan **"
echo "**************************"
echo "Scans ..X-Y.1-255 of input IP, with specified port."
echo "Builds output, then opens."
echo "Scan which port/s?"
read port
echo "IP Block 1:"
read block1
echo "IP Block 2:"
read block2
echo "IP Block 3 Start:"
read block3a
echo "IP Block 3 End:"
read block3b

while [ $block3a -le $block3b ]
do
	nmap -p $port $block1.$block2.$block3a.1-255 -oG /root/longscan.txt --append-output
	block3a=$(( block3a+1 ))
done

nano /root/longscan.txt
shortscan.sh
Code:
echo "***********************"
echo "** Mr Penguin's Auto **"
echo "** Full IPBlock Scan **"
echo "***********************"
echo "Scans input of first three IP blocks with nmap, with input of port."
echo "Builds output, then opens."
echo "Input first three IP Blocks, Seperated by space"
read ip1 ip2 ip3 
echo "Port, please"
read port
nmap -v -p $port $ip1.$ip2.$ip3.1-255 -oG /root/open.txt --append-output 
nano /root/open.txt
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 09:42 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2