r/Python • • Mar 07 '17

CIA uses Python (a lot)

From the latest Vault 7 leaks from Wikileaks, we can see that CIA uses a lot of Python in its secret hacking tools.

Most notably in the Assassin, Caterpillar, MagicViking and Hornet projects.

Unfortunatelly, no files from these projects have been released yet. But if you look at the dump that was released, there are plenty of .py files, and even PIL is included.

There are even Coding Conventions: https://wikileaks.org/ciav7p1/cms/page_26607631.html

You can see more Python-related stuff here: https://search.wikileaks.org/?query=python&exact_phrase=&any_of=&exclude_words=&document_date_start=&document_date_end=&released_date_start=&released_date_end=&publication_type%5B%5D=51&new_search=False&order_by=most_relevant#results

1.1k Upvotes

220 comments sorted by

View all comments

126

u/dr_g89 Mar 07 '17

If you read through some of the files there are some cool libraries they are referencing. Has anyone used angr before?

57

u/tunisia3507 Mar 07 '17

I've read the readme three times and still don't know what it's for.

97

u/dr_g89 Mar 07 '17

By reading this, you'll become an angr pro and will be able to fold binaries to your whim

If i understand what I've read correctly this is a tool for picking apart and experimenting with existing compiled binaries. My guess is to probe for exploits.

61

u/david5813 Mar 07 '17

It is. If I remember correctly the Shellphish team has given a talk at either Defcon or BlackHat about this. A part of their research is being able to perform a completely automated CTF where the systems identify vulnerabilities and even patch them on the fly.

It is a really cool topic and when I get back to a position to be able to search for it I will happily post a link a talk about it if no one else has already.

Edit: https://www.youtube.com/watch?v=oznsT-ptAbk

You can find more info on their site. http://angr.io/

16

u/hugthemachines Mar 07 '17

Tfw someone told you to do a talk for a certain time and you only have half that and fill 50% with "aaaaaa" ;-)

2

u/flutefreak7 Mar 13 '17

Besides exploits there's also the intelligence aspect of trying to figure out what a binary does. Say you recovered a performance model for a weapon, radar, communications system, etc, if all you have is the binary it could be hard to get it working, but tools like this would help.

8

u/sillycyco Mar 08 '17

I've read the readme three times and still don't know what it's for.

angr is similar to debugging tools you may have used, but entirely within python. Full decomposition of logic, and allowing for analysis of code at a much lower level. Aka scan for exploitable functionality in existing binary code, among other things. Pretty slick actually.

→ More replies (2)

0

u/[deleted] Mar 07 '17

[deleted]

13

u/ebilgenius Mar 07 '17

Took me a minute

3

u/jarins Mar 08 '17

Still don't get it.

42

u/Jesus_Harold_Christ Mar 08 '17

If your username was "I_DONT_NOTICE_USERNAMES" this thread would have been perfect

→ More replies (1)

17

u/cdrootrmdashrfstar Mar 08 '17 edited Mar 08 '17

I'm currently enrolled in an undergrad practical fundamentals of cybersecurity course at my uni, and last week, we used angr to script what we'd normally use gdb for in what's called a "capture the flag" assignment.

The creator of the binary will hide away a specific string, like "flag{th1s_1$_th3_fl4g}", purposefully deep within the binary and only obtainable (normally) through some modification to the execution order of the binary.

Originally, we learned to use the GNU debugger GDB for many weeks of CTF assignments, but last week we used Angr to script a way to explore many, many paths of execution in a program. Through adding constraints to inputs and explicting marking some parts of the binary as "avoid", angr would eventually navigate it's way to the end of execution (and hopefully result in a flag!) through some sort of either statistical model (maybe similar to sqlmap?) or through simply brute forcing all possible routes of execution. It's a very complex tool with lots of depth, and I've only really scratched the surface.

We might be doing more of this in the later weeks, but this week moving onto forensics, buffer overflow attacks, shellcode, and circumventing stack protections by compilers. In relation to python, we're using a library called pwntools (in addition to the obvious and incredibly useful set of tools provided by Linux and GNU).

7

u/dr_g89 Mar 08 '17

I'm going to look into pwntools. Where do you go to Uni if you don't mind me asking

7

u/cdrootrmdashrfstar Mar 08 '17

I'm a sophomore at a state school in the southeast US. It's a decent school (it sure has taught me a whole lot in a short amount of time), and we have a great offensive cybersecurity program which very often leads to jobs in places like the CIA, NSA, or the FBI.

3

u/dr_g89 Mar 08 '17

Super interesting man. I run the dev side of a software firm out in LA and have always been way to busy to spend too much time looking into this stuff. If you have a spare second I'd love to know what books on the this stuff they are having you read at school.

13

u/cdrootrmdashrfstar Mar 08 '17 edited Mar 09 '17

Recommended reading: “Hacking: The Art of Exploitation, 2nd Edition” by Jon Erickson: this is a book with accurate and detailed descriptions and commands of common vulnerabilities and corresponding exploits. It is an excellent book for understanding buffer overflow vulnerabilities, string format vulnerabilities, and shellcode, and other exploitation development.

“The Web Application Hacker's Handbook: Finding and Exploiting Security Flaws” by Dafydd Stuttard and Marcus Pinto. The book provides a comprehensive and thorough coverage of web security mechanisms, and web vulnerabilities.

“Information Security,” 2nd Edition, (ISBN 978-0-470-62639-9), Wiley, 2011, by Mark Stamp. The book provides a good coverage on commonly used cryptographic algorithms and cryptanalysis techniques, and security protocols.

Edit: Thank you so much for the gold! It's very much appreciated.

3

u/dr_g89 Mar 08 '17

Dude thanks a ton, especially on the lectures / course stuff, super interesting!

2

u/cdrootrmdashrfstar Mar 08 '17

Absolutely, let me know if you have any questions.

→ More replies (11)
→ More replies (2)

2

u/cdrootrmdashrfstar Mar 08 '17

Here is our course calendar page containing homework assignments and presentations covering the information we learn in lecture.

→ More replies (1)

11

u/[deleted] Mar 08 '17

Christ I hope whoever wrote this library puts it in his CV. "Developed a library used by the CIA"

5

u/k10_ftw Mar 08 '17

Might as well post his work to his personal github account

4

u/dr_g89 Mar 08 '17

Some of the other comments on this thread led me to discover it came out of the cybersecurity lab at UCSB. One of the authors is apparently a local high schooler from their community.

3

u/ifatree Mar 08 '17

interesting. are DART, UNDERMINE, PALANTIR, or TYBASE familiar names to any of you guys?

2

u/ssiwhw Mar 08 '17

3

u/HelperBot_ Mar 08 '17

Non-Mobile link: https://en.wikipedia.org/wiki/Palantir_Technologies


HelperBot v1.1 /r/HelperBot_ I am a bot. Please message /u/swim1929 with any feedback and/or hate. Counter: 40912