This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static InputStream getInputStreamFromApkResource(String apkFilePath, String apkResPath) throws IOException { | |
JarFile jarFile = new JarFile(apkFilePath); | |
JarEntry jarEntry = jarFile.getJarEntry(apkResPath); | |
return jarFile.getInputStream(jarEntry); | |
} | |
// Example usage reading the file "SecureManifest.xml" under "assets" folder: | |
File sdcard = Environment.getExternalStorageDirectory(); | |
File apkFile = new File(sdcard, "file.apk"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.w3c.dom.Document; | |
import javax.xml.parsers.DocumentBuilder; | |
import javax.xml.parsers.DocumentBuilderFactory; | |
import org.xml.sax.InputSource; | |
public static Document loadXMLFromString(String xml) { | |
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); | |
try { | |
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); | |
InputSource inputSource = new InputSource(new StringReader(xml)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LOG_NAME = datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S.log") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# enter in the bash of the first container | |
docker exec -it $(docker ps | head -n 2 | tail -n 1 | cut -d " " -f 1) bash | |
# delete all containers | |
docker ps -a | tail -n +2 | cut -d " " -f 1 | xargs docker rm | |
# delete all images | |
docker images | tail -n +2 | tr -s " " | cut -d " " -f 3 | xargs docker rmi -f |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main (int argc, char *argv[]) | |
{ | |
int i; | |
for(i=0;i<argc;i++) { | |
printf("%d %s\n", i, argv[i]); | |
} | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
while getopts "dte:h?" opt ; do | |
case "$opt" in | |
h|\?) | |
printf "usage: %s -e KEY=VALUE prog [args...]\n" $(basename $0) | |
exit 0 | |
;; | |
t) | |
tty=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import itertools | |
# https://developer.android.com/guide/topics/security/permissions.html#normal-dangerous | |
group_dangerous = { | |
"CALENDAR": {"READ_CALENDAR", "WRITE_CALENDAR"}, | |
"CAMERA": {"CAMERA"}, | |
"CONTACTS": {"READ_CONTACTS", "WRITE_CONTACTS", "GET_ACCOUNTS"}, | |
"LOCATION": {"ACCESS_FINE_LOCATION", "ACCESS_COARSE_LOCATION"}, | |
"MICROPHONE": {"RECORD_AUDIO"}, | |
"PHONE": {"READ_PHONE_STATE", "CALL_PHONE", "READ_CALL_LOG", "WRITE_CALL_LOG", "ADD_VOICEMAIL", "USE_SIP", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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="") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} |
OlderNewer