Skip to content

Instantly share code, notes, and snippets.

View tosiara's full-sized avatar

tosiara

View GitHub Profile
@tosiara
tosiara / threads.c
Created October 27, 2019 18:17
threads.c
#include <pthread.h>
#include <stdlib.h>
void *payload()
{
while (1);
}
void main(int argc, char **argv)
{
[1:ml1:MyCam1] [NTC] [ALL] motion_init: Camera 101 started: motion detection Enabled
[1:ml1:MyCam1] [NTC] [VID] vid_start: Opening V4L2 device
[1:ml1:MyCam1] [NTC] [VID] v4l2_device_open: Using videodevice /dev/video0 and input -1
[1:ml1:MyCam1] [ALR] [VID] v4l2_device_open: Failed to open video device /dev/video0: No such file or directory
[1:ml1:MyCam1] [ERR] [VID] vid_start: V4L2 device failed to open
[1:ml1:MyCam1] [WRN] [ALL] motion_init: Could not fetch initial image from camera
[1:ml1:MyCam1] [WRN] [ALL] motion_init: Motion continues using width and height from config file(s)
[1:ml1:MyCam1] [NTC] [ALL] image_ring_resize: Resizing pre_capture buffer to 1 items
[1:ml1:MyCam1] [NTC] [DBL] dbse_init: Database backend mysql
[1:ml1:MyCam1] [ERR] [DBL] dbse_init_mysql: Cannot connect to MySQL database motion on host localhost with user motion

On host:

sudo apt-get install libnss3-tools
hg clone https://hg.mozilla.org/mozilla-central
cd mozilla-central
nss-addbuiltin -n "SomeMaliciousCA" -t "CT,C,C" < ~/malicious.der >> security/nss/lib/ckfw/builtins/certdata.txt
sudo docker run -v "/mozilla-central:/mozilla-central" -ti ubuntu:focal /bin/bash

Inside docker:

@tosiara
tosiara / hashtopolis_fix.php
Last active June 15, 2021 15:00
Hashtopolis hack script to workaround DB resource limitation
<?php
/*
This script is a temporary hack to overcome Hashtopolis DB resource limitation.
Original thread: https://github.com/hashtopolis/server/issues/644
Script location: https://gist.github.com/tosiara/a0c4ebfb2e0707fc1920cf204f6cde0f
tl;dr: when a task has too many chunks in the table, apache will fetch them all
and process in a loop in order to calculate task progress - this will cause
@tosiara
tosiara / rename_jpegs_by_exif_date
Created August 20, 2021 10:37
Rename jpeg photo by its exif date
for i in *; do mv $i `exif $i 2> /dev/null | grep Date | grep Orig | awk '{ print $4 }' | awk -F '|' '{ print $2 }' | tr ':' '-'`_.jpg; done
@tosiara
tosiara / ruby_wtf.rb
Created October 11, 2021 09:53
Ruby WTF
def a; end
def b; end
puts "Before patching:"
print a
print b
a = {}
b {}
@tosiara
tosiara / openwrt_login_curl.md
Last active October 20, 2021 09:52
OpenWRT login curl

Login using curl:

curl -sw '%{http_code}' -o /dev/null -X POST -F "luci_username=root" -F "luci_password=root" http://192.168.1.1/cgi-bin/luci

The result will be 403 if the password is incorrect, or 302 in case of success

The session cookie looks like:

@tosiara
tosiara / android-wireguard-tools.md
Last active October 21, 2022 12:04
Cross compile wireguard-tools for Android
  1. Install NDK (side by side)
  2. Add NDK compiler to the PATH (select architecture accordingly, ex, x86_64):
export PATH=$PATH:/home/Android/Sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64/bin
export CC=x86_64-linux-android27-clang
  1. cd wireguard-tools/src
  2. make
@tosiara
tosiara / valgrind_motion_fuzz_no_crash.md
Created December 10, 2021 10:55
motion valgrind report
==227091== 
==227091== HEAP SUMMARY:
==227091==     in use at exit: 179,801,253 bytes in 116,355 blocks
==227091==   total heap usage: 16,254,781 allocs, 16,138,453 frees, 117,125,828,652 bytes allocated
==227091== 
==227091== Thread 1:
==227091== 12 bytes in 3 blocks are possibly lost in loss record 13 of 326
==227091==    at 0x483DD99: calloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==227091==    by 0x13D021: mymalloc (util.c:180)
@tosiara
tosiara / valgrind_motion_fuzz_double_free.md
Created December 13, 2021 07:59
motion valgrind report (double free)
==401159== Memcheck, a memory error detector
==401159== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==401159== Using Valgrind-3.19.0.GIT and LibVEX; rerun with -h for copyright info
==401159== Command: /home/user/git/motion/src/motion -c /home/user/git/motion-fuzzing.conf -n -d 7
==401159== 
[0:memcheck-amd64-] [NTC] [ALL] conf_load: Processing thread 0 - config file /home/user/git/motion-fuzzing.conf
[0:memcheck-amd64-] [NTC] [ALL] motion_startup: Logging to file (/dev/null)
==401159== Thread 4 ml1:
==401159== Invalid free() / delete / delete[] / realloc()