Image
 
linkedin_logo.png rss_logo.jpg
twitter_logo.png youtube_logo.jpg
Latest Additions
 
EH-Net Login
Welcome Guest.






Lost Password?
No account yet? Register
Who's Online
We have 32 guests and 1 member online
 
Advertisement

You are here: Home arrow Ethical Hacking Discussions and Related Certificationsarrow Programmingarrow First shell script... COMPLETE.
EH-Net
May 18, 2013, 06:40:01 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Go back to The Ethical Hacker Network Online Magazine Home Page
 
   Home   Help Calendar Login Register  
Pages: 1 [2]   Go Down
  Print  
Author Topic: First shell script... COMPLETE.  (Read 5291 times)
0 Members and 1 Guest are viewing this topic.
MaXe
Hero Member
*****
Offline Offline

Posts: 669


I've just upgraded myself to a cyborg muahahaa!!1


View Profile WWW
« Reply #15 on: October 01, 2012, 11:13:27 PM »

Exactly Seph, but you have to define $IP if you are going to use that. $1, $2, $3, $4, etc. are all predefined variables and is the same as sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4], etc. If I am not entirely mistaken.

In PHP you would have to define $IP like:
$IP = sys.argv[1]; // afaik, this may be wrong.
system('clear');
$commandline = "nmap -sP $IP > /pentest/results/scans/$scanname.txt && echo scan complete."
system($commandline);

Now I know this about shell scripting, but since I don't know how to use getopts, even though it's fairly simple as I read the "manual" not long ago, I thought that I would use PHP instead as an example as most programming languages translates universally somewhat.
Logged

I'm an InterN0T'er
SephStorm
Hero Member
*****
Offline Offline

Posts: 530


View Profile WWW
« Reply #16 on: October 01, 2012, 11:38:19 PM »

I read the relevant portion of the man page as suggested, and that helped me understand it. The PHP and sys.argv stuff is still out of reach for the moment.

EDIT: ok, so i changed the script, and executed it, it worked!
« Last Edit: October 02, 2012, 12:00:18 AM by SephStorm » Logged

MaXe
Hero Member
*****
Offline Offline

Posts: 669


I've just upgraded myself to a cyborg muahahaa!!1


View Profile WWW
« Reply #17 on: October 02, 2012, 01:49:24 AM »

Awesome, good to hear you read the manpage and understood everything  Grin It's understandable you don't want to dive into PHP or other scripting or programming languages at the moment, as it is easy to get lost if you dive into too many projects / languages at once.  Smiley
Logged

I'm an InterN0T'er
SephStorm
Hero Member
*****
Offline Offline

Posts: 530


View Profile WWW
« Reply #18 on: October 02, 2012, 08:38:54 AM »

So at this point, i'm feeling pretty good about everything, i've written a total of 3 scripts, one for ping scanning, one for port scanning (though im sure this one will require some manual interaction), and one for banner grabbing using ncat. I cant wait to practice using ncat, I hope to practice some proxying and SSL tunneling maybe?
Logged

hayabusa
Hero Member
*****
Offline Offline

Posts: 1630



View Profile
« Reply #19 on: October 02, 2012, 11:40:34 AM »

Good work.  Now keep going.  There's no end to what you can script up, during a pentest, and more often than not, you don't have tons of time to do it, so practice, practice, practice, and get proficient at it.

Try chaining tools and output together (calling one tool with output from another), reading from input / output files, etc.  Keep building on what you've accomplished, and you'll grow by leaps and bounds.

(And for your own benefit, learn to comment in your scripts, so you can reference them later, if you've forgotten something, or need a quick reminder.)
Logged

~ hayabusa ~ 

"All men can see these tactics whereby I conquer, but what none can see is the strategy out of which victory is evolved." - Sun Tzu, 'The Art of War'


OSCE, OSCP , GPEN, C|EH
Pages: 1 [2]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines
Joomla Bridge by JoomlaHacks.com
Valid XHTML 1.0! Valid CSS!
Page created in 0.084 seconds with 22 queries.
 
Exclusive Deal

sansfire13_245x90_cw90.jpg
SANSFIRE 2013
June 15 - 22

5% Off w/ Code: EHN_5

SANS Deals 4 EH-Netters
5% OFF Any SANS Course in Any Format!
Coupon Code: EHN_5 Including SANS Rocky Mountain 2013 & SANS Boston 2013
Polls
Compared to this year, 2013 will be:
 
Recent Forum Topics
EH-Net News Feeds
Latest Additions
 
         
Free Business and Tech Magazines and eBooks

© 2013 The Ethical Hacker Network
Joomla! is Free Software released under the GNU/GPL License.