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

makeImage.sh with a wrong DEVICE variable value causes error #89

Closed
c0mix opened this issue Sep 17, 2018 · 2 comments
Closed

makeImage.sh with a wrong DEVICE variable value causes error #89

c0mix opened this issue Sep 17, 2018 · 2 comments

Comments

@c0mix
Copy link
Contributor

@c0mix c0mix commented Sep 17, 2018

Inside firmadyne.config, the below assumption is not always correct.

get_device () {
    echo "/dev/mapper/loop0p1"
}

This wrong assumption causes a failure during the mounting phase of makeImage.sh because get_device it is called by the script to set DEVICE variable (line 51).

DEVICE=`get_device`

To avoid this issue, a simple workaround could be applied inside makeImage.sh file, specifically, it is possible to use the output of the kpartx command to infer the correct device name and set DEVICE variable.

echo "----Mounting QEMU Image----"
output=$(kpartx -a -s -v "${IMAGE}")
foo=$(echo "$output" | cut -d ' ' -f 3)
DEVICE="/dev/mapper/$foo"
echo $DEVICE # for debug purpose (can be removed)
sleep 1

The fixed makeImage.sh should look like this:
https://gist.github.com/c0mix/085a350df0b78290d3b3fb175a5c5555
Note: Tested on ubuntu 18.04 with 4.15.0-34-generic

@ddcc
Copy link
Collaborator

@ddcc ddcc commented Sep 18, 2018

Thanks for the feedback. Can you submit it as a pull request? My only concern is that other scripts such as mount.sh also utilize this functionality, so it'd be better to move the parsing into the firmadyne.config script, and have get_device take the output of kpartx as an input argument.

c0mix added a commit to c0mix/firmadyne that referenced this issue Sep 18, 2018
@c0mix
Copy link
Contributor Author

@c0mix c0mix commented Sep 18, 2018

As suggested I've opened a pull request here #90 moving the parsing into firmadyne.config
I hope that this will help you to improve your fantastic tool :)

ddcc added a commit that referenced this issue Oct 5, 2018
* bugfix to issue 89

#89
@ddcc ddcc closed this in 3f79250 Jan 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants