Skip to content

Instantly share code, notes, and snippets.

@kmark
kmark / XHookGms.java
Last active January 14, 2024 13:42
Hooking into any class in Google Play Services
package com.versobit.kmark.gist;
import android.app.Application;
import android.content.Context;
import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.callbacks.XC_LoadPackage;
import static de.robv.android.xposed.XposedHelpers.findAndHookMethod;
@kmark
kmark / AndroidClasspath.java
Last active January 14, 2024 13:41
Explores the current Android classpath
try {
PathClassLoader pcl = (PathClassLoader) Thread.currentThread().getContextClassLoader();
Field f = Class.forName("dalvik.system.BaseDexClassLoader").getDeclaredField("pathList");
f.setAccessible(true);
Object dpl = f.get(pcl);
Class cls = Class.forName("dalvik.system.DexPathList");
Field f2 = cls.getDeclaredField("dexElements");
f2.setAccessible(true);
Object[] elements = (Object[])f2.get(dpl);
for(Object e : elements) {
@kmark
kmark / TabsAdapter.java
Created September 3, 2013 00:42
An extensible FragmentPagerAdapter that supports both FragmentActivity and Fragment hosts.
package you.should.change.this;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.view.ViewGroup;
@kmark
kmark / AudioRecordActivity.java
Last active January 4, 2024 11:01
An example of how to read in raw PCM data from Android's AudioRecord API (microphone input, for instance) and output it to a valid WAV file. Tested on API 21/23 on Android and API 23 on Android Wear (modified activity) where AudioRecord is the only available audio recording API. MediaRecorder doesn't work. Compiles against min API 15 and probabl…
/*
* Copyright 2016 Kevin Mark
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@kmark
kmark / pi_bashrc.sh
Last active October 6, 2023 15:31
Modified RetroPie bashrc for general Raspberry Pi use.
# MODIFIED RETROPIE PROFILE START
# Source: https://github.com/RetroPie/RetroPie-Setup/blob/cc1f125c8f79d68b2d9393d21d992a7440b09085/scriptmodules/supplementary/bashwelcometweak.sh
function getIPAddress() {
local ip_route
ip_route=$(ip -4 route get 8.8.8.8 2>/dev/null)
if [[ -z "$ip_route" ]]; then
ip_route=$(ip -6 route get 2001:4860:4860::8888 2>/dev/null)
fi
[[ -n "$ip_route" ]] && grep -oP "src \K[^\s]+" <<< "$ip_route"
@kmark
kmark / LogMeIn.php
Last active July 16, 2023 06:31
PHP implementation of cPanel's Perl LogMeIn class.
<?php
namespace cPanel;
/**************************************************************************************
* Copyright (c) 2013, cPanel, Inc. *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without modification, *
* are permitted provided that the following conditions are met: *
* *
@kmark
kmark / plexDownloadMulti.sh
Created September 24, 2013 01:12
Super simple bash script to repeatedly execute plexDownload.php with the same encoding settings but different media IDs. Great for TV show seasons.
#!/bin/bash
# Copyright 2013 Kevin Mark
# Licensed under the Apache License, Version 2.0
# Will expand upon this script to be more convient, proof of concept right now.
# EXAMPLE USAGE: ./plexDownloadMulti.sh "-h 127.0.0.1:32400 -r 720x480 -b 800" 123 456 789
# Universal encoding settings in quotes is the first param. Space-seperated mediaIds are the rest
# Change the "folderformedia" and make sure it exists. Change the extension too if you want.
@kmark
kmark / de64.php
Created August 15, 2014 21:14
Recursively removes the base64 "encryption" on some obfuscated PHP files. First and only CLI parameter is the path to the encoded file.
<?php
/* Works on targets that are in this format:
* <?php $FirstVar = 'base64here'; $SecondVar = '$ThirdVar = base64_decode($FirstVar); eval($ThirdVar);'; eval($SecondVar); ?>
* Where the result of the base64_decode is more PHP that follows the above format.
*/
$target = $argc < 2 ? "" : $argv[1];
if($target === "" || !file_exists($target)) {
@kmark
kmark / plexDownload.php
Last active April 6, 2022 23:46
The Plex Universal Transcoder Downloader mimics the actions of the Plex/Web media flash player to download transcoded media. The differences begin when the downloader saves the streamed data and pieces it together. First a start.m3u8 playlist file is requested from the server with a query string that defines the transcoding options. Inside the …
<?php
/*******************************************************************************
* Plex Universal Transcoder Downloader v1.3 *
* See --help or --usage for more info *
*******************************************************************************
* Copyright 2013 Kevin Mark *
* *
* Licensed under the Apache License, Version 2.0 (the "License"); *
* you may not use this file except in compliance with the License. *
* You may obtain a copy of the License at *
<?php
// Quick script to get some not-cryptographically-secure random data
// to stdout in a portable way. Useful for generating uncompressable
// test files
define("INTS_PER_LOOP", 4096);
$f = str_repeat("l", INTS_PER_LOOP);
$r = []; // Using SplFixedArray is actually slower