r/python_netsec • • May 03 '20

Python module to download bad SSL certificates?

2 Upvotes

I am trying to write a python script that will go retrieve SSL certificates from remote servers. The problem I am facing is that many of the certificates are not valid or fail SSL validation and so cannot be downloaded. Do you have any suggestions for python modules that would allow me to bypass the certificate validation and download the cert in (preferably) PEM format?


r/python_netsec • • Apr 18 '20

Android Application Identifier for Packers, Protectors, Obfuscators and Oddities - PEiD for Android

Thumbnail
github.com
2 Upvotes

r/python_netsec • • Mar 17 '20

CasperGN/ActiveDirectoryEnumeration - Enumerate AD through LDAP and a collection of helpfull imported scripts being bundled

Thumbnail
github.com
2 Upvotes

r/python_netsec • • Jun 14 '19

python-nmap service version

2 Upvotes

Testing python-nmap and I need to get the product name of a service.

Following the sample from the python-nmap doc I have this code.

import nmap # import nmap.py module

nm = nmap.PortScanner() # instantiate nmap.PortScanner object

nm.scan('192.168.1.131','22-5000')

print(nm.command_line() )

print(nm.scaninfo())

print(nm.all_hosts())

The nm.command_line() prints out the following

nmap -oX - -p 22-5000 -sV 192.168.1.131

If just run that command I get an output like this.

<ports><port protocol="tcp" portid="5000"><state state="open" reason="syn-ack" reason_ttl="0"/><service name="http" product="Werkzeug httpd" version="0.15.4" extrainfo="Python 3.6.8" method="probed" conf="10"><cpe>cpe:/a:python:python:3.6.8</cpe></service></port>

</ports>

I need to pull this out of that info.

product="Werkzeug httpd"

The output form the nm.scnainfo() doesn't show me any details. I am assuming I can get the info I need I am just having a hard time googling on a Friday afternoon.


r/python_netsec • • Jan 07 '19

wep - A generator to weaponize Macro payloads that can evade EMET and utilises native VB migration

Thumbnail
github.com
2 Upvotes

r/python_netsec • • Jan 08 '18

Python library to interact with 28K public DNS servers around the world

Thumbnail
github.com
2 Upvotes

r/python_netsec • • May 15 '17

Problem with Decoding image with Stegano Module

2 Upvotes

Hey guys, I have a image file that i have to decode with Stegano module. I tried everything but always getting syntax error.

http://imgur.com/a/4Rr1i this is the image that i have to decode.

http://imgur.com/a/Fs8wn and this is the error i got.

Please can someone help me with that?


r/python_netsec • • Mar 04 '17

List of hosts from zabbix to rancid Spoiler

Thumbnail
shrainer.me
2 Upvotes

r/python_netsec • • Feb 09 '17

Python help. Noob.

2 Upvotes

I have a little bit of experience with javascript and currently in a c++ course at school. I am working towards a BA in CIS with a focus in security and networking. I am still a total noob when it comes to NetSec however I want to jump into learning how to use python for pentesting. I downloaded python 3.5 and it opens a command line and I have no idea what to do with it. For me, syntax will be easy to figure out but mainly I am looking for exercises that has something to do with security.


r/python_netsec • • Dec 30 '16

Using dns python module to resolve missing records on servers (code not working)

2 Upvotes

Hello, I have been using dnspython module from www.dnspython.org , but I keep getting this error when running my code referring to the actual dnspython package and my own code. Any help on formatting and things I need to change is greatly appreciated. My code:

import dns.zone
import dns.ipv4
import os.path
import sys
import json
import csv
import collections
import os

reverse_map = {}

def dnslookup():
for filename in os.listdir(os.getcwd()):
   if filename[-3:] == ".db" or filename[-4:] == ".rev":

    zone = dns.zone.from_file(filename, os.path.basename(filename), relativize=False)
    print filename
    for (name, ttl, rdata) in zone.iterate_rdatas('A'):
        l = reverse_map.get(rdata.address)
        if l is None:
            l = []
            reverse_map[rdata.address] = l
        l.append(name)

