
Hek

A python library mostly used for pentesting and automation some tasks.
Hek library is not near to be completed It's under constant updates.
Installation.
pip install hek
System.
Get device current username.
import hek
user = hek.system.username()
print(user)
Request device os name.
import hek
os_name = hek.system.oname()
print(os_name)
Download content.
You could not add any path and It'll extract the file name from the url.
from hek import system
path = "dog.jpg"
url = "https://example/dog_picure.jpg"
result = system.download_content(url=url, path=path)
print(result)
System - process.
kill process
You could change the name argument to process pid like (pid="1234"), also you could disable kill with force using force=False.
import hek
name = "chrome.exe"
res = hek.system.process.kill_process(name=name)
print(res)
Get process PID by process name.
from hek import system
name = "chrome.exe"
name = system.process.getnamebypid(name=pid)
print(name)
Get process name by PID.
from hek import system
pid = "2779"
name = system.process.getnamebypid(pid=pid)
print(name)
Proxy usages.
Doing http request using tor proxy
With this way you can do all kinds of requests like post/get/options, before using the function you need to setup and run tor bundle you could download it from tor official site
import hek
tor_session = hek.tor.get_session()
result = tor_session.get("http://httpbin.org/ip").text
print(result)
You may add your host/proxy manually using this way, Identity is your proxy location contain some other info.
import hek
host = "127.0.0.1:9050"
session = hek.tor.get_session(host=host)
identity = session.identity(host=host)
print(identity)
This code result your proxy identity.
Simple function to check if proxy is working.
import hek
result = hek.proxy.checkproxy(
url="https://github.com/",
user_agent="Mozilla/5.0",
proxy="185.61.94.65:61616"
)
if "Working" in result:
print("Alive proxy")
It'll return Working if It's alive end exception if not
Ip stuff.
Code to grab site ip address.
import hek
url = "github.com"
ip = hek.ipstuff.siteip(url)
print(ip)
Code to check if opened port.
import hek
ip = "192.168.0.1"
port = 80
result = hek.ipstuff.portscan(ip=ip, port=port, timeout=3)
if result == True:
print("Opened port.")
elif result == False:
print("Closed port.")
Checking if device SSH by device ip.
import hek
ip = "192.168.0.1"
result = hek.ipstuff.checkssh(ip)
if result == True:
print("is ssh")
elif result == False:
print("isn't ssh")
Simple code to check if device is rdp by device ip address.
import hek
ip = "192.168.0.1"
result = hek.ipstuff.checkrdp(ip)
if result == True:
print("is rdp")
elif result == False:
print("isn't rdp")
Simple code to check if ip does exist or not.
import hek
ip = "192.168.0.1"
result = hek.ipstuff.checkip(ip)
if result == True:
print("ip exist")
elif result == False:
print("ip doesn't exist")
It'll return True is exist and False if not.
Get public ip.
import hek
ip = hek.ipstuff.myip(find="query")
print(ip)
you could get your ip information by removing find="query" also you can change query and get other info about your ip.
Server.
Check if server port is open.
import hek
ip = "192.168.0.1"
port = 80
result = hek.server.portscan(ip=ip, port=port)
print(result)
Retrieve server banner.
import hek
ip = "192.168.0.1"
port = 430
result = hek.server.get_banner(address=ip, port=port)
print(result)
server.set_socket.
server.set_socket is a static way like a session that you only need to add the server info once to start sending and receiving data, unlike server.socket which is not static at all.
Connect to a server.
import hek
ip = "192.168.0.1"
port = 80
server = hek.server.set_socket(host=ip, port=port)
r = server.connect()
print(f"connected: {r}")
Send packet to a server.
import hek
ip = "192.168.0.1"
port = 80
server = hek.server.set_socket(host=ip, port=port)
r = server.connect()
print(f"connected: {r}")
packet = "hi im packet"
result = server.sendpacket()
print(result)
Receive data from a server.
data = server.recv(bufsize=1048)
print(data)
Close connection.
server.close()
server.socket.
server.socket unlike set_socket It's unstatic better to work with it while using multiple socket's and multithreading.
Create a socket.
from hek import server
server = server.socket()
sock = server.socket()
connect to a server.
result = server.connect(sock, host="192.168.0.1", port=80)
print(result)
send packet.
packet = "im a packet"
result = server.sendpacket(sock, packet=packet, host="192.168.0.1", port=80)
print(result)
Receive data.
server.recv(sock, bufsize=1048)
Close connection.
server.close(sock)
Network and trafficking.
Sniff and monitor any device traffic on your network.
import hek, threading
def sniff():
hek.network.arp.start_arp(
interface="wlan0",
router="192.168.0.1",
device="192.168.0.112"
)
def monitor_traffic():
hek.wireshark.monitor_device(
interface="wlan0",
device="192.168.0.112"
)
threading.Thread(target=monitor_traffic).start()
threading.Thread(target=sniff).start()
You can use this if you just want to sniff device traffic without needing to open wireshark.
import hek
def sniff():
hek.network.arp.start_arp(
interface="wlan0",
router="192.168.0.1",
device="192.168.0.112"
)
sniff()
Connect to wifi using hek library.
This function is for linux also requires wifi adapter.
import hek
result = hek.wifi.connect(ssid="Wifi ssid/Name",
password="wifi-password"
)
print(result)
Start monitor mode.
This function for linux.
import hek
result = hek.net.monitor_start(name="wlan0")
print(result)
Stop monitor mode.
This function for linux.
import hek
result = hek.net.monitor_stop(name="wlan0mon")
print(result)
Recording , videos, images stuff.
While recording a video you could display your choice of fps like fps=30 or 60 or higher.
import hek
data = hek.Image.extracexif(filename="hek.jpg")
print(data)
Screen shot.
import hek
hek.screen.screenshot(filename="test.png")
Webcam picture.
import hek
hek.webcam.webcamshot(filename="test.png")
Screen video capture.
import hek
hek.screen.capture_video(filename="filename.avi", seconds=5)
Webcam video capture.
import hek
hek.webcam.capture_video(filename="webname.avi", seconds=3)
This program uses MIT license.