""" Computrace Registry-based redirector Developed by Alfredo Ortega (aortega@coresecurity.com) and Anibal Sacco (Anibal.Sacco@coresecurity.com) This tool modifies the configuration block of the computrace agent in the registry, without any modification to the rpcnet.exe file. Copyright (c) 2009 Core Security Technologies, Core SDI Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY Core Security Technologies ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """ from _winreg import * from struct import pack, unpack import sys ## 16-bit checksum def checksum(string): result = 0 for i in range(0, len(string),2): result += unpack("" % sys.argv[0] print " newurl: New report URL of the computrace Agent (20 chars max.)" print "" print "NOTE: Please stop computrace service before using this tool!:" print "To stop computrace service you can use:" print " net stop rpcnet" print "from the command line." print "" print "To reinstall the comptrace agent to the original server, issue:" print " c:\windows\system32\rpcnet.exe -r" print "then: c:\windows\system32\rpcnet.exe -i" exit(0) #read and pad new URL newurl=sys.argv[1] if len(newurl)>20: newurl=newurl[:20] newurl=newurl+("\x00"*(20-len(newurl))) #pad # Read from registry print r"[+] Reading Configuration block" aReg = ConnectRegistry(None,HKEY_LOCAL_MACHINE) value = retrieve_key(aReg) CloseKey(aReg) #extract magic number from configuration block magic_number = value[0x104:0x106] print "[+] MAGIC NUMBER: %02x" % unpack("0): print "[+] found default connection server at index 0x%x" % strpos else: print "[+] Oops... default server '%s' not found...decrypt failed!" % defaultserver exit(-1) ready_string = ready_string[:strpos] + newurl + ready_string[strpos+20:] # first encryption encrypted_b5 = xor_string(ready_string, 0xb5) # second encryption encrypted_final=encrypt(encrypted_b5, magic_number) #print "[+] Re-Encrypted string:" #print hexformat(encrypted_final) print "[+] inserting into registry" set_key(encrypted_final) print "[+] Success"