question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Help solving an exercise

See original GitHub issue

Hi all, suppose I have this C code:

#include<stdlib.h>
int main(int argc, char *argv[]) {
	int a = atoi(argv[1]);
	a = a - 10;
	int b = a + 1;
	if ( b > 3 )
	    malloc(b);
}

Once compiled the call to malloc is at 0x00000000004005a6

With angr I would like to obtain the min value for argv1 if I have the malloc to be called. The solution should be 13 but I cannot have that result. My code is the following:

import angr

def main():
	proj = angr.Project('./example', load_options={"auto_load_libs": False})
	argv1 = angr.claripy.BVS("argv1", 64)
	initial_state = proj.factory.entry_state(args=["./example", argv1]) 

	initial_path = proj.factory.path(initial_state)
	path_group = proj.factory.path_group(initial_state)
	path_group.explore(find=0x00000000004005a6)
	found = path_group.found[0]
	print found.state.se.min(argv1)

if __name__ == '__main__':
    main()

My output is:

3112040326038040883

Can you explain me why please?

Thanks

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
axtcommented, Dec 12, 2016
0reactions
ltfishcommented, Dec 12, 2016

You can add a new constraint that limits the most significant bit of your symbolic variable argv1 to 0 (positive numbers) or 1 (negative numbers), and then call se.min() or se.max() respectively.

Read more comments on GitHub >

github_iconTop Results From Across the Web

14 Great Exercises to Solve Problems as a Team - Merlin Project
We have put together 14 problem solving exercises for teams to help solve complex problems better. The exercises also promote cooperation, ...
Read more >
Top 15 Problem-Solving Activities for Your Team to Master
A problem-solving exercise or game helps identify those strengths and builds problem-solving skills and strategies while having fun with ...
Read more >
Try this creative problem solving exercise! - YouTube
... exercise to try next time you're feeling stuck! http://femaleentrepreneurassociation.com/2013/05/a-creative-way-to- solve -your-problems/
Read more >
Problem or Exercise? – Mathematics for Elementary Teachers
The main activity of mathematics is solving problems. However, what most people experience in most mathematics classrooms is practice exercises.
Read more >
20 Problem Solving Activities to Improve Creativity
These exercises are techniques on how to improve problem solving skills and the art of problem solving. Listed below are 20 interactive exercises...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found