Skip to content
This repository was archived by the owner on Aug 22, 2025. It is now read-only.

Conversation

@sharon-lin
Copy link
Contributor

No description provided.

@RylanOC RylanOC self-requested a review January 6, 2019 22:54
Copy link
Contributor

@RylanOC RylanOC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like you accidentally pushed an mcore_... directory in exploit_generation_example. Aside from that, your script looks good to me!

@CLAassistant
Copy link

CLAassistant commented Jan 7, 2019

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ sharon-lin
❌ sharontlin
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Contributor

@RylanOC RylanOC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

If our password passes all of the checks, we can return it as the flag.
"""
with m.locked_context() as context:
print("[+] success. flag: BugsBunny{" + str(context['password']) + "}")
Copy link
Member

@disconnect3d disconnect3d Jan 7, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is more readable if we use proper string formatting instead of concatenating strings. In Python, there are three ways for that currently:

  • % operator for string, e.g.: 'some int: %d' % some_int - note, that if you want to format more than one thing you need to pass a collection e.g. 'some int: %d and string: %s' % (some_int, some_str)
  • str.format method e.g.: 'some int: {} some str: {}'.format(some_int, some_str)
  • f-strings: f'some int: {some_int} some str: {some_str}'

The % operator and .format methods are old ways to format strings. You can learn more about them on https://pyformat.info/. The f-string is a Literal String Interpolation added to Python 3.6 proposed in PEP-498.

I'd go for changing it to f-strings since we use them in Manticore anyway (and so we require Python>=3.6):

Suggested change
print("[+] success. flag: BugsBunny{" + str(context['password']) + "}")
print(f"[+] success. flag: BugsBunny{{context['password']}}")

PS: It is possible to accept this change on github PR page.

"""
with m.locked_context() as context:
print("[+] injecting password: " + str(format(context['password'], '020')))
state.cpu.write_bytes(state.cpu.RDI,str(format(context['password'],'020')))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The format function returns a string so we don't need to use str. Also, since we use the value twice, can we assign it to a variable? e.g. formatted_pwd = f"{context['password']:020}"?

return to the original point of injection.
"""
with m.locked_context() as context:
if (len(str(context['password'])) == 20):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (len(str(context['password'])) == 20):
if len(str(context['password'])) == 20:

Copy link
Member

@disconnect3d disconnect3d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see suggestions

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants