.

First shell script... COMPLETE.

<<

MaXe

User avatar

Hero Member
Hero Member

Posts: 671

Joined: Tue Aug 17, 2010 9:49 am

Post Mon Oct 01, 2012 11:13 pm

Re: First shell script... COMPLETE.

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.
I'm an InterN0T'er
<<

SephStorm

User avatar

Hero Member
Hero Member

Posts: 570

Joined: Sat Apr 17, 2010 12:12 pm

Post Mon Oct 01, 2012 11:38 pm

Re: First shell script... COMPLETE.

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 edited by SephStorm on Tue Oct 02, 2012 12:00 am, edited 1 time in total.
sectestanalysis.blogspot.com/‎
<<

MaXe

User avatar

Hero Member
Hero Member

Posts: 671

Joined: Tue Aug 17, 2010 9:49 am

Post Tue Oct 02, 2012 1:49 am

Re: First shell script... COMPLETE.

Awesome, good to hear you read the manpage and understood everything  ;D 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.  :)
I'm an InterN0T'er
<<

SephStorm

User avatar

Hero Member
Hero Member

Posts: 570

Joined: Sat Apr 17, 2010 12:12 pm

Post Tue Oct 02, 2012 8:38 am

Re: First shell script... COMPLETE.

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?
sectestanalysis.blogspot.com/‎
<<

hayabusa

User avatar

Hero Member
Hero Member

Posts: 1662

Joined: Mon Jan 29, 2007 2:59 pm

Post Tue Oct 02, 2012 11:40 am

Re: First shell script... COMPLETE.

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.)
~ 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
Previous

Return to Programming

Who is online

Users browsing this forum: No registered users and 1 guest

cron
.
Powered by phpBB® Forum Software © phpBB Group.
Designed by ST Software