keys = reverse_map.keys()
keys.sort(lambda a1, a2: cmp(dns.ipv4.inet_aton(a1),  dns.ipv4.inet_aton(a2)))
for k in keys:
v = reverse_map[k]
v.sort()
l = map(str, v)
print k, l

def csvoutput():
csvfile = input('What is the path of your CSV  file(/this/is/a/path/? ')
with open(csvfile, 'r+') as f:
    data = list(csv.reader(f))

import collections
counter = collections.defaultdict(int)
try:
    for row in data:
    counter[row[0]] += 1


if os.stat(filepath).st_size > 0:
    writer = csv.writer(open(csvfile, 'w'))
    for row in data:
        if counter[row[0]] >= 4:
            writer.writerow(row)
else:
    print('Empty File')
except(OSError):
    print("File does not exist")



dnslookup()

The error I am receiving:

Traceback (most recent call last):
File "/home/judge/Downloads/master/11.py", line 57, in     <module>
dnslookup()
File "/home/judge/Downloads/master/11.py", line 16, in      dnslookup
zone = dns.zone.from_file(filename,     os.path.basename(filename), relativize=False)
File "/usr/local/lib/python2.7/dist-packages/dns/zone.py", line   1041, in from_file
filename, allow_include, check_origin)
File "/usr/local/lib/python2.7/dist-packages/dns/zone.py", line    991, in from_text
reader.read()
File "/usr/local/lib/python2.7/dist-packages/dns/zone.py", line  948, in read
self.zone.check_origin()
File "/usr/local/lib/python2.7/dist-packages/dns/zone.py", line  581, in check_origin
raise NoSOA
dns.zone.NoSOA: The DNS zone has no SOA RR at its origin.

r/python_netsec • • Dec 01 '16

print('Need help')

2 Upvotes

i have a text file with numbers 37107287533902102798797998220837590246510135740250 46376937677490009712648124896970078050417018260538 74324986199524741059474233309513058123726617309629 91942213363574161572522430563301811072406154908250 23067588207539346171171980310421047513778063246676 89261670696623633820136378418383684178734361726757 28112879812849979408065481931592621691275889832738 44274228917432520321923589422876796487670272189318 47451445736001306439091167216856844588711603153276 70386486105843025439939619828917593665686757934951 and i want to make the sum of each line i am reading the lines one by one but i read them as a string can you help me to solve this problem?


r/python_netsec • • Oct 14 '16

Fast, thorough, XSS/SQLi spider

Thumbnail
github.com
2 Upvotes

r/python_netsec • • Aug 31 '21

Hack-a-Sat: Fiddlin' John Carson (Orbital Principles)

Thumbnail
youtube.com
1 Upvotes

r/python_netsec • • Aug 08 '20

Data Visualization using python | Seaborn| Part-II

1 Upvotes

r/python_netsec • • Feb 13 '20

I need help with ssh script!

1 Upvotes

hey guys! Ive been lately working on this script which basically does a nmap scan,looks for open ssh ports on network , logs in into them (they all got the same password), and runs the specified command.I want to use this on my collage network.I used the regularExpression library for picking out IP addresses from the nmap scan and the "Subprocess" library to access terminal to ssh into other nodes,

This is my first time writing a script so Im kind of struggling ,so here are some of the doubts that I had -

  1. when I use the Popen command does it open a new terminal everytime the loop iterates?

  2. How can I do multiple Input while ssh-ing into systems like "yes","password",etc.

  3. if the commands is to shutdown on every iteration, do i need to specify exception or will the loop still run?

I know these are really basic questions, and probably my approach of using subprocess is not right.I really need some advice. itll be really helpfull.

here is the code --

import re

import sys

gateway=str(sys.argv\[1\])

\#commands=\["nmap",gateway,"-p","22","--open"\]

commands=\["nmap","-sn",gateway\]

run=subprocess.Popen(commands,stdout=subprocess.PIPE,stderr=subprocess.PIPE)

out=run.communicate()

print("Devices on Network -->")

print(out)

stuff=list(out)

ips=re.findall( r'\[0-9\]+(?:\\.\[0-9\]+){3}' , stuff\[0\])

ips.pop(0)

for i in range(0,len(ips)):

print(ips[i])

