├── truffleHog ├── __init__.py └── truffleHog.py ├── setup.cfg ├── testRules.json ├── .gitignore ├── .travis.yml ├── requirements.txt ├── Dockerfile ├── setup.py ├── scripts └── searchOrg.py ├── test_all.py ├── README.md └── LICENSE /truffleHog/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [bdist_wheel] 2 | universal=1 3 | -------------------------------------------------------------------------------- /testRules.json: -------------------------------------------------------------------------------- 1 | { 2 | "RSA private key": "-----BEGIN EC PRIVATE KEY-----" 3 | } 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /build/ 2 | /dist/ 3 | /truffleHog.egg-info/ 4 | **/__pycache__/ 5 | **/*.pyc 6 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | python: 3 | - "2.7" 4 | script: pytest --cov=./ && codecov 5 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | GitPython==2.1.1 2 | unittest2==1.1.0 3 | pytest-cov==2.5.1 4 | codecov==2.0.15 5 | truffleHogRegexes==0.0.4 6 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3-alpine 2 | RUN apk add --no-cache git && pip install trufflehog 3 | RUN adduser -S truffleHog 4 | USER truffleHog 5 | WORKDIR /proj 6 | ENTRYPOINT [ "trufflehog" ] 7 | CMD [ "-h" ] 8 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup, find_packages 2 | 3 | setup( 4 | name='truffleHog', 5 | version='2.0.92', 6 | description='Searches through git repositories for high entropy strings, digging deep into commit history.', 7 | url='https://github.com/dxa4481/truffleHog', 8 | author='Dylan Ayrey', 9 | author_email='dxa4481@rit.edu', 10 | license='GNU', 11 | packages = ['truffleHog'], 12 | install_requires=[ 13 | 'GitPython == 2.1.1', 14 | 'truffleHogRegexes == 0.0.4' 15 | ], 16 | entry_points = { 17 | 'console_scripts': ['trufflehog = truffleHog.truffleHog:main'], 18 | }, 19 | ) 20 | -------------------------------------------------------------------------------- /scripts/searchOrg.py: -------------------------------------------------------------------------------- 1 | """ 2 | Credit for this code goes to https://github.com/ryanbaxendale 3 | via https://github.com/dxa4481/truffleHog/pull/9 4 | """ 5 | import requests 6 | from truffleHog import truffleHog 7 | 8 | def get_org_repos(orgname, page): 9 | response = requests.get(url='https://api.github.com/users/' + orgname + '/repos?page={}'.format(page)) 10 | json = response.json() 11 | if not json: 12 | return None 13 | for item in json: 14 | if item['private'] == False: 15 | print('searching ' + item["html_url"]) 16 | truffleHog.find_strings(item["html_url"], do_regex=True, do_entropy=False, max_depth=100000) 17 | get_org_repos(orgname, page + 1) 18 | get_org_repos("twitter", 1) 19 | -------------------------------------------------------------------------------- /test_all.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import os 3 | from truffleHog import truffleHog 4 | 5 | 6 | class TestStringMethods(unittest.TestCase): 7 | 8 | def test_shannon(self): 9 | random_stringB64 = "ZWVTjPQSdhwRgl204Hc51YCsritMIzn8B=/p9UyeX7xu6KkAGqfm3FJ+oObLDNEva" 10 | random_stringHex = "b3A0a1FDfe86dcCE945B72" 11 | self.assertGreater(truffleHog.shannon_entropy(random_stringB64, truffleHog.BASE64_CHARS), 4.5) 12 | self.assertGreater(truffleHog.shannon_entropy(random_stringHex, truffleHog.HEX_CHARS), 3) 13 | 14 | def test_cloning(self): 15 | project_path = truffleHog.clone_git_repo("https://github.com/dxa4481/truffleHog.git") 16 | license_file = os.path.join(project_path, "LICENSE") 17 | self.assertTrue(os.path.isfile(license_file)) 18 | 19 | def test_unicode_expection(self): 20 | try: 21 | truffleHog.find_strings("https://github.com/dxa4481/tst.git") 22 | except UnicodeEncodeError: 23 | self.fail("Unicode print error") 24 | 25 | if __name__ == '__main__': 26 | unittest.main() 27 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Truffle Hog 2 | Searches through git repositories for secrets, digging deep into commit history and branches. This is effective at finding secrets accidentally committed. 3 | 4 | ## NEW 5 | Trufflehog previously functioned by running entropy checks on git diffs. This functionality still exists, but high signal regex checks have been added, and the ability to surpress entropy checking has also been added. 6 | 7 | These features help cut down on noise, and makes the tool easier to shove into a devops pipeline. 8 | 9 | 10 | ``` 11 | truffleHog --regex --entropy=False https://github.com/dxa4481/truffleHog.git 12 | ``` 13 | 14 | or 15 | 16 | ``` 17 | truffleHog file:///user/dxa4481/codeprojects/truffleHog/ 18 | ``` 19 | 20 | ![Example](https://i.imgur.com/YAXndLD.png) 21 | 22 | ## Install 23 | ``` 24 | pip install truffleHog 25 | ``` 26 | 27 | ## Customizing 28 | 29 | Custom regexes can be added with the following flag `--rules /path/to/rules`. This should be a json file of the following format: 30 | ``` 31 | { 32 | "RSA private key": "-----BEGIN EC PRIVATE KEY-----" 33 | } 34 | ``` 35 | Things like subdomain enumeration, s3 bucket detection, and other useful regexes highly custom to the situation can be added. 36 | 37 | Feel free to also contribute high signal regexes upstream that you think will benifit the community. Things like Azure keys, Twilio keys, Google Compute keys, are welcome, provided a high signal regex can be constructed. 38 | 39 | Trufflehog's base rule set sources from https://github.com/dxa4481/truffleHogRegexes/blob/master/truffleHogRegexes/regexes.json 40 | 41 | ## How it works 42 | This module will go through the entire commit history of each branch, and check each diff from each commit, and check for secrets. This is both by regex and by entropy. For entropy checks, trufflehog will evaluate the shannon entropy for both the base64 char set and hexidecimal char set for every blob of text greater than 20 characters comprised of those character sets in each diff. If at any point a high entropy string >20 characters is detected, it will print to the screen. 43 | 44 | ## Help 45 | 46 | ``` 47 | usage: trufflehog [-h] [--json] [--regex] [--rules RULES] 48 | [--entropy DO_ENTROPY] [--since_commit SINCE_COMMIT] 49 | [--max_depth MAX_DEPTH] 50 | git_url 51 | 52 | Find secrets hidden in the depths of git. 53 | 54 | positional arguments: 55 | git_url URL for secret searching 56 | 57 | optional arguments: 58 | -h, --help show this help message and exit 59 | --json Output in JSON 60 | --regex Enable high signal regex checks 61 | --rules RULES Ignore default regexes and source from json list file 62 | --entropy DO_ENTROPY Enable entropy checks 63 | --since_commit SINCE_COMMIT 64 | Only scan from a given commit hash 65 | --max_depth MAX_DEPTH 66 | The max commit depth to go back when searching for 67 | secrets 68 | ``` 69 | 70 | ## Wishlist 71 | 72 | - ~~A way to detect and not scan binary diffs~~ 73 | - ~~Don't rescan diffs if already looked at in another branch~~ 74 | - ~~A since commit X feature~~ 75 | - ~~Print the file affected~~ 76 | -------------------------------------------------------------------------------- /truffleHog/truffleHog.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | from __future__ import absolute_import 5 | import shutil 6 | import sys 7 | import math 8 | import datetime 9 | import argparse 10 | import uuid 11 | import hashlib 12 | import tempfile 13 | import os 14 | import re 15 | import json 16 | import stat 17 | from git import Repo 18 | from git import NULL_TREE 19 | from truffleHogRegexes.regexChecks import regexes 20 | 21 | 22 | def main(): 23 | parser = argparse.ArgumentParser(description='Find secrets hidden in the depths of git.') 24 | parser.add_argument('--json', dest="output_json", action="store_true", help="Output in JSON") 25 | parser.add_argument("--regex", dest="do_regex", action="store_true", help="Enable high signal regex checks") 26 | parser.add_argument("--rules", dest="rules", help="Ignore default regexes and source from json list file") 27 | parser.add_argument("--entropy", dest="do_entropy", help="Enable entropy checks") 28 | parser.add_argument("--since_commit", dest="since_commit", help="Only scan from a given commit hash") 29 | parser.add_argument("--max_depth", dest="max_depth", help="The max commit depth to go back when searching for secrets") 30 | parser.add_argument('git_url', type=str, help='URL for secret searching') 31 | parser.set_defaults(regex=False) 32 | parser.set_defaults(rules={}) 33 | parser.set_defaults(max_depth=1000000) 34 | parser.set_defaults(since_commit=None) 35 | parser.set_defaults(entropy=True) 36 | args = parser.parse_args() 37 | rules = {} 38 | if args.rules: 39 | try: 40 | with open(args.rules, "r") as ruleFile: 41 | rules = json.loads(ruleFile.read()) 42 | for rule in rules: 43 | rules[rule] = re.compile(rules[rule]) 44 | except (IOError, ValueError) as e: 45 | raise("Error reading rules file") 46 | for regex in dict(regexes): 47 | del regexes[regex] 48 | for regex in rules: 49 | regexes[regex] = rules[regex] 50 | do_entropy = str2bool(args.do_entropy) 51 | output = find_strings(args.git_url, args.since_commit, args.max_depth, args.output_json, args.do_regex, do_entropy, surpress_output=False) 52 | project_path = output["project_path"] 53 | shutil.rmtree(project_path, onerror=del_rw) 54 | if output["foundIssues"]: 55 | sys.exit(1) 56 | else: 57 | sys.exit(0) 58 | 59 | def str2bool(v): 60 | if v == None: 61 | return True 62 | if v.lower() in ('yes', 'true', 't', 'y', '1'): 63 | return True 64 | elif v.lower() in ('no', 'false', 'f', 'n', '0'): 65 | return False 66 | else: 67 | raise argparse.ArgumentTypeError('Boolean value expected.') 68 | 69 | 70 | BASE64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=" 71 | HEX_CHARS = "1234567890abcdefABCDEF" 72 | 73 | def del_rw(action, name, exc): 74 | os.chmod(name, stat.S_IWRITE) 75 | os.remove(name) 76 | 77 | def shannon_entropy(data, iterator): 78 | """ 79 | Borrowed from http://blog.dkbza.org/2007/05/scanning-data-for-entropy-anomalies.html 80 | """ 81 | if not data: 82 | return 0 83 | entropy = 0 84 | for x in iterator: 85 | p_x = float(data.count(x))/len(data) 86 | if p_x > 0: 87 | entropy += - p_x*math.log(p_x, 2) 88 | return entropy 89 | 90 | 91 | def get_strings_of_set(word, char_set, threshold=20): 92 | count = 0 93 | letters = "" 94 | strings = [] 95 | for char in word: 96 | if char in char_set: 97 | letters += char 98 | count += 1 99 | else: 100 | if count > threshold: 101 | strings.append(letters) 102 | letters = "" 103 | count = 0 104 | if count > threshold: 105 | strings.append(letters) 106 | return strings 107 | 108 | class bcolors: 109 | HEADER = '\033[95m' 110 | OKBLUE = '\033[94m' 111 | OKGREEN = '\033[92m' 112 | WARNING = '\033[93m' 113 | FAIL = '\033[91m' 114 | ENDC = '\033[0m' 115 | BOLD = '\033[1m' 116 | UNDERLINE = '\033[4m' 117 | 118 | def clone_git_repo(git_url): 119 | project_path = tempfile.mkdtemp() 120 | Repo.clone_from(git_url, project_path) 121 | return project_path 122 | 123 | def print_results(printJson, issue): 124 | commit_time = issue['date'] 125 | branch_name = issue['branch'] 126 | prev_commit = issue['commit'] 127 | printableDiff = issue['printDiff'] 128 | commitHash = issue['commitHash'] 129 | reason = issue['reason'] 130 | path = issue['path'] 131 | 132 | if printJson: 133 | print(json.dumps(issue, sort_keys=True)) 134 | else: 135 | print("~~~~~~~~~~~~~~~~~~~~~") 136 | reason = "{}Reason: {}{}".format(bcolors.OKGREEN, reason, bcolors.ENDC) 137 | print(reason) 138 | dateStr = "{}Date: {}{}".format(bcolors.OKGREEN, commit_time, bcolors.ENDC) 139 | print(dateStr) 140 | hashStr = "{}Hash: {}{}".format(bcolors.OKGREEN, commitHash, bcolors.ENDC) 141 | print(hashStr) 142 | filePath = "{}Filepath: {}{}".format(bcolors.OKGREEN, path, bcolors.ENDC) 143 | print(filePath) 144 | 145 | if sys.version_info >= (3, 0): 146 | branchStr = "{}Branch: {}{}".format(bcolors.OKGREEN, branch_name, bcolors.ENDC) 147 | print(branchStr) 148 | commitStr = "{}Commit: {}{}".format(bcolors.OKGREEN, prev_commit, bcolors.ENDC) 149 | print(commitStr) 150 | print(printableDiff) 151 | else: 152 | branchStr = "{}Branch: {}{}".format(bcolors.OKGREEN, branch_name.encode('utf-8'), bcolors.ENDC) 153 | print(branchStr) 154 | commitStr = "{}Commit: {}{}".format(bcolors.OKGREEN, prev_commit.encode('utf-8'), bcolors.ENDC) 155 | print(commitStr) 156 | print(printableDiff.encode('utf-8')) 157 | print("~~~~~~~~~~~~~~~~~~~~~") 158 | 159 | def find_entropy(printableDiff, commit_time, branch_name, prev_commit, blob, commitHash): 160 | stringsFound = [] 161 | lines = printableDiff.split("\n") 162 | for line in lines: 163 | for word in line.split(): 164 | base64_strings = get_strings_of_set(word, BASE64_CHARS) 165 | hex_strings = get_strings_of_set(word, HEX_CHARS) 166 | for string in base64_strings: 167 | b64Entropy = shannon_entropy(string, BASE64_CHARS) 168 | if b64Entropy > 4.5: 169 | stringsFound.append(string) 170 | printableDiff = printableDiff.replace(string, bcolors.WARNING + string + bcolors.ENDC) 171 | for string in hex_strings: 172 | hexEntropy = shannon_entropy(string, HEX_CHARS) 173 | if hexEntropy > 3: 174 | stringsFound.append(string) 175 | printableDiff = printableDiff.replace(string, bcolors.WARNING + string + bcolors.ENDC) 176 | entropicDiff = None 177 | if len(stringsFound) > 0: 178 | entropicDiff = {} 179 | entropicDiff['date'] = commit_time 180 | entropicDiff['path'] = blob.b_path if blob.b_path else blob.a_path 181 | entropicDiff['branch'] = branch_name 182 | entropicDiff['commit'] = prev_commit.message 183 | entropicDiff['diff'] = blob.diff.decode('utf-8', errors='replace') 184 | entropicDiff['stringsFound'] = stringsFound 185 | entropicDiff['printDiff'] = printableDiff 186 | entropicDiff['commitHash'] = commitHash 187 | entropicDiff['reason'] = "High Entropy" 188 | return entropicDiff 189 | 190 | def regex_check(printableDiff, commit_time, branch_name, prev_commit, blob, commitHash, custom_regexes={}): 191 | if custom_regexes: 192 | secret_regexes = custom_regexes 193 | else: 194 | secret_regexes = regexes 195 | regex_matches = [] 196 | for key in secret_regexes: 197 | found_strings = secret_regexes[key].findall(printableDiff) 198 | for found_string in found_strings: 199 | found_diff = printableDiff.replace(printableDiff, bcolors.WARNING + found_string + bcolors.ENDC) 200 | if found_strings: 201 | foundRegex = {} 202 | foundRegex['date'] = commit_time 203 | foundRegex['path'] = blob.b_path if blob.b_path else blob.a_path 204 | foundRegex['branch'] = branch_name 205 | foundRegex['commit'] = prev_commit.message 206 | foundRegex['diff'] = blob.diff.decode('utf-8', errors='replace') 207 | foundRegex['stringsFound'] = found_strings 208 | foundRegex['printDiff'] = found_diff 209 | foundRegex['reason'] = key 210 | foundRegex['commitHash'] = commitHash 211 | regex_matches.append(foundRegex) 212 | return regex_matches 213 | 214 | def diff_worker(diff, curr_commit, prev_commit, branch_name, commitHash, custom_regexes, do_entropy, do_regex, printJson, surpress_output): 215 | issues = [] 216 | for blob in diff: 217 | printableDiff = blob.diff.decode('utf-8', errors='replace') 218 | if printableDiff.startswith("Binary files"): 219 | continue 220 | commit_time = datetime.datetime.fromtimestamp(prev_commit.committed_date).strftime('%Y-%m-%d %H:%M:%S') 221 | foundIssues = [] 222 | if do_entropy: 223 | entropicDiff = find_entropy(printableDiff, commit_time, branch_name, prev_commit, blob, commitHash) 224 | if entropicDiff: 225 | foundIssues.append(entropicDiff) 226 | if do_regex: 227 | found_regexes = regex_check(printableDiff, commit_time, branch_name, prev_commit, blob, commitHash, custom_regexes) 228 | foundIssues += found_regexes 229 | if not surpress_output: 230 | for foundIssue in foundIssues: 231 | print_results(printJson, foundIssue) 232 | issues += foundIssues 233 | return issues 234 | 235 | def handle_results(output, output_dir, foundIssues): 236 | for foundIssue in foundIssues: 237 | result_path = os.path.join(output_dir, str(uuid.uuid4())) 238 | with open(result_path, "w+") as result_file: 239 | result_file.write(json.dumps(foundIssue)) 240 | output["foundIssues"].append(result_path) 241 | return output 242 | 243 | def find_strings(git_url, since_commit=None, max_depth=1000000, printJson=False, do_regex=False, do_entropy=True, surpress_output=True, custom_regexes={}): 244 | output = {"foundIssues": []} 245 | project_path = clone_git_repo(git_url) 246 | repo = Repo(project_path) 247 | already_searched = set() 248 | output_dir = tempfile.mkdtemp() 249 | 250 | for remote_branch in repo.remotes.origin.fetch(): 251 | since_commit_reached = False 252 | branch_name = remote_branch.name 253 | prev_commit = None 254 | for curr_commit in repo.iter_commits(branch_name, max_count=max_depth): 255 | commitHash = curr_commit.hexsha 256 | if commitHash == since_commit: 257 | since_commit_reached = True 258 | if since_commit and since_commit_reached: 259 | prev_commit = curr_commit 260 | continue 261 | # if not prev_commit, then curr_commit is the newest commit. And we have nothing to diff with. 262 | # But we will diff the first commit with NULL_TREE here to check the oldest code. 263 | # In this way, no commit will be missed. 264 | diff_hash = hashlib.md5((str(prev_commit) + str(curr_commit)).encode('utf-8')).digest() 265 | if not prev_commit: 266 | prev_commit = curr_commit 267 | continue 268 | elif diff_hash in already_searched: 269 | prev_commit = curr_commit 270 | continue 271 | else: 272 | diff = prev_commit.diff(curr_commit, create_patch=True) 273 | # avoid searching the same diffs 274 | already_searched.add(diff_hash) 275 | foundIssues = diff_worker(diff, curr_commit, prev_commit, branch_name, commitHash, custom_regexes, do_entropy, do_regex, printJson, surpress_output) 276 | output = handle_results(output, output_dir, foundIssues) 277 | prev_commit = curr_commit 278 | # Handling the first commit 279 | diff = curr_commit.diff(NULL_TREE, create_patch=True) 280 | foundIssues = diff_worker(diff, curr_commit, prev_commit, branch_name, commitHash, custom_regexes, do_entropy, do_regex, printJson, surpress_output) 281 | output = handle_results(output, output_dir, foundIssues) 282 | output["project_path"] = project_path 283 | output["clone_uri"] = git_url 284 | return output 285 | 286 | if __name__ == "__main__": 287 | main() 288 | -------------------------------------------------------------------------------- /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 | {description} 294 | Copyright (C) {year} {fullname} 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 | --------------------------------------------------------------------------------