基于渗透的python
Python for Pentesters
还记得开始学习编程的C,虽然淡忘,但思想仍在。
子域名枚举
request库
import pyfiglet
import requests
import sys
ascii_banner = pyfiglet.figlet_format("ABC-L")
print(ascii_banner)
dir_path = ""
sub_list = open(dir_path, "r").read()
subdoms = sub_list.splitlines()
for sub in subdoms:
sub_domains = f"http://{sub}.{sys.argv[1]}"
try:
requests.get(sub_domains)
except requests.ConnectionError:
pass
else:
print("Valid domain: ",sub_domains)
目录枚举
还是requests
import requests
import sys
import pyfiglet
ascii_banner = pyfiglet.figlet_format("ABC-L")
print(ascii_banner)
path = ''
sub_list = open(path,'r').read()
directories = sub_list.splitlines()
for dir in directories:
dir_enum = f"http://{sys.argv[1]}/{dir}"
r = requests.get(dir_enum)
if r.status_code==404:
pass
else:
print("Valid directory:" ,dir_enum)
网络扫描
from scapy.all import *
import pyfiglet
ascii_banner = pyfiglet.figlet_format("ABC-L")
print(ascii_banner)
interface = "eth0"
ip_range = "10.10.X.X/24"
broadcastMac = "ff:ff:ff:ff:ff:ff"
packet = Ether(dst=broadcastMac)/ARP(pdst = ip_range)
ans, unans = srp(packet, timeout =2, iface=interface, inter=0.1)
for send,receive in ans:
print (receive.sprintf(r"%Ether.src% - %ARP.psrc%"))
端口扫描
socket编程https://www.cnblogs.com/-Lucky-/p/17039661.html
import sys
import socket
import pyfiglet
ascii_banner = pyfiglet.figlet_format("ABC-L")
print(ascii_banner)
ip = sys.argv[1]
open_ports =[]
ports = range(1, 65535)
def probe_port(ip, port):
result = 1
try:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(0.5)
r = sock.connect_ex((ip, port))
if r == 0:
result = r
sock.close()
except Exception as e:
pass
return result
for port in ports:
sys.stdout.flush()
response = probe_port(ip, port)
if response == 0:
open_ports.append(port)
print(f"Open Ports:{open_ports}")
文件下载器
Linux 系统上的 Wget 或 Windows 上的 Certutil 是下载文件的有用工具。
import requests
url = 'https://assets.tryhackme.com/img/THMlogo.png'
r = requests.get(url, allow_redirects=True)
open('THMlogo.png', 'wb').write(r.content)
import requests
url = 'https://download.sysinternals.com/files/PSTools.zip'
r = requests.get(url, allow_redirects=True)
open('PSTools.zip', 'wb').write(r.content)
hash破解
tools:john,hashcat
import hashlib
import pyfiglet
ascii_banner = pyfiglet.figlet_format("ABC-L")
print(ascii_banner)
wordlist_location = str(input('Enter wordlist file location: '))
hash_input = str(input('Enter hash to be cracked: '))
with open(wordlist_location, 'r') as file:
for line in file.readlines():
print(line)
hash_ob = hashlib.md5(line.strip().encode())
hashed_pass = hash_ob.hexdigest()
if hashed_pass == hash_input:
print('Found cleartext password! ' + line.strip())
exit(0)
键盘记录器
import keyboard
keys = keyboard.record(until ='ENTER')
keyboard.play(keys)
ssh暴力破解
tools:hydra
import paramiko
import sys
import os
target = str(input('Please enter target IP address: '))
username = str(input('Please enter username to bruteforce: '))
password_file = str(input('Please enter location of the password file: '))
def ssh_connect(password, code=0):
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
try:
ssh.connect(target, port=22, username=username, password=password)
except paramiko.AuthenticationException:
code = 1
ssh.close()
return code
with open(password_file, 'r') as file:
for line in file.readlines():
password = line.strip()
try:
response = ssh_connect(password)
if response == 0:
print('password found: '+ password)
exit(0)
elif response == 1:
print('no luck')
except Exception as e:
print(e)
pass
input_file.close()
基于渗透的python的更多相关文章
- 基于SQL和PYTHON的数据库数据查询select语句
#xiaodeng#python3#基于SQL和PYTHON的数据库数据查询语句import pymysql #1.基本用法cur.execute("select * from biao&q ...
- DIY一个基于树莓派和Python的无人机视觉跟踪系统
DIY一个基于树莓派和Python的无人机视觉跟踪系统 无人机通过图传将航拍到的图像存储并实时传送回地面站差点儿已经是标配.假设想来点高级的--在无人机上直接处理拍摄的图像并实现自己主动控制要怎么实现 ...
- 基于七牛Python SDK写的一个批量下载脚本
前言 上一篇基于七牛Python SDK写的一个同步脚本所写的脚本只支持上传,不支持文件下载. 虽然这个需求不太强烈,但有可能有人(在备份.迁移时)需要,而官方有没提供对应的工具,所以我就把这个功能也 ...
- 配置基于Vim的Python开发环境
配置基于Vim的Python开发环境插件 Vundle YouCompleteMe NERDTree Vim-Jinja2-Syntax set nocompatible " be iMpr ...
- 基于Appium、Python的自动化测试
基于Appium.Python的自动化测试环境部署和实践 第一章 导言 1.1 编制目的 该文档为选用Appium作为移动设备原生(Native).混合(Hybrid).移动Web(Mobile ...
- 如何在Windows系统上基于Sublime搭建Python的编译环境
刚刚接触到Python,直接在计算机上编译时不能正确的运行,所以将一些有关编译环境调试的知识总结了一下. 环境搭建: Python在 windows系统上编译的时候可能会出现一些编译无法运行的情况,我 ...
- 基于Pycharm的Python开发环境配置
基于Pycharm的Python开发环境配置 编辑于2020-11-18 Python安装 双击桌面的Python3.x安装包. 勾选Add to path. 方便起见,选择Install now.下 ...
- 基于Selenium2与Python自动化测试环境搭建
简介: selenium 是一个web的自动化测试工具,不少学习功能自动化的同学开始首选selenium ,相因为它相比QTP有诸多有点: * 免费,也不用再为破解QTP而大伤脑筋 * 小巧,对于 ...
- 基于esky实现python应用的自动升级
一.esky介绍 Esky is an auto-update framework for frozen Python applications. It provides a simple API t ...
- 基于ELK和Python搭建简单的监控告警系统
Reference: https://www.jianshu.com/p/67e358dc065d 在做完支付系统后,我搭建了两套监控系统. 一套是点评的CAT,主要用于代码级的实时统计和历史统计以及 ...
随机推荐
- 发布新版博客备份功能:生成 sqlite 数据库文件,vscode 插件可查看
大家好,最近我们重新开发了园子的博客备份功能,今天发布第一个预览版,欢迎大家试用. 点击博客后台侧边栏的博客备份进入新版博客备份: 点击创建备份按钮创建博客备份任务(目前每天只能创建一次备份),待备份 ...
- 蓝桥杯十一届JavaA组-C++解题
本人随便乱写,目前正确性未知 C.本质上升序列 #include<bits/stdc++.h> using namespace std; bool access[4][4]; int df ...
- 开发者需掌握的超实用VS Code for Windows快捷键
链接|https://dev.to/devland/100-crucial-keyboard-shortcuts-for-vs-code-users-4474 作者|Thomas Sentre 翻译| ...
- kubectl管理多个集群配置
需求描述:在一台机器上通过kubectl管理多个Kubernetes集群. 操作过程:将各集群的kubectl config文件中的证书内容转换,通过命令创建config文件:通过上下文切换使用不同集 ...
- IO流中「线程」模型总结
目录 一.基础简介 二.同步阻塞 1.模型图解 2.参考案例 三.同步非阻塞 1.模型图解 2.参考案例 四.异步非阻塞 1.模型图解 2.参考案例 五.Reactor模型 1.模型图解 1.1 Re ...
- Java设计模式 —— 原型模式
7 原型模式 7.1 原型模式概述 Prototype Pattern:使用原型实例指定待创建对象的类型,并且通过复制这个原型来创建新的对象. 原型模式的工作原理:将一个原型对象传给创建者,该创建者通 ...
- PyInstaller打包的文件闪退
问题描述:使用PyInstaller打包的pycharm写的python程序,打包好后从windows上打开一直闪退 一.双击exe文件闪退,从cmd命令行中与加载程序,可以看到具体的报错 D:\di ...
- Yii初学者必看-yii 表单验证规则
对yii深入了解总结出:希望对初学者有些帮助 Active Record (AR) 是一个流行的 对象-关系映射 (ORM) 技术. 每个 AR 类代表一个数据表(或视图),数据表(或视图)的列在 A ...
- 【Vue】二
一个第三方js处理类库 BootCDN Vue过滤器 Date.now() 获取时间戳 Date.now() 1652411231222 计算属性实现 <body> <div id= ...
- Kubernetes入门实践(Pods)
为了解决多应用联合运行的问题,同时还要不破坏容器的隔离,就要再对多个容器进行打包.Pod就是对容器的打包,里面的容器可以看成是一个整体,总是能一起调度.一起运行,绝不会出现分离的情况,而Pod属于Ku ...