Skip to content

Instantly share code, notes, and snippets.

@ppoffice
ppoffice / README.md
Last active April 21, 2024 01:33
Install Visual Studio Code (actually code-server) on Android
  1. Install Termux, an Android terminal emulator that provides a Linux execution environment and various tools.

  2. Update system packages in Termux:

    $ pkg update -y
@ppoffice
ppoffice / xstartup
Last active April 5, 2024 04:03
VNC xstartup for Ubuntu Desktop (Gnome)
#!/bin/sh
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
vncconfig -iconic &
export DESKTOP_SESSION=/usr/share/xsessions/ubuntu.desktop
export XDG_CURRENT_DESKTOP=ubuntu:GNOME
export GNOME_SHELL_SESSION_MODE=ubuntu
export XDG_DATA_DIRS=/usr/share/ubuntu:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop
dbus-launch --exit-with-session /usr/bin/gnome-session --systemd --session=ubuntu
@ppoffice
ppoffice / README.md
Last active April 2, 2024 08:58
A step by step guide to upgrade webview on an old Android Emulator

Tools

  1. emulator (30.3.5) (via Android SDK)
  2. adb (30.0.5) (via Android SDK)
  3. apktool (2.5.0) and Java runtime
  4. zip (3.0)
  5. unzip (6.0)

Make sure you have JAVA_HOME and ANDROID_HOME environment variables correctly set.

@ppoffice
ppoffice / asn1.py
Last active December 19, 2023 18:13
Textbook/RAW RSA & RSA with OAEP+SHA1+MGF1 Python Implementation
from typing import Tuple
import pyasn1.codec.der.encoder
import pyasn1.type.univ
import base64
import rsa
def private_key_pem(n: int, e: int, d: int, p: int, q: int, dP: int, dQ: int, qInv: int) -> str:
'''Create a private key PEM file
@ppoffice
ppoffice / 01_Android_LXC_Note.md
Last active September 11, 2023 00:55
LXC for Android 9.0.0 r18 Goldfish

Steps to build Android kernel and system for LXC:

  1. Download Android SDK, NDK, system and kernel source code;
  2. Download modified lxc and libcap source code (ppoffiec/lxc-android, ppoffice/libcap-android)
  3. Build Android system from source first so that we can link to its shared library when we build lxc (or maybe we don't have to);
  4. Modify Android kernel config and make sure lxc-checkconfig does not report any missing features. Then build kernel;
  5. Modify Android system/core/rootdir/init.rc according to init.rc.diff. Make sure you mount all the cgroup subsystems needed (cpu, cpuacct, cpuset, memory, pids, devices, freezer, blkio) under /sys/fs/cgruop, otherwise lxc won't find them;
  6. Rebuilt the Android system image so that the modified init.rc is in the image;
  7. Fire up the emulator with custom kernel (emulator -kernel kernel-file-path) and use adb shell and dmesg to check if everything is doing ok.
@ppoffice
ppoffice / main.sh
Last active March 14, 2023 23:44
LG Nexus 5 Ubuntu Xfce4 Desktop with X11 fbdev and evdev
# recompile kernel first with patch:
# https://github.com/postmarketOS/pmbootstrap/blob/4b10acc2535033414cd4f358433a51626096d7ce/aports/device/linux-lg-hammerhead/06_fix_mdss_fb_rgb_mode.patch
git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.8 \
-b marshmallow-mr1-release \
~/arm-eabi-4.8
git clone https://android.googlesource.com/kernel/msm \
-b android-msm-hammerhead-3.4-marshmallow-mr1 \
~/msm
git clone https://github.com/osm0sis/mkbootimg.git ~/mkbootimg
cd ~/msm
@ppoffice
ppoffice / build.sh
Last active March 14, 2023 23:44
Minimal Linux Build Script
#!/bin/sh
# Modified from ivandavidov/minimal-linux-script
# https://github.com/ivandavidov/minimal-linux-script
# This script includes a dynamic linked busybox, openssl, python and
# network support
set -ex
KERNEL_VERSION=4.17.2
BUSYBOX_VERSION=1.28.4
# Get Pre-reqs
apt-get install libattr1-dev git unzip make gcc automake pkg-config
# Get Android NDK
cd /root
mkdir -p build && cd build
wget http://dl.google.com/android/repository/android-ndk-r10e-linux-x86_64.zip -O /tmp/android-ndk-r10e-linux-x86_64.zip
unzip /tmp/android-ndk-r10e-linux-x86_64.zip -d /root/build
# Set paths
@ppoffice
ppoffice / backup.sh
Last active September 2, 2022 19:20
Backup Linux using tar
#!/bin/bash
cd /
tar -cvpzf backup.tar.gz \
--exclude=/backup.tar.gz \
--exclude=/proc \
--exclude=/tmp \
--exclude=/mnt \
--exclude=/dev \
--exclude=/sys \
--exclude=/run \
@ppoffice
ppoffice / README.md
Last active October 2, 2021 16:28
How to setup a Mirai testbed

Overview

  • CNC Server: 192.168.1.12:23 (cnc.local:23)
  • Report Server: 192.168.1.12:48101 (cnc.local:48101)
  • Loader Server: 192.168.1.13
  • Bot Binary Host: http://192.168.1.13:80/bins/mirai.*

Hosts Setup

Router