Leaderboard
Popular Content
Showing content with the highest reputation on 01/05/12 in Posts
-
Screen Dupa cum spune si titlul, acest soft ascunde text in imagini, pentru mai multe detalii vezi comentariul sursei. L-am pus aici ca sa ramana mai mult timp "vizibil", daca e vreo problema il mut la stuff. In 3 zile, 300 linii de cod, m-am gandit sa ma rezolv cat de cat cu atestatul si cum iubesc sursa libera si impartasirea ei pun la dispozitie asta: http://codepad.org/hNzxFzFT #! /usr/bin/env python # Text In Image # 02.01.2012 cmiN # # This is a simple GUI script which can hide text in pictures # using least significant bit method. # Also the input text can be encrypted and the output can be decrypted too # with a symmetric key using AES. # Writing is done directly on input image so be careful with certain extensions # because the output will always have the BMP format. # # Contact: cmin764@yahoo/gmail.com from Tkinter import * # widgets's classes from tkFileDialog import askopenfilename # get file name from tkMessageBox import showerror, showinfo # user dialog from PIL import Image # image converting from Crypto.Cipher import AES # text cipher class Engine: """ Code for processing the image. Separated from GUI. """ def __init__(self): """ Initialize parameters. """ self.ext = "bmp" # save format self.name = None # save name self.path = None # save path self.im = None # image object, read and write self.generator = None # get locations to write/read bits self.useAES = None # use it or not self.aes = None # AES object self.data = None # data to be written to image self.width = None # image width self.height = None # image height self.tmp = None # last string, used when key changes def binary(self, nr, size): """ Get 1&0 representation. """ return bin(nr).replace("0b", "").zfill(size * 8) def path_name(self, path): """ Split a file path in path and name. """ ind = path.rfind("/") + 1 return (path[:ind], path[ind:]) def set_generator(self): """ Useful for resetting. """ self.generator = ((wp, hp, ch) for wp in xrange(self.width) # WxHxC for hp in xrange(self.height) for ch in xrange(3)) def load(self, path): """ Load image. """ self.im = Image.open(path) (self.width, self.height) = self.im.size (self.path, self.name) = self.path_name(path) return self.width * self.height * 3 # total useful bytes def parse_key(self, key): """ If key exists make an AES object from it. """ if not key: self.aes = None # empty key == no encryption return self.parse_string(self.tmp) # must return size (see the next return) key.decode() # test availability size = len(key) for padding in (16, 24, 32): # fixed key size if size <= padding: break key += chr(0) * (padding - size) self.aes = AES.new(key) return self.parse_string(self.tmp) # if key changes you must update string def parse_string(self, string): """ Convert to bitstring. """ if not string: # without string can't start the process self.tmp = None self.data = None return 0 string.decode() # test availability self.tmp = string if self.useAES and self.aes: # encrypt it string += chr(0) * ((16 - len(string) % 16) % 16) # multiple of 16 string string = self.aes.encrypt(string) string = str().join([self.binary(ord(x), 1) for x in string]) # convert every char in a set of 8 bits size = self.binary(len(string), 4) # get binary representation of string's length in 4 bytes self.data = size + string return len(self.data) def write(self): """ Write using LSB. """ self.set_generator() # rearm for bit in self.data: (wp, hp, ch) = self.generator.next() # get next position values = list(self.im.getpixel((wp, hp))) # retrieve its values tmp = self.binary(values[ch], 1) # convert one of them values[ch] = int(tmp[:7] + bit, 2) # alter that channel self.im.putpixel((wp, hp), tuple(values)) # put it back self.im.save(self.path + self.name, format=self.ext) # save the new output def read(self): """ Read from every LSB. """ self.set_generator() # rearm total = self.width * self.height * 3 if total < 32: raise Exception("Text not found.") size = chunk = string = str() i = 0 # for(i=0; true; ++i) while True: (wp, hp, ch) = self.generator.next() # i byte values = self.im.getpixel((wp, hp)) tmp = self.binary(values[ch], 1) if i < 32: # it's lame but I prefer string/bitset size += tmp[7] if i == 31: size = int(size, 2) if size < 1 or (size + 32) > total: raise Exception("Text not found.") elif i < size + 32: chunk += tmp[7] if len(chunk) == 8: string += chr(int(chunk, 2)) chunk = str() else: break i += 1 if self.useAES and self.aes: if len(string) % 16 != 0: raise Exception("Text not encrypted.") string = self.aes.decrypt(string).rstrip(chr(0)) string.decode() # raise an exception if invalid return string class GUI(Frame): """ Main window, inherited from Frame. Here we put our widgets and set their behavior. """ def __init__(self, master=None, margin=30): """ Same as Frame's constructor. """ Frame.__init__(self, master, padx=margin, pady=margin) self.grid() self.widgets() self.behavior() def widgets(self): """ Build and grid widgets. """ # ---- create variables ---- self.totalBytes = IntVar() # depends on image size self.usedBytes = IntVar() # how many of them are used self.textStatus = StringVar() # used per total bytes self.useEncryption = IntVar() # 0-plain 1-AES self.mode = IntVar() # 0-read 1-write self.textOpt = dict() # text last config self.keyOpt = dict() # key last config self.loaded = False # image loaded or not # ---- create widgets ---- self.label = Label(self, textvariable=self.textStatus) self.about = Label(self, text="About", fg="blue") self.text = Text(self, width=30, height=5, fg="grey") self.scrollbar = Scrollbar(self, orient="vertical", command=self.text.yview) self.loadButton = Button(self, text="Load", width=5, command=lambda: self.action("load")) self.readRadio = Radiobutton(self, text="Read", variable=self.mode, value=0, command=self.set_state) self.checkButton = Checkbutton(self, text="Use AES", variable=self.useEncryption, onvalue=1, offvalue=0, command=self.set_state) self.startButton = Button(self, text="Start", width=5, state="disabled", command=lambda: self.action("start")) self.writeRadio = Radiobutton(self, text="Write", variable=self.mode, value=1, command=self.set_state) self.keyEntry = Entry(self, width=10, fg="grey", show="*") # ---- show widgets ---- self.label.grid(row=0, column=0, columnspan=2, sticky="w") self.about.grid(row=0, column=2, sticky="e") self.text.grid(row=1, column=0, rowspan=3, columnspan=3) self.scrollbar.grid(row=1, column=3, rowspan=3, sticky="ns") self.loadButton.grid(row=4, column=0, sticky="w", pady=5) self.readRadio.grid(row=4, column=1) self.checkButton.grid(row=4, column=2, sticky="e") self.startButton.grid(row=5, column=0, sticky="w") self.writeRadio.grid(row=5, column=1) self.keyEntry.grid(row=5, column=2, sticky="e") def behavior(self): """ Customize widgets. """ self.text.config(yscrollcommand=self.scrollbar.set) self.text.insert(0.0, "Text here") self.keyEntry.insert(0, "Key here") self.text.bind("<Button>", self.handle_event) self.text.bind("<KeyRelease>", self.handle_event) self.keyEntry.bind("<Button>", self.handle_event) self.keyEntry.bind("<KeyRelease>", self.handle_event) self.textOpt = self.get_opt(self.text) self.keyOpt = self.get_opt(self.keyEntry) self.about.bind("<Button>", self.handle_event) self.set_state() def action(self, arg): """ What every button triggers. """ if arg == "load": fileTypes = [("BMP", "*.bmp"), ("JPEG", ("*.jpeg", "*.jpg")), ("PNG", "*.png"), ("All Files", "*.*")] path = askopenfilename(parent=self, title="Open image", filetypes=fileTypes) if path != "": try: self.totalBytes.set(app.load(path)) except IOError as msg: showerror("Error", str(msg).capitalize().strip(".") + ".") # some formatting else: self.loaded = True self.set_state() self.master.title("Text In Image - %s" % app.name) # update name in title elif arg == "start": if self.mode.get(): try: app.write() except Exception as msg: showerror("Error", str(msg).capitalize().strip(".") + ".") else: showinfo("Info", "Done.") else: try: string = app.read() except UnicodeError: showerror("Error", "Text not found or wrong key.") except Exception as msg: showerror("Error", str(msg).capitalize().strip(".") + ".") else: self.text.config(state="normal") self.textOpt["fg"] = "black" # touched self.text.delete(0.0, END) self.text.insert(0.0, string) self.text.config(state="disabled") self.usedBytes.set(app.parse_string(string)) self.set_status() showinfo("Info", "Done.") def set_status(self): """ Get used per total bytes. """ string = "%9.3f%s/%9.3f%s" unit1 = unit2 = "b" used = self.usedBytes.get() total = self.totalBytes.get() if used > total: self.label.config(fg="red") else: self.label.config(fg="black") if used > 999999: unit1 = "Mb" used /= 1000000.0 elif used > 999: unit1 = "Kb" used /= 1000.0 if total > 999999: unit2 = "Mb" total /= 1000000.0 elif total > 999: unit2 = "Kb" total /= 1000.0 self.textStatus.set(string % (used, unit1, total, unit2)) def get_opt(self, widget): """ Get some options from a widget then pack them. """ opt = dict() opt["state"] = widget["state"] opt["fg"] = widget["fg"] opt["bg"] = widget["bg"] return opt def set_state(self): """ Enable or disable a widget according to option selected. """ if self.mode.get(): # write self.text.config(**self.textOpt) else: self.text.config(state="disabled", bg="lightgrey", fg="darkgrey") if self.useEncryption.get(): # use AES self.keyEntry.config(**self.keyOpt) app.useAES = True else: self.keyEntry.config(state="disabled") app.useAES = False length = app.parse_string(app.tmp) self.usedBytes.set(length) self.set_status() if self.loaded: # a file is loaded if self.mode.get() == 0: # read mode ok = True elif app.data != None and self.usedBytes.get() <= self.totalBytes.get(): ok = True else: ok = False else: ok = False # no file loaded if ok: self.startButton.config(state="normal") else: self.startButton.config(state="disabled") def handle_event(self, event): """ Handle events for specific widgets. """ if event.widget is self.text and self.text["state"] == "normal": if self.text["fg"] == "grey": self.text.delete(0.0, END) self.textOpt["fg"] = self.text["fg"] = "black" string = self.text.get(0.0, END).strip() try: length = app.parse_string(string) except UnicodeError: showerror("Error", "Invalid text.") else: self.usedBytes.set(length) self.set_state() elif event.widget is self.keyEntry and self.keyEntry["state"] == "normal": if self.keyEntry["fg"] == "grey": self.keyEntry.delete(0, END) self.keyOpt["fg"] = self.keyEntry["fg"] = "black" key = self.keyEntry.get()[:32] # first 32 (max size is 32) try: length = app.parse_key(key) except UnicodeError: showerror("Error", "Invalid key.") else: self.usedBytes.set(length) self.set_state() elif event.widget is self.about: showinfo("About", "Hide text, which can be encrypted with AES, in pictures, preferably bitmaps. Coded by cmiN. Visit rstcenter.com") if __name__ == "__main__": app = Engine() # core root = Tk() # toplevel root.title("Text In Image") root.maxsize(350, 250) root.iconbitmap("tii.ico") # comment if you don't have one GUI(root) root.mainloop() Testat pe windows, fedora si slackware, merge perfect, dar sa cititi comentariul principal. Aveti nevoie de python 2.7, PIL si pycrypto. Pe linux de obicei sunt preinstalate. Versiune portabila: box gamefront Updated: 14.01.20123 points
-
URL Dumper is an Online scanner SQLi,XSS. Used too get XSS and SQL Injections vulns.. supports multi search engine, trash system, etc.. Features: -Get all page links by advanced technique with regular expression; -XSS Scanner (auto check all page links); -SQLInjection Scanner (auto check all page links); -Multi-Thread engine; -Get many links by search (google/Yahoo/Live Search/Altavista/Terravista) -Search in the page source by regular expression; -View Source (Code/Browser); -Trash system -Database in SQLite to organize the URL’s -Enabled Proxy server Descarca Cod sursa1 point
-
http://vimeo.com/34598369 Hacking wifi WPA easily using a new tool called reaver 1.1 | Network and Security1 point
-
O colectie foarte mare de carti din toate domeniile de programare. http://www.wowebook.com1 point
-
This post explains how to analyze the malicious code used in current Exploit Kits. There are many ways to analyze this type of code, and you can find tools that do most of the job automatically. However, as researchers who like to understand how things work, we are going to analyze it with no other tools than a text editor and a Web browser. My goal is to lay the basis for you to learn how to remove the different obfuscation layers that a malicious JavaScript code may employ. I will teach you how to remove those layers step by until you get to the last layer where the logic that exploits the relevant vulnerability is found. IMPORTANT: I recommend that you perform this type of analysis on a virtual machine on its own isolated network in a laboratory dedicated exclusively to this type of research to avoid unwanted infection. BASIC CONCEPTS Generally speaking, malicious code is used to exploit vulnerabilities in Web browsers and PDF readers like Adobe Reader or Foxit. This code is usually written in javascript and has various layers of obfuscation. Code obfuscation techniques are generally used to make code difficult to understand for researchers, avoid detection by signatures or bypass automated scanning tools. The way they work is really simple: each of these layers calls other functions that obfuscate code that will become part of the next layer and so on and so forth until the final code. The final code is normally divided into two parts. The first one aims at detecting the Web browser version and the plug-ins installed on the victim’s computer (like Adobe Reader, Apple Quicktime or the Java virtual machine). The second part selects the vulnerability to exploit according to the information gathered in the first part. CODE ANALYSIS The image below is a screenshot of the malicious code to be analyzed in this article. As you can see, the code is made up of several HTML objects. However, if you look closer you can actually identify different things in these objects: First: The value of the id attribute for each of these objects has the format “<number>+CytobimusubekUda”, where “<number>” is a number from 0 to 1230 in consecutive order. Second: The value of each object is an apparently meaningless string of characters of approximately the same length, and the word Add repeated several times inside it. All this seems to indicate that the id attribute is used as an index (look at the consecutive numbers) in a cycle to parse all HTML objects and deobfuscate their contents to create a new code layer. Let’s start analyzing the code. FORMATTING THE CODE The first thing I usually do when examining a javascript code is use the Format Code option in Malzilla. This option formats the code as if it had been written with a program such as Visual Studio. Although simple, this is a very important step as many times the code is not properly formatted and is hard to understand. You could also do this manually, line by line, but you risk making a mistake and it will take you too long. For example, the malicious code that we will analyze here contains almost 600 lines of script code and HTML code. Malzilla is an excellent utility to analyze malicious code automatically. However, in this article we intend to analyze this malware strain manually. Unformatted code (before using the "Format Code” option) Well-formatted code (after using Malzilla’s “Format Code” option) THE TOOL The next step is to copy the well-formatted Javascript code to the text editor to be used in the analysis. Any text editor with the following basic options should be enough: JavaScript code identification: It will help you view the code and quickly detect Javascript functions. String search-and-replace: This will help you avoid mistakes when replacing the names of functions and variables. Windows Tabs: This is optional. Tabs will let you work very quickly when analyzing the code of various files. FINDING THE ‘START’ FUNCTION The sample currently has 96 lines of javascript code and more than 500 lines of HTML code. You will reduce the number of lines as you remove the obfuscation layers. The first thing you have to do is determine the javascript code that runs when the browser loads the malicious Web page. Then you have to analyze all the other functions as they are run. The first steps to take with every function are the following: Simplify the code to analyze Rename the functions and variables for the code to be easier to understand. To do that, first check the HTML code, and if there is no HTML object that calls a javascript function, proceed to analyze the code found between the <script> and </script> tags. There you must find the code that does not belong to a function definition, as that will be the code that runs automatically when the Web page is loaded by the browser. The screenshot below shows that code between lines 81 and 89 (both included). You can also see that the HazakeduhaQurenepenus() function (85) is the first one to run (the previous three don’t perform any important actions). Therefore, this is the first function that you must analyze. Code run on loading the page (red rectangle) SIMPLIFYING THE CODE AND MAKING IT EASIER TO UNDERSTAND Simplifying the code and making it easy to understand is one of the most difficult yet important tasks. It involves studying almost every instruction in the javascript code, and modifying them to create a code that is easier to understand and analyze. VERY IMPORTANT: When modifying the code, don’t change the final result that would be returned by the original code. As previously said, start with the HazakeduhaQurenepenus() function. This function looks like this: “HazakedubaQurenepenus()” function before the analysis In the code, pay special attention to the functions that are not part of the javascript API, that is, the functions programmed by the user. You have to resolve the value that these will return in order to analyze the function. In the code above, the factor to resolve is the PypiwIgo() function that has the following code: If you take a look at it and you are familiar with the javascript language, you will realize that the function will return the getElementById string every time it is called. With this in mind and knowing that the DeqesedaDakonyqev variable refers to the document object, you can make the first change for the code to be easier to understand. The resulting code will look like this: “HazakedubaQurenepenus()” function after the analysis You may have noticed that I have changed the name of several variables and of the analyzed function itself to func_decrypt_01. This may seem a little bit bold, but after having analyzed many functions like this you become capable of recognizing certain code structures at a glance. Your next objective is to resolve the value to be returned by the function in the buffer variable. To do that, you must separate the function from the original code and run it independently. Prior to that, you must make sure that the function to analyze will not need any external values or any other piece of data calculated by any other function of the assigned code in any global variable. Otherwise, you will have to first calculate that value and then replace it in the code to isolate. This is very important as otherwise you will probably not be able to run the code separately: the Web browser will show an error when loading the page and it will not be possible to run the code or it simply won’t behave in the same way as if it had been run with the entire malicious code. Let’s see this with an example in the code we are analyzing. The following instruction refers to an external value in the DasuRokyduconiwidy HTML object. string_01 = document.getElementById(“DasuRokyduconiwidy”).innerHTML; The resulting value is assigned to the string_01 variable. Since this variable is used inside the code, you must resolve its value. Otherwise, if the variable was only used to confuse the user, you could eliminate it from the code. The technique of using data in HTML objects and referring to it from the javascript code is frequently used to obfuscate code by splitting it into parts. This serves to bypass the automatic analyses performed by certain tools unable to interpret the connection between the javascript and the HTML code. This anti-analysis technique is also used by malicious PDF files. The technique involves making calls to the Adobe PDF API’s javascript functions, which cannot be interpreted by many analysis tools. The first thing you need to do is find the DasuRokyduconiwidy object. Once you find it, assign its value to the string_01 variable in the script code that you have created, and replace the return buffer instruction with a TEXTAREA object that will show the content of the buffer variable once the new code is run in the Web browser. Value of the DasuRokyduconiwidy object and line of code to replace The screenshot below shows the simplified code and how the “return buffer” instruction has been replaced with a textarea object created at runtime. New code created to view the result of the buffer variable Once you have the code, open it with the Web browser to see the function result. Value of the buffer variable As you can see, the returned result is a string comprising a sequence of names of javascript API functions. Once you have resolved the value obtained when calling the func_decrypt_01 function, rename the GuzoZaq variable. This is the variable that the return value is assigned to. For example, call it concat_func_string, and then assign to it the value obtained in the textarea object. The code will look like this. concat_func_string variable with the value already resolved Continue analyzing the code run when loading the Web page. The next function to analyze is NupUr(). This function calls function HaynubOguf(), which you must resolve before continuing to analyze the code. HaynubOguf( ) is a very simple function that returns the substr string, which is the name of a javascript function whose job is to obtain a substring from a string. Therefore, rename the HanynubOguf() function to func_substr(). The NupUr() function will look like this. NupUr() function to analyze Now that you have “resolved” the different parts of the function code, make the code more readable. This involves resolving the names of all the functions in brackets from inside out. As you can see, the code uses the concat_func_string variable. If you remember, this variable refers to a string made up of the names of multiple javascript API functions. Also, note that the code uses the substr variable as well. This indicates that part of the string will be extracted to obtain the name of the function to be later on used in the code. Original function Resolved function [func_substr()](63,14) .substr(63,14) [concat_func_string.substr(63,14)] getElementById [func_substr()](1736/56,585/65) [func_substr()][31,9] ? .substr(31,9) [concat_func_string.substr(31,9)] .InnerHTML The result is the following code: As you resolve more and more functions you will be able to discover the actions to be taken by the rest of them simply by taking a glance at their code. This is because you’ll have already resolved many unknown values. This will help you analyze other functions more quickly and eliminate obfuscation layers more easily. Finally, let’s analyze the MivoJaqugutec() function: At first glance, the first thing that you can identify in the code is a cycle that runs through all of the HTML objects, storing their values and concatenating them in the PofUhicehofudilysuwe variable returned by the function once the cycle ends. Well, with everything you have learnt so far you probably know what to do. Separate the function from the original code, resolve the unknown values and rename its variables for the code to be easier to understand. Your objective should be to determine the value of the PofUhicehofudilysuwe variable in the return instruction. Once you run the code on the Web browser you’ll get the following result: Similarly, transform the other functions in the code that’s left to analyze. The final result is quite interesting: you’ve gone from 96 lines of javascript code and some 500 lines of HTML code to just 2 lines of javascript code with the eval() and unescape() functions. These 2 functions normally indicate the execution of a new obfuscation layer. Have you reached your final objective yet? Is this the final layer responsible for triggering the vulnerability? Well, let’s see what it contains. ACCESSING THE FINAL CODE The last 2 lines of code include the payload variable, which refers to an encoded, 55,496-character-long unicode string. After running its content with the eval( unescape(payload) ) instruction you’ll get to the last layer in the malicious code. In this last part of the article we will only analyze the generic parts often found in malicious codes. The following two screenshots show a series of instructions that are often used both in legitimate and malicious code, although with very different purposes. Whereas they are used in legitimate code for design purposes, in malicious code they are used to obtain information about the victim’s environment and exploit the most appropriate vulnerability. As you can see in the two screenshots above, the programmer has used the userAgent method of the navigator object to identify the Web browser used by the victim. In the case of Internet Explorer they check to see if the version is lower than 6. They also try to identify if there are any plug-ins installed on the browser. In this code the programmer has decided to create an object identified by the CLSID CA8A9780-280D-11CF-A24D-444553540000 in the Pdf1 variable. Although the name of the variable gives a hint as to what object the programmer wants to create, let’s make sure. Use the regedit.exe tool to find the CLSID key in the Windows registry. Our suppositions were true: The CLSID key refers to the Adobe Acrobat/Reader ActiveX control. The programmer has created this object to find out if the victim has Adobe Acrobat or Adobe Reader installed (and what version they are using), and select the malicious PDF file that can exploit one of the vulnerabilities in the detected version. They use the GetVersions() method to find out the version of the Adobe program installed on the victim’s computer, as seen in the first instruction in the code below: The last part of the code is used to select the most appropriate PDF file to exploit the vulnerability. If the value of the lv variable is greater than or equal to 800 (which possibly identifies version 8), the code will call the fghjdfgxbz function passing the string “d0456d.pdf” as a parameter. Otherwise, it will pass the “07dd5d.pdf” string as a parameter. The fghjdfgxbz function simply creates an IFRAME object at runtime that points to the value passed as the parameter. As a result, the Web browser will open a malicious PDF file designed to exploit an unpatched security vulnerability. To sum up, in this article we have explained how to analyze and deobfuscate the layers of one of the malicious codes currently used in exploit kits, with just a text editor, a Web browser and some knowledge of JavaScript and HTML. We have also analyzed part of the final code to show you some of the methods used to detect the Web browser and the plug-ins installed on victims’ computers. Happy hunting!! http://pandalabs.pandasecurity.com/deobfuscating-malicious-code-layer-by-layer/1 point
This leaderboard is set to Bucharest/GMT+02:00