Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to create a SimFile and use SimSymbolicMemory? #2311

Closed
JustAhmed opened this issue Aug 27, 2020 · 4 comments
Closed

How to create a SimFile and use SimSymbolicMemory? #2311

JustAhmed opened this issue Aug 27, 2020 · 4 comments

Comments

@JustAhmed
Copy link


Greetings!
So, i was going through some CTF challenges with angr and came across that one
it seems pretty straight forward to me but when i ran the script for the first time i got the following error:

password_file = angr.storage.SimFile(filename, 'rb', content=symbolic_file_backing_memory, size=symbolic_file_size_bytes) TypeError: __init__() got multiple values for argument 'content'

after researching the problem i found out that removing 'rb' from the parameters should solve the problem. Running the script again generated a different error but this time i can't figure it out. The error is:
File "solve.py", line 91, in main
password_file = angr.storage.SimFile(filename, content=symbolic_file_backing_memory, size=symbolic_file_size_bytes)
File "/home/user1/Angr/lib/python3.8/site-packages/angr/storage/file.py", line 179, in __init__
raise TypeError("Can't handle SimFile content of type %s" % type(content))
TypeError: Can't handle SimFile content of type <class 'angr.state_plugins.symbolic_memory.SimSymbolicMemory'>

I thought it may be related to the fact that i'm using python3, but i can't confirm that since anger is no longer supported for pytho2 so i'm kinda stuck at this point. Can i get a hint on how to solve/wrok around this porblem?
Many thanks for the awesome framework btw

@rhelmot
Copy link
Member

rhelmot commented Sep 2, 2020

angr_ctf is extremely outdated, as you may have guessed. these days, the correct way to instanciate a SimFile is not to create a SimSymbolicMemory (which as of a few days ago doesn't even exist anymore) but rather to just directly pass password as the content argument.

@JustAhmed
Copy link
Author

Thank you for the reply. I actually tried passing password as the argument for content as well and the script ran with no errors but gave me no solution then, i found that the mapping between (the file name and where it should appear on the file system) and the angr.storage.SimFiles should be changed from:
symbolic_filesystem = { filename : password_file }
initial_state.posix.fs = symbolic_filesystem

To:
initial_state.fs.insert(filename, password_file)

that change did the trick for me

@rhelmot
Copy link
Member

rhelmot commented Sep 3, 2020

the best way to do this is in fact to pass fs={filename: password_file} to the state constructor.

@JustAhmed
Copy link
Author

Yep. just gave it a try and it works. Thank you very much for your help and support!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants