Skip to content

Instantly share code, notes, and snippets.

View EONRaider's full-sized avatar
💀
Start The World

EONRaider

💀
Start The World
View GitHub Profile
@EONRaider
EONRaider / http_client.rs
Created December 14, 2022 21:08
A simple asynchronous HTTP client in Rust
// [dependencies]
// async-std = { version = "1.7.0", features = ["unstable"]}
// surf = "1.0.0"
pub async fn many_requests(urls: &[String]) -> Vec<Result<String, surf::Exception>> {
let client = surf::Client::new();
let mut handles = vec![];
for url in urls {
let request = client.get(&url).recv_string();
Just a way to host my images...
@EONRaider
EONRaider / ptr_iter.c
Last active December 2, 2021 19:10
Iterating and modifying an array using pointers in C
#include <stdio.h>
#include <stdlib.h>
#define SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
void arr_iter(const short[], short);
void in_place_mod(short[], short, unsigned int);
int main(void) {
short numsArr[] = {1, 2, 3, 4};
@EONRaider
EONRaider / http_get.py
Last active April 2, 2021 18:53
Send a HTTP GET request using socket in Python 3
#!/bin/env/python3
# https://gist.github.com/EONRaider/d6041f6c5845f9b8e726bed33d09c6c6
__author__ = 'EONRaider, keybase.io/eonraider'
from socket import socket
def get_request(hostname: str, path: str = None, port: int = 80,
encoding: str = 'utf_8'):
path = path if path is not None else '/'
@EONRaider
EONRaider / translate_tcp_flags.py
Last active November 7, 2020 12:15
Translate TCP flags from HEX, INT or OCTAL values to text in Python 3
#!/usr/bin/env python3
# https://gist.github.com/EONRaider/35484fc55c643ddbdac7ae55f919419d
__author__ = 'EONRaider, keybase.io/eonraider'
def translate_tcp_flags(flag_code: str, *, base: int):
flag_names = 'NS', 'CWR', 'ECE', 'URG', 'ACK', 'PSH', 'RST', 'SYN', 'FIN'
flag_bits = format(int(flag_code, base=base), '09b')
yield from (flag_name for flag_name, flag_bit in zip(flag_names, flag_bits)
if flag_bit == '1')
@EONRaider
EONRaider / CONKY.md
Last active October 31, 2020 11:07
Configuration file for Conky system monitor
@EONRaider
EONRaider / packet_sniffer.py
Created October 29, 2020 11:27
Sniff TCP/IP packets on a network in Python 3
#!/usr/bin/env python3
# https://gist.github.com/EONRaider/32c5dbf467c786f393bd0e7601246ddf
__author__ = 'EONRaider @ keybase.io/eonraider'
"""
A low-level network sniffer for TCP/IP packets.
"""
import struct
from binascii import hexlify
@EONRaider
EONRaider / icmp_ping.py
Created October 28, 2020 12:32
Execute an ICMP ping scan on a network in Python 3
#!/usr/bin/env python3
# https://gist.github.com/EONRaider/a59d6c4636c1211c7a854c384ddf19a0
__author__ = 'EONRaider, keybase.io/eonraider'
import argparse
import ipaddress
try:
from scapy.all import *
from scapy.layers.inet import ICMP, IP
@EONRaider
EONRaider / interface_info.py
Last active October 24, 2020 11:01
Get the IP, MAC, netmask and broadcast addresses of a network interface in Python 3
#!/usr/bin/env python3
# https://gist.github.com/EONRaider/f2284ccf75613c8751e20062b9e750f3
__author__ = 'EONRaider, keybase.io/eonraider'
try:
import netifaces
except ModuleNotFoundError as e:
raise SystemExit(f"Requires {e.name} module. Run 'pip install {e.name}' "
f"and try again.")
@EONRaider
EONRaider / get_ip_address.py
Last active September 21, 2023 21:36
Get the IP address of a network interface in Python 3
#!/usr/bin/env python3
# https://gist.github.com/EONRaider/3b7a8ca433538dc52b09099c0ea92745
__author__ = 'EONRaider, keybase.io/eonraider'
import fcntl
import socket
import struct
try:
from netifaces import AF_INET, ifaddresses