Skip to content

Instantly share code, notes, and snippets.

View ppmx's full-sized avatar
🇺🇦

mx ppmx

🇺🇦
  • Europe
View GitHub Profile
@ppmx
ppmx / expression.py
Created May 6, 2018 15:32
rough logic bug in python
#!/usr/bin/env python3
class Expression:
OPERATORS = ['+', '-']
@staticmethod
def parse(expression):
# If it is a leaf-expression return even a leaf:
if len(expression) == 1:
return Expression(int(expression[0]), None, None)
@ppmx
ppmx / expression-fixed.py
Created May 6, 2018 18:56
Fix for logic bug in expression code
#!/usr/bin/env python3
class Expression:
OPERATORS = ['+', '-']
@staticmethod
def parse(expression):
# If it is a leaf-expression return even a leaf:
if len(expression) == 1:
return Expression(int(expression[0]), None, None)
@ppmx
ppmx / strtok
Created August 29, 2018 13:57
just an example how to use strtok
/* % ./a.out "hello, world. this is an example" ".,"
* hello
* world
* this is an example
*/
#include <stdio.h>
#include <string.h>
int main(int argc, char **argv)
@ppmx
ppmx / anti-debugging.c
Created October 30, 2018 11:25
illustrates a simple anti debugging technique
#include <stdio.h>
#include <stdlib.h>
#include <sys/ptrace.h>
void anti_debugging(void) __attribute__ ((constructor));
void run_evil_code();
void anti_debugging(void)
{
// if we are not traced:
@ppmx
ppmx / gist:10dcd0804503affb92584e03718d17d6
Created December 2, 2018 21:45
sys_getdents filename extraction
#include <dirent.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <unistd.h>
struct linux_dirent {
unsigned long d_ino;
@ppmx
ppmx / shellcode loader
Created December 4, 2018 15:09
x86-64 shellcode to read another shellcode from stdin and execute it
BITS 64
; syscall:
;
; ptr = mmap(NULL, size, PROT_EXEC | PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0)
;
;
; arguments:
;
@ppmx
ppmx / list_profiles.sh
Created February 3, 2020 22:30
List Names of Chromium Profiles
ls .config/chromium | grep -E "^Profile [0-9]*$" | while read x; do echo "$x: $(cat .config/chromium/$x/Preferences | jq '. | .profile.name')"; done
@ppmx
ppmx / test_adapter.py
Last active February 17, 2020 14:25
Example for a Test Adapter
class MathClass:
def sqrt(self, x):
import math
return math.sqrt(x)
class TestAdapterMathClass(MathClass):
def sqrt(self, x):
self.assert (x >= 0)
ret = super().sqrt(x)
@ppmx
ppmx / s.md
Created October 11, 2022 21:45 — forked from zfarbp/s.md
Trigger Spotify with osascript

Trigger Spotify with osascript

/Applications/Spotify.app/Contents/Resources/Spotify.sdef

# read-only
osascript -e 'tell application "Spotify" to player state'                  # stopped,playing,paused
osascript -e 'tell application "Spotify" to current track'                 # The current playing track.
osascript -e 'tell application "Spotify" to artwork of current track'      # Image data in TIFF format.
osascript -e 'tell application "Spotify" to artist of current track'       # The artist of the track.