Tag Archives: scanner

Ruby – Simple Port Scanner

0
Filed under ruby
Tagged as , , , , , , , , , ,

Author: slac3dork
Site: http://snippet.c0de.me
Summary: Simple Port Scanner Using Ruby. Tested on Linux. Thanks to someone who’s inspired me to create this script. I forget the name my inspirator, sorry.
Usage: ruby port_scanner.rb <target> <startPort> <endPort>

#!/usb/bin/ruby

#  _________      .__       .____   _______
# /   _____/ ____ |__|_____ |    |  \   _  \    ____
# \_____  \ /    \|  \____ \|    |  /  /_\  \  / ___\
# /        \   |  \  |  |_> >    |__\  \_/   \/ /_/  >
#/_______  /___|  /__|   __/|_______ \_____  /\___  /
#        \/     \/   |__|           \/     \//_____/
# http://snippet.c0de.me
# slac3dork[at]gmail[dot]com
#
require 'socket'
require 'timeout'

class Scanner
  def Scanning(host, startPort, endPort)
    print "\nScanning ", host, "\n"
    for port in startPort..endPort
      begin
        s = TCPSocket.open(host, port)
        Timeout::timeout(1){s}
      rescue
        else
  	print "Port ",port,": Open\n"
  	s.close
      end
    end
  end
end

class Msg
  def hello
    puts "-------------------------------------"
    puts "Simple Port Scanner using Ruby"
    puts "Author: slac3dork"
    puts "I don't know who gives me inspiration to create this script"
    puts "-------------------------------------"
  end
end

if ARGV.length != 3
  puts "\nUsage: ruby port_scanner.rb <target> <startPort> <endPort>"
  exit(1)
end

target = ARGV[0]
startPort = ARGV[1].to_i
endPort = ARGV[2].to_i

host = Scanner.new
host.Scanning(target, startPort, endPort)




ruby,code,code,snippet

Python – Directory Scanner

0
Filed under python
Tagged as , , , , , , , ,

Author: slac3dork
Site: http://snippet.c0de.me
Summary: Python script to scan directory. Tested on Linux.
Usage: python dirscanner.py <YOUR_DIR>

#!/usr/bin/python
#
#  _________      .__       .____   _______
# /   _____/ ____ |__|_____ |    |  \   _  \    ____
# \_____  \ /    \|  \____ \|    |  /  /_\  \  / ___\
# /        \   |  \  |  |_> >    |__\  \_/   \/ /_/  >
#/_______  /___|  /__|   __/|_______ \_____  /\___  /
#        \/     \/   |__|           \/     \//_____/
# http://snippet.c0de.me
# slac3dork[at]gmail[dot]com  

from os import walk
from sys import argv

def scanning(dir):
        for rootdir, dirs, files in walk(dir):
                for file in files:
                        print rootdir+"/"+file

if __name__ == "__main__":
        if len(argv) != 2:
                print "Usage: python dirscanner.py <YOUR_DIR>"
                exit()
        dir_name = argv[1]
        scanning(dir_name)



python,logo,banner

Python – Simple Port Scanner

0
Filed under python
Tagged as , , , , ,

Author: slac3dork
site: http://snippet.c0de.me/
summary: A simple multi-threading port scanner tool using python. Tested on Linux
Usage: ./portScanner.py <target≶ <startport> <endport>

#!/usr/bin/python

#  _________      .__       .____   _______
# /   _____/ ____ |__|_____ |    |  \   _  \    ____
# \_____  \ /    \|  \____ \|    |  /  /_\  \  / ___\
# /        \   |  \  |  |_> >    |__\  \_/   \/ /_/  >
#/_______  /___|  /__|   __/|_______ \_____  /\___  /
#        \/     \/   |__|           \/     \//_____/
# http://snippet.c0de.me
# slac3dork@gmail.com

import sys
import socket
import threading

class Scanner(threading.Thread):
	def __init__(self, host, port):
		threading.Thread.__init__(self)
		self.host = host
		self.port = port
		self.status = ""

	def run(self):
		self.sk = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
		self.sk.settimeout(0.03)
		try:
			self.sk.connect((self.host, self.port))
		except:
			pass
		else:
			self.status = "open"
			self.sk.close()

def error():
	print "Usage: ./portScanner.py <target> <startport> <endport>"

def welcomeMsg():
	print "---------------------------------------------"
	print " portScanner.py - A Simple Port Scanner Tool"
	print " coded by slac3dork"
	print "---------------------------------------------"

if (__name__ == "__main__"):
	if (len(sys.argv) != 4):
		error()
	else:
		welcomeMsg()

		target = sys.argv[1]
		startPort = int(sys.argv[2])
		endPort = int(sys.argv[3])
		threads = []
		for port in range(startPort, endPort):
			thread = Scanner(target, port)
			threads.append(thread)
			thread.start()

		print "Target = ", target

		for thread in threads:
			if (thread.status == "open"):
				print "Port", thread.port, " : ", thread.status

python,logo,banner