Skip to content

Instantly share code, notes, and snippets.

@sdtm1016
sdtm1016 / recover_source_code.md
Created March 13, 2017 04:55 — forked from simonw/recover_source_code.md
How to recover lost Python source code if it's still resident in-memory

How to recover lost Python source code if it's still resident in-memory

I screwed up using git ("git checkout --" on the wrong file) and managed to delete the code I had just written... but it was still running in a process in a docker container. Here's how I got it back, using https://pypi.python.org/pypi/pyrasite/ and https://pypi.python.org/pypi/uncompyle6

Attach a shell to the docker container

Install GDB (needed by pyrasite)

apt-get update && apt-get install gdb
@sdtm1016
sdtm1016 / Base File.sublime-settings
Created March 9, 2016 05:18 — forked from ufologist/Base File.sublime-settings
Sublime Text User Preferences -- Eclipse shortcuts for Sublime Text
{
"alignment_chars" : ["=", ":"]
}

cat

For pupil: all binary can be downloaded http://pan.baidu.com/s/1hqH2Pko

After overwriting, maybe need to run chmod +x /path/to/sublime_text. For linux default installation, need to add sudo.

For programmer:

VERSION PLATFORM OFFSET ORIGINAL CRACKED
$ pgrep java
3464
$ clhsdb
hsdb> attach 3464
Attaching to process 3464, please wait...
hsdb> jsload objtree.js
hsdb> objtree 0xc99f6378
Oop for java/util/HashSet @ 0x00000000c99f6378 (size of 16)
_mark: 5
map: Oop for java/util/HashMap @ 0x00000000c99f6388 (size of 48)
public class HelloWorld {
private static int foo() {
return 42;
}
private static void bar() {
}
public static void main(String[] args) throws Exception {
foo();
import java.io.*;
import java.util.*;
import sun.jvm.hotspot.memory.*;
import sun.jvm.hotspot.oops.*;
import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.runtime.*;
import sun.jvm.hotspot.tools.*;
import sun.jvm.hotspot.utilities.*;
public class DirectMemorySize extends Tool {
import java.io.*;
import java.util.*;
import sun.jvm.hotspot.memory.*;
import sun.jvm.hotspot.oops.*;
import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.runtime.*;
import sun.jvm.hotspot.tools.*;
public class DumpClassURL extends Tool {
public void run() {