Testing driller with a program that reads a file
See original GitHub issueHi, all. I want to test the driller with a program that reads a file, like djpeg. First, I want to test a very simple example,
#include <fcntl.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
int main(int argc, char** argv) {
int fd = open(argv[1], O_RDONLY);
int input = 0;
read(fd, &input, sizeof(input));
if (input == 0xdeadbeef)
printf("Good");
close(fd);
}
To do it, I modified the following line to get fs, and argv.
s = p.factory.tracer_state(input_content=self.input, magic_content=r.magic, args=self.argv, fs=self._fs)
And run the driller as follows
input_file = 'sample/input.bin'
binary = 'sample/main'
with open(input_file, 'rb') as f:
inputs = f.read()
fs = {input_file: simuvex.storage.file.SimFile(input_file, "rb", size=os.path.getsize(input_file))}
d = driller.Driller(binary, inputs, argv=[binary, input_file], fs=fs)
for drilled in d.drill_generator():
print(drilled)
The input_file
is just “AAAA”. But unfortunately, I couldn’t get 0xdeadbeef.
Driller generates a testcase, but it was just empty string.
I checked that open() returns SimFile.
Could you let me know where do I have to take a look?
Thanks.
Issue Analytics
- State:
- Created 6 years ago
- Comments:12 (1 by maintainers)
Top Results From Across the Web
Drill and test software - The OLPC Wiki
1 Testing software for classroom evaluation (traditional exams) · 2 Drill software · 3 Software for scheduling constructionist activities or teaching vocabulary, ...
Read more >Solved 1: Create a Java Program titled "Driller" Your - Chegg
Question: 1: Create a Java Program titled "Driller" Your program will read the drilling data file—a text file in which data fields are...
Read more >Text Files: CSV, TSV, PSV - Apache Drill
Drill reads CSV, TSV, and PSV files into a list of VARCHARS, ... You can use code to achieve this, as you can...
Read more >Disk Drill Data Recovery Software | Free Download | CleverFiles
Let us know if you are interested in helping us beta-test this feature. Recover All File Types. Disk Drill, a professional Windows data...
Read more >Junit a application that reads a file and processes it
A simple solution: change your interfaces to be easy to test. Meaning: have one method that puts together a file name "in the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@agarciagonzalez FYI, this is my code for reading file input using driller. This uses kinda bug in the angr that it treats /dev/stdin as a normal file, and it lets us do file operations such as
lseek
. @salls Do you think it will be fine? I didn’t change any core part of driller, but the qemu part(to get file as input), and use /dev/stdin if we use angr.Driller is heavily hardcoded to use stdin. You’ll have to find in tracer where it preconstrains the input and make it use the file instead. And you’ll have to look at where driller dumps inputs, because it’s also just dumping stdin. It will definitely require some work to change from using stdin to using an input file.
The other option, if it doesn’t use stdin. Is to hook/change the file reads so they read from stdin instead. Then you can use driller as is