Forked from apfelchips/ghidra_processor_docs_downloader.py
Last active
December 9, 2022 19:22
-
-
Save sprout42/ae6121236d8dd89eb478b631c4333abb to your computer and use it in GitHub Desktop.
Ghidra Processor Documentation Downloader
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
#!/usr/bin/env python3 | |
# vim: tabstop=4:softtabstop=4:shiftwidth=4:expandtab: | |
import os | |
import sys | |
import requests | |
docs = { | |
'68000': { | |
'M68000PRM.pdf': 'https://www.nxp.com/files-static/archives/doc/ref_manual/M68000PRM.pdf', | |
}, | |
'8051': { | |
'8xc251sx_um.pdf': 'https://www.keil.com/dd/docs/datashts/intel/8xc251sx_um.pdf', | |
}, | |
'ARM': { | |
'Armv7AR_errata.pdf': 'https://www.cs.utexas.edu/~simon/378/resources/ARMv7-AR_TRM.pdf', | |
}, | |
'AARCH64': { | |
'DDI0487G_b_armv8_arm.pdf': 'https://documentation-service.arm.com/static/611fa684674a052ae36c7c91?token=' | |
}, | |
'Atmel': { | |
'doc32000.pdf': 'https://ww1.microchip.com/downloads/en/devicedoc/doc32000.pdf', | |
}, | |
'CR16': { | |
'cr16.pdf': 'https://pubweb.eng.utah.edu/~cs3710/handouts/cr16.pdf', | |
'prog16c.pdf': 'https://doc-0s-4s-docs.googleusercontent.com/docs/securesc/ha0ro937gcuc7l7deffksulhg5h7mbp1/tgcekhm1ilon5d6gp5v5c09mepm3b9fa/1551938400000/14157490643402214266/*/1QOkOiMNmoH_D0JEk62R4B4MdFhZR0il7?e=download', | |
}, | |
'JVM': { | |
'jvms8.pdf': 'https://docs.oracle.com/javase/specs/jvms/se8/jvms8.pdf', | |
}, | |
'MIPS': { | |
'mips64v2.pdf': 'https://www.ece.lsu.edu/ee4720/mips64v2.pdf', | |
'MD00076-2B-MIPS1632-AFP-02.63.pdf': 'https://s3-eu-west-1.amazonaws.com/downloads-mips/documents/MD00076-2B-MIPS1632-AFP-02.63.pdf', | |
'MD00087-2B-MIPS64BIS-AFP-06.03.pdf': 'https://s3-eu-west-1.amazonaws.com/downloads-mips/documents/MD00087-2B-MIPS64BIS-AFP-06.03.pdf', | |
'MD00582-2B-microMIPS32-AFP-05.03.pdf': 'https://github.com/f47h3r/firmware_reversing/raw/master/docs/research/MD00582-2B-microMIPS32-AFP-05.03.pdf', | |
'MD00582-2B-microMIPS32-AFP-05.04.pdf': 'https://s3-eu-west-1.amazonaws.com/downloads-mips/documents/MD00582-2B-microMIPS32-AFP-05.04.pdf', | |
'MD000594-2B-microMIPS64-AFP-06.02.pdf': 'https://s3-eu-west-1.amazonaws.com/downloads-mips/documents/MD000594-2B-microMIPS64-AFP-06.02.pdf', | |
'r4000.pdf': 'https://web.archive.org/web/20170830040648if_/http://www.pitt.edu/~kmram/CoE0147/reading/R4400_Uman_book_Ed2.pdf', | |
}, | |
'PA-RISC': { | |
'pa11_acd.pdf': 'https://web.archive.org/web/20120205012512if_/http://ftp.parisc-linux.org/docs/arch/pa11_acd.pdf', | |
}, | |
'PIC': { | |
'PIC12_40139e.pdf': 'https://ww1.microchip.com/downloads/en/devicedoc/40139e.pdf', | |
'PIC17F_40001761E.pdf': 'https://ww1.microchip.com/downloads/en/DeviceDoc/40001761E.pdf', | |
'PIC16_33023a.pdf': 'https://ww1.microchip.com/downloads/en/devicedoc/33023a.pdf', | |
'PIC17_30289b.pdf': 'https://ww1.microchip.com/downloads/en/devicedoc/30289b.pdf', | |
'PIC18_14702.pdf': 'https://www.farnell.com/datasheets/22241.pdf', | |
'PIC24_70157D.pdf': 'https://ww1.microchip.com/downloads/en/DeviceDoc/70157D.pdf', | |
}, | |
'PowerPC': { | |
'POWERISA_V2.06_PUBLIC.pdf': 'http://kib.kiev.ua/x86docs/POWER/PowerISA_V2.06B_V2_PUBLIC.pdf', | |
'PowerISA_V2.07B.pdf': 'http://kib.kiev.ua/x86docs/POWER/PowerISA_V2.07B.pdf', | |
'PowerISA_V3.0.pdf': 'http://kib.kiev.ua/x86docs/POWER/PowerISA_V3.0.pdf', | |
'powerpc.pdf': 'https://wiki.alcf.anl.gov/images/f/fb/PowerPC_-_Assembly_-_IBM_Programming_Environment_2.3.pdf', | |
'altivec.pdf': 'https://web.archive.org/web/20131106030811if_/http://dec8.info/Apple/macos8pdfs/CD_MacOS_8_9_X_4D_Omnis/Apple/MPC7450/ALTIVECPEM.pdf', | |
}, | |
'Sparc': { | |
'SPARCV9.pdf': 'https://cr.yp.to/2005-590/sparcv9.pdf', | |
}, | |
'TI_MSP430': { | |
# 'MSP430.pdf': 'https://e2echina.ti.com/cfs-file/__key/telligent-evolution-components-attachments/00-55-01-00-00-00-61-61/MSP430x2xx-Family-User_26002300_39_3B00_s-Guide-_2800_Rev.-E_2900_.pdf', # Rev. E | |
'MSP430.pdf': 'https://www.ti.com/lit/ug/slau144j/slau144j.pdf', # Rev. J | |
}, | |
'x86': { | |
'Intel64_IA32_SoftwareDevelopersManual_vol2a.pdf': 'https://web.archive.org/web/20190828163311if_/http://kib.kiev.ua:80/x86docs/SDMs/253666-029.pdf', | |
'Intel64_IA32_SoftwareDevelopersManual_vol2b.pdf': 'https://web.archive.org/web/20190514122822if_/http://kib.kiev.ua/x86docs/SDMs/253667-029.pdf', | |
'AMD64_ProgrammersManual_vol3.pdf': 'https://web.archive.org/web/20210109233328if_/https://www.amd.com/system/files/TechDocs/24594.pdf', | |
'AMD64_ProgrammersManual_vol4.pdf': 'https://web.archive.org/web/20190822172034if_/https://www.amd.com/system/files/TechDocs/26568.pdf', | |
'AMD64_ProgrammersManual_vol5.pdf': 'https://web.archive.org/web/20210321040716if_/https://www.amd.com/system/files/TechDocs/26569_APM_V5.pdf', | |
'AMD64_128-bit_SSE5_Instructions.pdf': 'https://web.archive.org/web/20190315070432if_/https://www.amd.com/system/files/TechDocs/43479.pdf', | |
'325383-sdm-vol-2abcd.pdf': 'https://software.intel.com/content/dam/develop/public/us/en/documents/325383-sdm-vol-2abcd.pdf', | |
}, | |
'Z80': { | |
'UM0050.pdf': 'https://www.zilog.com/force_download.php?filepath=YUhSMGNEb3ZMM2QzZHk1NmFXeHZaeTVqYjIwdlpHOWpjeTk2TVRnd0wzVnRNREExTUM1d1pHWT0=', | |
'UM0080.pdf': 'https://www.zilog.com/force_download.php?filepath=YUhSMGNEb3ZMM2QzZHk1NmFXeHZaeTVqYjIwdlpHOWpjeTk2T0RBdlZVMHdNRGd3TG5Ca1pnPT0=', | |
} | |
} | |
if (len(sys.argv[1:]) == 0 or len(sys.argv[1:]) > 2 or sys.argv[1] == '-h'): | |
print("Usage: </path/to/ghidra>\n".format(os.path.basename(__file__))) | |
exit(1) | |
elif (len(sys.argv)): | |
os.chdir(sys.argv[1]) | |
headers = {'User-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36'} | |
for platform in docs: | |
destdir = 'Ghidra/Processors/{}/data/manuals'.format(platform) | |
if not os.path.exists(destdir): | |
os.makedirs(destdir) | |
for proc_doc in docs[platform]: | |
destfile = '{}/{}'.format(destdir, proc_doc) | |
print("{}:".format(destfile), end=' ') | |
if not os.path.exists(destfile): | |
web_src = docs[platform][proc_doc] | |
if web_src is None: | |
print('no docs :-/') | |
continue | |
print("download {}:".format(web_src), end=' ') | |
try: | |
resp = requests.get(web_src, stream=True, headers=headers) | |
if resp.ok: | |
with open(destfile, 'wb') as fd: | |
for chunk in resp.iter_content(chunk_size=16384): | |
if not chunk: | |
break | |
fd.write(chunk) | |
print("OK!") | |
else: | |
print("Failed! ({})".format(resp.status_code)) | |
except requests.exceptions.ConnectionError: | |
print('HTTP Exception :-<') | |
else: | |
print("exists") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment