{"id":18023721,"url":"https://github.com/katrix/scarlet","last_synced_at":"2025-03-27T00:30:45.334Z","repository":{"id":83323390,"uuid":"299140021","full_name":"Katrix/Scarlet","owner":"Katrix","description":"A work in progress Scala decompiler","archived":false,"fork":false,"pushed_at":"2023-12-16T21:39:13.000Z","size":8725,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-22T17:44:14.641Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Katrix.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-09-27T23:43:17.000Z","updated_at":"2024-08-28T14:39:49.000Z","dependencies_parsed_at":null,"dependency_job_id":"d49d1fbc-78ee-463a-a2e2-58ad63e01ec4","html_url":"https://github.com/Katrix/Scarlet","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Katrix%2FScarlet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Katrix%2FScarlet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Katrix%2FScarlet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Katrix%2FScarlet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Katrix","download_url":"https://codeload.github.com/Katrix/Scarlet/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245760559,"owners_count":20667886,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-30T07:10:28.937Z","updated_at":"2025-03-27T00:30:44.435Z","avatar_url":"https://github.com/Katrix.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Scarlet\nA work in progress Scala decompiler and reverse engineering tool/library. \nThere isn't much interesting stuff happening here yet. Come back later and maybe I've gotten further with this.\n\n## Usage\n```bash\njava -jar scarlet.jar \u003cinput-file\u003e [language]\n```\n\nThe language specifies how far to parse and process the classfiles. \nMost will likely not be useful. \n\nThe more common ones that you will probably normally use are:\n* `scala-2.11`: TODO\n* `scala-2.12`: TODO\n* `scala-2.13`: TODO\n* `scala-3`: TODO\n* `java`: TODO\n\nThe complete list is.\n* `raw-classfile`: \n  Reads the classfile without resolving any references in the \n  constant pool or any other further processing.\n* `classfile`: \n  Reads the classfile, resolves some references, but nothing more.\n* `raw-bytecode`: \n  Parses the bytecode of the methods, but does not resolve references to the \n  constant pool, or do any other processing.\n* `bytecode`: \n  Reads the bytecode of the methods, resolves references to the constant pool, \n  and removes specialization.\n* `sir`: \n  Scarlet's first IR. A stackless IR, close to but not exactly the same \n  as bytecode. Based on the IR from this \n  [paper](http://people.irisa.fr/David.Pichardie/papers/aplas10.pdf)\n* `sir-syntax`: \n  Same as `sir`, but prints it in a more readable format, looking more \n  like normal code.\n* `sir-classsyntax`: \n  Same syntax as `sir-syntax` but also transforms the class around the \n  methods to Scala code.\n* `sir-cfg`: \n  GraphViz format with SIR organized by control flow graph.\n* `sir-cfg-syntax`: \n  GraphViz format file with SIR syntax organized by control flow graph.\n* `sir-cfg-classsyntax`: \n  Same syntax as `sir-cfg-syntax` but also transforms the class around the \n  methods to Scala code.\n\n## Stuff that still needs to be done\n* [x] Parse classfiles\n* [x] Parse OPCode\n* [x] Remove the stack\n* [x] Construct CFGs\n* [ ] Structuring\n* [ ] Try-Catch stuff\n* [ ] Lambdas\n* [ ] Rewrite statements to expressions where it makes sense\n* [ ] Rewrite match expressions ending with `MatchError`\n* [ ] Rewrite match expressions not ending with `MatchError`\n* [ ] Recover lost generics types using type inference\n* [ ] Recover top level lazy vals\n* [ ] Recover method level lazy vals\n* [ ] Inline most values produced by the decompilation process\n* [ ] Remove most unit values\n* [ ] Recover traits original form where they can hold arbitrary code\n* [ ] Group seperate classes that belong together in one file\n\n## Goals\nThe end goal for Scarlet is to be able to decompile Java and Scala code and \nreturn a high level representation of the bytecode. This includes recovering \ninformation not present in the bytecode like generics and more advanced types \nlike existentials, dependant and higher kinded types.\n\nIt should be able to do this both with and without the information provided by \nextra attributes found in the classfile.\n\n## Where does the name come from?\nNowhere really, but if you really want an explanation, let's go with \nSCAla Reverse Language Engineering Tool.\n\n## References\nhttps://docs.oracle.com/javase/specs/jvms/se8/html/jvms-2.html  \nhttps://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html  \nhttps://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html  \nhttps://www.ndss-symposium.org/ndss2015/ndss-2015-programme/no-more-gotos-decompilation-using-pattern-independent-control-flow-structuring-and-semantics/  \nhttps://www.backerstreet.com/decompiler/frameless_functions.php  \nhttps://www.researchgate.net/publication/2645337_Analyzing_Control_Flow_in_Java_Bytecode  \nhttp://people.irisa.fr/David.Pichardie/papers/aplas10.pdf\nhttps://eli.thegreenplace.net/2015/directed-graph-traversal-orderings-and-applications-to-data-flow-analysis/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkatrix%2Fscarlet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkatrix%2Fscarlet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkatrix%2Fscarlet/lists"}