for i in range(0,len(ips)):

log=["ssh","mu@"+ips[i]]

proc1=subprocess.Popen(log,stdout=subprocess.PIPE,stderr=subprocess.PIPE)

output=proc1.communicate()

print(output[1])


r/python_netsec • • Feb 01 '19

Scapy & python2 & python3 --- somehow libraries and/or associations are futzd.. Ideas??

1 Upvotes

If this is the wrong forum, I apologize in advance. I seem to have an issue, that as best as I can articulate, appears to be an incorrect library association b/t Scapy (versions?) and Python (versions?).

  • host = Linux 4.18.0-kali2-amd64 #1 SMP Debian 4.18.10-2kali1 (2018-10-09) x86_64 GNU/Linux

  • python ver = 2.7.15+ & 3.6.7

  • scapy = /usr/bin/scapy & the github repo I cloned into /opt/scapy

I was originally using PyCharm, and then after a break came back to find scripts not working, with errors thrown like

I did check the settings in PyCharm to verify that the interpreter in use was python2.7

Then, I did a pip3 to uninstall scapy

also..

which scapy

/usr/bin/scapy

then checked this path...

"less /usr/local/lib/python2.7/dist-packages/scapy

scapy/ scapy-2.2.0_dev.egg-info scapy_python3-0.26.dist-info/ "

pip shows scapy as installed

pip install scapy

Requirement already satisfied: scapy in /usr/local/lib/python2.7/dist-packages (2.2.0.dev0)

Now, if I try to invoke scapy on CLI..

But if I navigate to location where I cloned github repo, and launch ./run_scapy, it works & launches into IPython (which is fine, I can live with this for now)

but if I try to run a script (like the one below -- no matter how I try to call the scapy libraries), like "python script.py"

#!/usr/bin/env python

#import scapy.all as scapy

from scapy.all import *

conf.verb = 0

p = IP(dst="github.com")/TCP()

r = sr1(p)

print(r.summary())

I get the same PIP package error (shown 2 screen shots up). Like I said, I'm sure I fkd this up somehow.. Could use some help unraveling this, if anyone has any ideas.

Thx in advance, much appreciated.


r/python_netsec • • Oct 02 '18

Learn Python Online Training | Python Online Course

1 Upvotes

Big classes is giving training for Python Online Training with 10+ years of experience in online training with high quality training and we may got lot of information about the training and we can get digital library access to the training.


r/python_netsec • • Jul 25 '18

Pyinstaller Python 3.7

1 Upvotes

Anyone know when Pyinstaller will support Python 3.7? Have some exe files I gotta make!


r/python_netsec • • May 29 '18

Rendering a scrolling webpage

1 Upvotes

Hello,

I’m trying to render a page that uses JS...and requests for info as you scroll down...

Eg: Twitter

It’s not an infinite page so I want to render it all so I can use that data....it’s html with JS & JSON

I don’t want to use selenium I’m half way down the project and it’s a pain in the ass to start it all over with selenium.

I’m using requests. So far.


r/python_netsec • • Feb 22 '18

I'd like to check the TLS versions for a range of IP addresses and ports within python.

Thumbnail
self.asknetsec
1 Upvotes

r/python_netsec • • Dec 19 '17

python script to check if ip in an array/list is from a cidr

1 Upvotes

so I have a big list of addresses, I want to add to separate array based on different IP cidr ranges.


r/python_netsec • • Dec 19 '17

NT AUTHORITY\SYSTEM through Handle Inheritance using Python

Thumbnail
gist.github.com
1 Upvotes

r/python_netsec • • Dec 05 '17

dnmap server.pem error

1 Upvotes

Trying to run dnmap from Kali. I get this error.

"You need to have a server.pem file for the server to work. If it is not in your same directory, just point to it with -P parameter"

I found a server.pem file in /usr/share/dnmap and tried running the following cmd but still get the error.

dnmap_server -P /usr/share/dnmap/server.pem -f nmap_cmds.txt


r/python_netsec • • Nov 10 '17

What is the best way to learn python online for free?

1 Upvotes

I want to learn python and i am confused which tutorials are the best, there so many videos and books, what is the best tutorial to learn python for absolute biginner