Jump to content


Photo
- - - - -

a happy couple


  • Please log in to reply
2 replies to this topic

#1 frogbong

frogbong

    mad 1337

  • Members
  • 134 posts
  • Country:
  • Gender:Male

Posted 02 June 2011 - 05:20 AM

I found these useful, I hope you do as well. Making these helped me learn some basic but useful things about bash, linux and python.
#!/bin/bash
##
### netmon.sh - use nmap to watch local network for active hosts
## Note: don't forget to set 'NETWORK' to your subnet
#
export NETWORK="10.0.1."

# Cleanup 
function cancel() {
  echo ""
  echo "deleting /tmp/netmon.tmp.."; rm -f /tmp/netmon.tmp
  echo "killing all instances of nmap.."; killall -g nmap
  echo "killing all instances of netmon.sh.."; killall -g netmon.sh
}

# Make sure to catch ctrl-c for cleanup routine
trap cancel SIGINT

# Check if nmap is installed 
if [ -f `which nmap` ]
  then
    touch /tmp/netmon.tmp
    while true; do nmap -sP $NETWORK*|grep $NETWORK > /tmp/netmon.tmp; sleep 30; done &
    while true; do clear; echo "Local Network: "; cat /tmp/netmon.tmp; sleep 7; done
  else
    # If nmap is not installed tell the user and quit
    echo "nmap not found: install nmap and run again" && exit
fi
#!/usr/bin/python
##
### getip.py - get external ip from ipchicken.com
##
#
import httplib

conn = httplib.HTTPConnection("ipchicken.com")
conn.request("GET", "/")
resp = conn.getresponse()

if resp.status != 200:
	print resp.status, resp.reason
	exit()
elif resp.status == 200:
	output = resp.read()
	output = output[output.find('<font face="Verdana, Arial, Helvetica, sans-serif" size="5" color="#0000FF"><b>'): 
		output.find('<A HREF="javascript:makeLink()"><font size="2">')]
	output = output.strip('font face="Verdana, Arial, Helvetica, sans-serif" size="5" color="#0000FF"><b>')
	output = output.strip()
	output = output.strip('<br>')
	print output
else: 
	print resp.status, resp.reason
	exit()


#2 Outis

Outis

    I broke 10 posts and all I got was this lousy title!

  • Members
  • 15 posts
  • Country:
  • Gender:Male

Posted 28 June 2011 - 11:33 AM

The first script is pretty cool.

But, for the second one, it might have been easier to pull the IP from http://www.whatismyip.org
No formatting to strip

Edited by Outis, 28 June 2011 - 11:34 AM.


#3 frogbong

frogbong

    mad 1337

  • Members
  • 134 posts
  • Country:
  • Gender:Male

Posted 28 June 2011 - 08:53 PM

wow that makes life easy, but I'm definitely glad I learned how to format output.




BinRev is hosted by the great people at Lunarpages!