├── challenges ├── 1-helloworld │ ├── solve_1.py │ ├── Makefile │ ├── solve_1.java │ └── 1.c ├── README.md ├── Makefile ├── 7-hello-patch │ ├── 7.c │ └── Makefile ├── 8-evil-bytes │ ├── Makefile │ └── 8.c ├── 5-decompiler │ ├── Makefile │ └── 5.c ├── 3-references │ ├── Makefile │ ├── solve_3.py │ ├── solve_3.java │ └── 3.c ├── 6-defined-data │ ├── Makefile │ └── 6.cpp ├── 2-ghidra-metadata │ ├── Makefile │ ├── solve_2.py │ ├── 2.c │ └── solve_2.java ├── 4-called-functions │ ├── Makefile │ ├── solve_4.py │ ├── 4.c │ └── solve_4.java └── 9-class-functions │ ├── Makefile │ └── 9.cpp ├── .imgs └── gg_scripts.png ├── solves ├── solve_8.py ├── solve_7.py ├── solve_5.py ├── solve_6.py ├── solve_2.java ├── solve_9.py ├── solve_1.java ├── solve_4.java └── solve_3.java ├── README.md └── LICENSE /challenges/1-helloworld/solve_1.py: -------------------------------------------------------------------------------- 1 | def run(): 2 | # println here 3 | pass -------------------------------------------------------------------------------- /.imgs/gg_scripts.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ghidragolf/putting_green/HEAD/.imgs/gg_scripts.png -------------------------------------------------------------------------------- /challenges/README.md: -------------------------------------------------------------------------------- 1 | ## Building all Challenges 2 | Run `make` in the top level directory. You must have `gcc` and `g++` installed. -------------------------------------------------------------------------------- /challenges/Makefile: -------------------------------------------------------------------------------- 1 | SUBDIRS := $(wildcard */.) 2 | 3 | all: $(SUBDIRS) 4 | $(SUBDIRS): 5 | $(MAKE) -C $@ 6 | 7 | .PHONY: all $(SUBDIRS) 8 | -------------------------------------------------------------------------------- /challenges/7-hello-patch/7.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(int argc, char* argv[]) 5 | { 6 | printf("hello world!"); 7 | return 0; 8 | } -------------------------------------------------------------------------------- /challenges/8-evil-bytes/Makefile: -------------------------------------------------------------------------------- 1 | CC := gcc 2 | SF := $(wildcard *.c) 3 | OUTDIR := bin 4 | NAME := bytes 5 | 6 | all: clean build 7 | 8 | build: 9 | $(CC) $(SF) -o $(OUTDIR)/$(NAME) -fno-stack-protector 10 | 11 | clean: 12 | mkdir -p $(OUTDIR) 13 | rm -f $(OUTDIR)/* 14 | -------------------------------------------------------------------------------- /challenges/1-helloworld/Makefile: -------------------------------------------------------------------------------- 1 | CC := gcc 2 | SF := $(wildcard *.c) 3 | OUTDIR := bin 4 | NAME := helloworld 5 | 6 | all: clean build 7 | 8 | build: 9 | $(CC) $(SF) -o $(OUTDIR)/$(NAME) -fno-stack-protector 10 | 11 | clean: 12 | mkdir -p $(OUTDIR) 13 | rm -f $(OUTDIR)/* 14 | -------------------------------------------------------------------------------- /challenges/5-decompiler/Makefile: -------------------------------------------------------------------------------- 1 | CC := gcc 2 | SF := $(wildcard *.c) 3 | OUTDIR := bin 4 | NAME := decompiler 5 | 6 | all: clean build 7 | 8 | build: 9 | $(CC) $(SF) -o $(OUTDIR)/$(NAME) -fno-stack-protector 10 | 11 | clean: 12 | mkdir -p $(OUTDIR) 13 | rm -f $(OUTDIR)/* 14 | -------------------------------------------------------------------------------- /challenges/7-hello-patch/Makefile: -------------------------------------------------------------------------------- 1 | CC := gcc 2 | SF := $(wildcard *.c) 3 | OUTDIR := bin 4 | NAME := patch-me 5 | 6 | all: clean build 7 | 8 | build: 9 | $(CC) $(SF) -o $(OUTDIR)/$(NAME) -fno-stack-protector 10 | 11 | clean: 12 | mkdir -p $(OUTDIR) 13 | rm -f $(OUTDIR)/* 14 | -------------------------------------------------------------------------------- /challenges/3-references/Makefile: -------------------------------------------------------------------------------- 1 | CC := gcc 2 | SF := $(wildcard *.c) 3 | OUTDIR := bin 4 | NAME := references 5 | 6 | all: clean build 7 | 8 | build: 9 | $(CC) $(SF) -lm -o $(OUTDIR)/$(NAME) -fno-stack-protector 10 | 11 | clean: 12 | mkdir -p $(OUTDIR) 13 | rm -f $(OUTDIR)/* 14 | -------------------------------------------------------------------------------- /challenges/6-defined-data/Makefile: -------------------------------------------------------------------------------- 1 | CC := g++ 2 | SF := $(wildcard *.cpp) 3 | OUTDIR := bin 4 | NAME := symbols-b64 5 | 6 | all: clean build 7 | 8 | build: 9 | $(CC) $(SF) -o $(OUTDIR)/$(NAME) -fno-stack-protector 10 | 11 | clean: 12 | mkdir -p $(OUTDIR) 13 | rm -f $(OUTDIR)/* 14 | -------------------------------------------------------------------------------- /challenges/2-ghidra-metadata/Makefile: -------------------------------------------------------------------------------- 1 | CC := gcc 2 | SF := $(wildcard *.c) 3 | OUTDIR := bin 4 | NAME := ghidra-meta 5 | 6 | all: clean build 7 | 8 | build: 9 | $(CC) $(SF) -o $(OUTDIR)/$(NAME) -fno-stack-protector 10 | 11 | clean: 12 | mkdir -p $(OUTDIR) 13 | rm -f $(OUTDIR)/* 14 | -------------------------------------------------------------------------------- /challenges/4-called-functions/Makefile: -------------------------------------------------------------------------------- 1 | CC := gcc 2 | SF := $(wildcard *.c) 3 | OUTDIR := bin 4 | NAME := function-calls 5 | 6 | all: clean build 7 | 8 | build: 9 | $(CC) $(SF) -o $(OUTDIR)/$(NAME) -fno-stack-protector 10 | 11 | clean: 12 | mkdir -p $(OUTDIR) 13 | rm -f $(OUTDIR)/* 14 | -------------------------------------------------------------------------------- /challenges/2-ghidra-metadata/solve_2.py: -------------------------------------------------------------------------------- 1 | def run(): 2 | # find the missing function. replace CHANGEME 3 | println(getCurrentProgram().CHANGEME()) # get executable path 4 | 5 | println(getCurrentProgram().CHANGEME()) # get name 6 | 7 | println(getCurrentProgram().CHANGEME()) # get md5 hash -------------------------------------------------------------------------------- /challenges/9-class-functions/Makefile: -------------------------------------------------------------------------------- 1 | CC := g++ 2 | SF := $(wildcard *.cpp) 3 | OUTDIR := bin 4 | NAME := class-functions 5 | 6 | all: clean build 7 | 8 | build: 9 | $(CC) $(SF) -o $(OUTDIR)/$(NAME) -fno-stack-protector 10 | 11 | clean: 12 | mkdir -p $(OUTDIR) 13 | rm -f $(OUTDIR)/* 14 | -------------------------------------------------------------------------------- /solves/solve_8.py: -------------------------------------------------------------------------------- 1 | # finding bytes in memory 2 | # @author 3 | # @category GhidraGolf 4 | # @keybinding 5 | # @menupath 6 | # @toolbar 7 | 8 | evil = "\\x65\\x76\\x69\\x6c" 9 | 10 | addr = findBytes(getCurrentProgram().getMinAddress(), evil) 11 | 12 | println("Evil Offset: 0x" + str(addr.getOffset())) 13 | 14 | -------------------------------------------------------------------------------- /challenges/1-helloworld/solve_1.java: -------------------------------------------------------------------------------- 1 | import ghidra.app.script.GhidraScript; 2 | import ghidra.program.model.listing.*; 3 | import ghidra.program.model.symbol.*; 4 | import ghidra.program.model.address.*; 5 | 6 | public class solve_1 extends GhidraScript { 7 | 8 | @Override 9 | protected void run() throws Exception { 10 | /* Println Here */ 11 | } 12 | } -------------------------------------------------------------------------------- /challenges/1-helloworld/1.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(int argc, char* argv[]) 5 | { 6 | if (argc != 2) 7 | { 8 | printf("hello world!\n"); 9 | } 10 | else 11 | { 12 | char buffer[100]; 13 | memcpy(buffer, argv[1], 99); 14 | printf("hello %s!\n", buffer); 15 | } 16 | 17 | return 0; 18 | } -------------------------------------------------------------------------------- /challenges/2-ghidra-metadata/2.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(int argc, char* argv[]) 5 | { 6 | if (argc != 2) 7 | { 8 | printf("hello world!\n"); 9 | } 10 | else 11 | { 12 | char buffer[100]; 13 | memcpy(buffer, argv[1], 99); 14 | printf("hello %s!\n", buffer); 15 | } 16 | 17 | return 0; 18 | } -------------------------------------------------------------------------------- /solves/solve_7.py: -------------------------------------------------------------------------------- 1 | # basic patching 2 | # @author 3 | # @category GhidraGolf 4 | # @keybinding 5 | # @menupath 6 | # @toolbar 7 | 8 | from ghidra.program.model.data import StringDataType 9 | 10 | program = getCurrentProgram() 11 | 12 | addr = findBytes(program.getMinAddress(), "hello world!") 13 | println("Patching: " + str(addr)) 14 | program.getMemory().setBytes(addr, "hello Ghidra".encode('utf-8')) 15 | 16 | println("Hello Ghidra: " + addr.toString()) 17 | -------------------------------------------------------------------------------- /solves/solve_5.py: -------------------------------------------------------------------------------- 1 | # Using the decompiler 2 | # @author 3 | # @category GhidraGolf 4 | # @keybinding 5 | # @menupath 6 | # @toolbar 7 | 8 | from ghidra.app.decompiler import DecompInterface 9 | from ghidra.util.task import ConsoleTaskMonitor 10 | import hashlib 11 | 12 | program = getCurrentProgram() 13 | ifc = DecompInterface() 14 | ifc.openProgram(program) 15 | code = ifc.decompileFunction(getFirstFunction(), 0, None) 16 | c_code = code.getDecompiledFunction().getC() 17 | println(c_code) 18 | -------------------------------------------------------------------------------- /challenges/2-ghidra-metadata/solve_2.java: -------------------------------------------------------------------------------- 1 | // print ghidra metadata 2 | 3 | import ghidra.app.script.GhidraScript; 4 | 5 | public class solve_2 extends GhidraScript { 6 | 7 | @Override 8 | public void run() { 9 | 10 | /* find the missing function. Replace CHANGEME */ 11 | 12 | println(getCurrentProgram().CHANGEME()); // get executable path 13 | 14 | println(getCurrentProgram().CHANGEME()); // get name 15 | 16 | println(getCurrentProgram().CHANGEME()); // get md5 hash 17 | } 18 | } -------------------------------------------------------------------------------- /solves/solve_6.py: -------------------------------------------------------------------------------- 1 | # decoding strings 2 | # @author 3 | # @category GhidraGolf 4 | # @keybinding 5 | # @menupath 6 | # @toolbar 7 | 8 | import base64 9 | from ghidra.program.model.data import TerminatedStringDataType 10 | 11 | definedData = currentProgram.getListing().getDefinedData(True) 12 | 13 | for data in definedData: 14 | if str(data.getDataType()) == "string" and "=" in data.getValue(): # applicable only to our case of encoded data 15 | encoded = data.getValue() 16 | println("Decoded: " + base64.b64decode(encoded)) 17 | -------------------------------------------------------------------------------- /challenges/3-references/solve_3.py: -------------------------------------------------------------------------------- 1 | import ghidra.app.script.GhidraScript 2 | 3 | functionName = "flag" 4 | 5 | fm = currentProgram.getFunctionManager() 6 | functions = fm.getFunctions(True) 7 | 8 | for func in functions: 9 | if func.getName() == functionName: 10 | 11 | """ 12 | entryPoint = ???? # get the entry point of the function 13 | 14 | refs = ????? # get the references to entryPoint 15 | """ 16 | 17 | break 18 | 19 | for ref in refs: 20 | print("Reference to address offset: 0x" + str(ref.getFromAddress())) 21 | -------------------------------------------------------------------------------- /solves/solve_2.java: -------------------------------------------------------------------------------- 1 | //metadata collection 2 | //@author 3 | //@category GhidraGolf 4 | //@keybinding 5 | //@menupath 6 | //@toolbar 7 | 8 | import ghidra.app.script.GhidraScript; 9 | 10 | public class solve_2 extends GhidraScript { 11 | 12 | @Override 13 | public void run() { 14 | 15 | /* find the missing function. Replace CHANGEME */ 16 | println(getCurrentProgram().getExecutablePath()); // get executable path 17 | println(getCurrentProgram().getName()); // get name 18 | println(getCurrentProgram().getExecutableMD5()); // get md5sum 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /challenges/4-called-functions/solve_4.py: -------------------------------------------------------------------------------- 1 | def run(): 2 | functions = getCurrentProgram().getFunctionManager().getFunctions(True) 3 | 4 | while functions.hasNext(): 5 | func = functions.next() 6 | if func.getName() == "secondMain": 7 | """ 8 | calledFunctions = ????? # get called functions of func 9 | """ 10 | 11 | for calledFunc in calledFunctions: 12 | """ 13 | functionName = ?????? # get name of calledFunc 14 | """ 15 | println("Called function: " + functionName) 16 | 17 | run() 18 | 19 | -------------------------------------------------------------------------------- /solves/solve_9.py: -------------------------------------------------------------------------------- 1 | # finding specific symbol types 2 | # @author 3 | # @category GhidraGolf 4 | # @keybinding 5 | # @menupath 6 | # @toolbar 7 | 8 | from ghidra.program.model.symbol import SymbolType 9 | 10 | def run(): 11 | st = getCurrentProgram().getSymbolTable() 12 | fm = getCurrentProgram().getFunctionManager() 13 | 14 | defSymbols = st.getDefinedSymbols() 15 | 16 | for symbol in defSymbols: 17 | if symbol.getSymbolType() == SymbolType.CLASS and symbol.isGlobal(): 18 | for child in st.getChildren(symbol): 19 | if child.getSymbolType() == SymbolType.FUNCTION: 20 | println(symbol.getName() + " : " + child.getName()) 21 | 22 | run() 23 | -------------------------------------------------------------------------------- /solves/solve_1.java: -------------------------------------------------------------------------------- 1 | //Hello world printing for Ghidra Golf 2 | //@author 3 | //@category GhidraGolf 4 | //@keybinding 5 | //@menupath 6 | //@toolbar 7 | 8 | import ghidra.app.script.GhidraScript; 9 | import ghidra.program.model.mem.*; 10 | import ghidra.program.model.lang.*; 11 | import ghidra.program.model.pcode.*; 12 | import ghidra.program.model.util.*; 13 | import ghidra.program.model.reloc.*; 14 | import ghidra.program.model.data.*; 15 | import ghidra.program.model.block.*; 16 | import ghidra.program.model.symbol.*; 17 | import ghidra.program.model.scalar.*; 18 | import ghidra.program.model.listing.*; 19 | import ghidra.program.model.address.*; 20 | 21 | public class solve_1 extends GhidraScript { 22 | 23 | public void run() throws Exception { 24 | println("Hello world"); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /challenges/4-called-functions/4.c: -------------------------------------------------------------------------------- 1 | // grab all function calls by code 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | int secondMain() 9 | { 10 | FILE *fp; 11 | char buffer[100]; 12 | 13 | fp = fopen("file.txt", "r"); 14 | 15 | fread(buffer, 1, 100, fp); 16 | 17 | printf("%s\n", buffer); 18 | 19 | fclose(fp); 20 | 21 | time_t now = time(NULL); 22 | 23 | long epoch = (long)now; 24 | 25 | printf("Epoch time is %ld\n", epoch); 26 | 27 | for (int i = 0; i < strlen(buffer); i++) { 28 | buffer[i] = tolower(buffer[i]); 29 | } 30 | 31 | printf("%s\n", buffer); 32 | 33 | fp = fopen("file.txt", "w"); 34 | 35 | fwrite(buffer, sizeof(buffer[0]), sizeof(buffer) / sizeof(buffer[0]), fp); 36 | 37 | fclose(fp); 38 | 39 | return 0; 40 | } 41 | 42 | int main() 43 | { 44 | return secondMain(); 45 | } -------------------------------------------------------------------------------- /challenges/4-called-functions/solve_4.java: -------------------------------------------------------------------------------- 1 | // functions that secondMain calls 2 | 3 | import ghidra.app.script.GhidraScript; 4 | 5 | public class solve_4 extends GhidraScript { 6 | 7 | @Override 8 | public void run() throws Exception { 9 | FunctionIterator functions = currentProgram.getFunctionManager().getFunctions(true); 10 | 11 | while (functions.hasNext()) { 12 | Function func = functions.next(); 13 | 14 | if (func.getName().equals("secondMain")) { 15 | // FunctionIterator calledFunctions = ??????; // get called functions from func 16 | 17 | while (calledFunctions.hasNext()) { 18 | Function calledFunc = calledFunctions.next(); 19 | println("Called function: " + calledFunc.???????); // get name from calledFunc 20 | } 21 | } 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /challenges/6-defined-data/6.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | typedef unsigned char uchar; 6 | 7 | static std::string base64_decode(const std::string &in) { 8 | 9 | std::string out; 10 | 11 | std::vector T(256,-1); 12 | for (int i=0; i<64; i++) T["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[i]] = i; 13 | 14 | int val=0, valb=-8; 15 | for (uchar c : in) { 16 | if (T[c] == -1) break; 17 | val = (val << 6) + T[c]; 18 | valb += 6; 19 | if (valb >= 0) { 20 | out.push_back(char((val>>valb)&0xFF)); 21 | valb -= 8; 22 | } 23 | } 24 | return out; 25 | } 26 | 27 | int main(void) 28 | { 29 | const std::string encoded = "d2VsY29tZSB0byB0aGUgUEdHQSE="; 30 | 31 | std::string decoded = base64_decode(encoded); 32 | 33 | std::cout << decoded << std::endl; 34 | 35 | return 0; 36 | } -------------------------------------------------------------------------------- /challenges/3-references/solve_3.java: -------------------------------------------------------------------------------- 1 | import ghidra.app.script.GhidraScript; 2 | import ghidra.program.model.listing.*; 3 | import ghidra.program.model.symbol.*; 4 | import ghidra.program.model.address.*; 5 | 6 | public class solve_3 extends GhidraScript { 7 | 8 | @Override 9 | protected void run() throws Exception { 10 | String functionName = "flag"; 11 | Address entryPoint; 12 | Reference[] refs; 13 | 14 | FunctionManager fm = getCurrentProgram().getFunctionManager(); 15 | Function[] functions = fm.getFunctions(true); 16 | 17 | for (Function function : functions) { 18 | if function.getName().equals(functionName) { 19 | /* 20 | entryPoint = ????; // get the entry point of the function 21 | 22 | refs = ?????; // get the references to entryPoint 23 | */ 24 | break; 25 | } 26 | } 27 | for (Reference reference : refs) { 28 | println("Reference to address: 0x" + reference.getFromAddress().getOffset()); 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /solves/solve_4.java: -------------------------------------------------------------------------------- 1 | //get called functions list 2 | //@author 3 | //@category GhidraGolf 4 | //@keybinding 5 | //@menupath 6 | //@toolbar 7 | 8 | import java.util.Iterator; 9 | import java.util.Set; 10 | 11 | import ghidra.app.script.GhidraScript; 12 | import ghidra.program.model.listing.Function; 13 | import ghidra.program.model.listing.FunctionIterator; 14 | 15 | public class solve_4 extends GhidraScript { 16 | 17 | @Override 18 | public void run() throws Exception { 19 | FunctionIterator functions = currentProgram.getFunctionManager().getFunctions(true); 20 | 21 | while (functions.hasNext()) { 22 | Function func = functions.next(); 23 | 24 | if (func.getName().equals("secondMain")) { 25 | Set calledFunctions = func.getCalledFunctions(null); 26 | Iterator funcs = calledFunctions.iterator(); 27 | 28 | while(funcs.hasNext()) { 29 | Function called = funcs.next(); 30 | println("Called function: " + called.getName()); 31 | 32 | } 33 | 34 | } 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /solves/solve_3.java: -------------------------------------------------------------------------------- 1 | //get references to function calls 2 | //@author 3 | //@category GhidraGolf 4 | //@keybinding 5 | //@menupath 6 | //@toolbar 7 | 8 | import java.util.ArrayList; 9 | 10 | import ghidra.app.script.GhidraScript; 11 | import ghidra.program.model.listing.*; 12 | import ghidra.program.model.symbol.*; 13 | import ghidra.program.model.address.*; 14 | 15 | public class solve_3 extends GhidraScript { 16 | 17 | @Override 18 | protected void run() throws Exception { 19 | String functionName = "flag"; 20 | Address entryPoint; 21 | Reference[] refs = new Reference[100]; 22 | 23 | FunctionManager fm = getCurrentProgram().getFunctionManager(); 24 | FunctionIterator functions = fm.getFunctions(true); 25 | 26 | for (Function function : functions) { 27 | if (function.getName().equals(functionName)) { 28 | /* 29 | entryPoint = ????; // get the entry point of the function 30 | 31 | refs = ?????; // get the references to entryPoint 32 | */ 33 | entryPoint = function.getEntryPoint(); 34 | refs = (getReferencesTo(entryPoint)); 35 | 36 | break; 37 | 38 | } 39 | } 40 | for (Reference reference : refs) { 41 | println("Reference to address: " + reference.getFromAddress()); 42 | 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /challenges/5-decompiler/5.c: -------------------------------------------------------------------------------- 1 | // decompiler 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include // for close 10 | 11 | #define PORT 25 12 | 13 | int main(int argc, char *argv[]) 14 | { 15 | int sockfd, port; 16 | struct sockaddr_in serv_addr; 17 | struct hostent *server; 18 | char buffer[1024]; 19 | 20 | if (argc < 2) { 21 | fprintf(stderr,"usage %s hostname\n", argv[0]); 22 | exit(0); 23 | } 24 | 25 | port = PORT; 26 | server = gethostbyname(argv[1]); 27 | if (server == NULL) { 28 | fprintf(stderr,"ERROR, no such host\n"); 29 | exit(0); 30 | } 31 | 32 | // create a socket 33 | sockfd = socket(AF_INET, SOCK_STREAM, 0); 34 | if (sockfd < 0) 35 | perror("ERROR opening socket"); 36 | 37 | // set up the server address 38 | memset(&serv_addr, 0, sizeof(serv_addr)); 39 | serv_addr.sin_family = AF_INET; 40 | serv_addr.sin_port = htons(port); 41 | memcpy(&serv_addr.sin_addr.s_addr, server->h_addr, server->h_length); 42 | 43 | // connect to the server 44 | if (connect(sockfd, (const struct sockaddr*)&serv_addr, sizeof(serv_addr)) < 0) 45 | perror("ERROR connecting"); 46 | 47 | // send the SMTP request 48 | memset(buffer, 0, 1024); 49 | strcpy(buffer, "HELO smtp.example.com\r\n"); 50 | if (send(sockfd, buffer, strlen(buffer), 0) < 0) 51 | perror("ERROR writing to socket"); 52 | 53 | // get the response 54 | memset(buffer, 0, 1024); 55 | if (recv(sockfd, buffer, 1023, 0) < 0) 56 | perror("ERROR reading from socket"); 57 | 58 | printf("Received response: %s\n", buffer); 59 | 60 | close(sockfd); 61 | return 0; 62 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Putting Green 2 | The "Putting Green" are a series of entry level Ghidra Scripting challenges designed to get a competitor familiar with Ghidra's [FlatProgramAPI](https://ghidra.re/ghidra_docs/api/ghidra/program/flatapi/FlatProgramAPI.html). 3 | 4 | These series of 9 challenges walk a competitor through different scripting scenarios to include patching, searching, metadata extraction, and symbol enumeration. From challenge 1 through 4 a template script is provided to the competitor. Challenges 5 on wards require writing your own in either Python or Java. A description of the challenges can be seen below with corresponding "solve scripts" available in [./solves](./solves). 5 | 6 | These challenges and associated solve scripts are being released in hopes of future competition organizers leveraging them in their own Ghidra Golf Competition or inspiring them for similar challenges. 7 | 8 | ## Challenge Description 9 | 10 | * [1-helloworld](./challenges/1-helloworld): submit a Ghidra Script to simply print "Hello world" to understand the Ghidra Script submission process. 11 | * Note, if using python, ```println``` has to be used to get captured in [analyzeHeadless](https://github.com/NationalSecurityAgency/ghidra/blob/master/Ghidra/RuntimeScripts/Linux/support/analyzeHeadless)' ```-scriptLog``` output. 12 | 13 | * [2-ghidra-metadata](./challenges/2-ghidra-metadata): Obtain metadata about the currently loaded program. 14 | 15 | * [3-references](./challenges/3-references): Obtain references to a given function/address. 16 | 17 | * [4-called-functions](./challenges/4-called-functions): Identify functions that call a specific function. 18 | 19 | * [5-decompiler](./challenges/5-decompiler): programatically print out Ghidra's decompilation of a function. 20 | 21 | * [6-defined-data](./challenges/6-defined-data): Enumerate values in different sections of the binary. 22 | 23 | * [7-hello-patch](./challenges/7-hello-patch): Patch specific bytes within a binary. 24 | 25 | * [8-evil-bytes](./challenges/8-evil-bytes): Identify the evil bytes and print the offset within a binary. 26 | 27 | * [9-class-function](./challenges/9-class-functions): Enumerate methods of given classes. 28 | 29 | 30 | ## Ghidra Scripts 31 | Reference the steps provided in the [ghidra_scripts](https://github.com/ghidragolf/ghidra_scripts) repo for how to add a directory to your Ghidra Script search path. The Ghidra Scripts are identifiable from the GhidraGolf category as shown below. 32 | 33 | ![./.imgs/gg_scripts.png](./.imgs/gg_scripts.png) 34 | -------------------------------------------------------------------------------- /challenges/3-references/3.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | void flag(void) 7 | { 8 | printf("GOLFING!\n"); 9 | return; 10 | } 11 | 12 | int random_number(int min, int max) { 13 | return min + rand() % (max - min + 1); 14 | } 15 | 16 | void print_random_numbers(int min, int max, int num) { 17 | int i; 18 | flag(); 19 | srand(time(0)); 20 | for (i = 0; i < num; i++) { 21 | printf("%d\n", random_number(min, max)); 22 | } 23 | } 24 | 25 | int random_even_number(int min, int max) { 26 | int num = random_number(min, max); 27 | while (num % 2 != 0) { 28 | num = random_number(min, max); 29 | } 30 | return num; 31 | } 32 | 33 | void print_random_even_numbers(int min, int max, int num) { 34 | int i; 35 | srand(time(0)); 36 | for (i = 0; i < num; i++) { 37 | printf("%d\n", random_even_number(min, max)); 38 | } 39 | } 40 | 41 | int random_odd_number(int min, int max) { 42 | int num = random_number(min, max); 43 | while (num % 2 == 0) { 44 | num = random_number(min, max); 45 | } 46 | return num; 47 | } 48 | 49 | void print_random_odd_numbers(int min, int max, int num) { 50 | int i; 51 | srand(time(0)); 52 | for (i = 0; i < num; i++) { 53 | printf("%d\n", random_odd_number(min, max)); 54 | } 55 | } 56 | 57 | int random_prime_number(int min, int max) { 58 | int num, i; 59 | int is_prime; 60 | do { 61 | num = random_number(min, max); 62 | is_prime = 1; 63 | for (i = 2; i < num; i++) { 64 | if (num % i == 0) { 65 | is_prime = 0; 66 | } 67 | } 68 | } while (is_prime == 0); 69 | return num; 70 | } 71 | 72 | void print_random_prime_numbers(int min, int max, int num) { 73 | int i; 74 | srand(time(0)); 75 | flag(); 76 | for (i = 0; i < num; i++) { 77 | printf("%d\n", random_prime_number(min, max)); 78 | } 79 | } 80 | 81 | int random_fibonacci_number(int min, int max) { 82 | int num = random_number(min, max); 83 | flag(); 84 | while (!(num == 1 || num == 2 || num == 3 || num == 5 || num == 8 || num == 13 || num == 21 || num == 34 || num == 55 || num == 89)) { 85 | num = random_number(min, max); 86 | } 87 | return num; 88 | } 89 | 90 | void print_random_fibonacci_numbers(int min, int max, int num) { 91 | int i; 92 | srand(time(0)); 93 | for (i = 0; i < num; i++) { 94 | printf("%d\n", random_fibonacci_number(min, max)); 95 | } 96 | } 97 | 98 | int random_perfect_square_number(int min, int max) { 99 | int num = random_number(min, max); 100 | while (1) { 101 | int temp = (int)sqrt(num); 102 | if (temp * temp == num) { 103 | break; 104 | } 105 | num = random_number(min, max); 106 | } 107 | return num; 108 | } 109 | 110 | void print_random_perfect_square_numbers(int min, int max, int num) { 111 | int i; 112 | srand(time(0)); 113 | for (i = 0; i < num; i++) { 114 | printf("%d\n", random_perfect_square_number(min, max)); 115 | } 116 | } 117 | 118 | int random_palindrome_number(int min, int max) { 119 | int num = random_number(min, max); 120 | while (1) { 121 | int temp = num; 122 | int rev = 0; 123 | flag(); 124 | while (temp > 0) { 125 | int digit = temp % 10; 126 | rev = rev * 10 + digit; 127 | temp /= 10; 128 | } 129 | if (rev == num) { 130 | break; 131 | } 132 | num = random_number(min, max); 133 | } 134 | return num; 135 | } 136 | 137 | void print_random_palindrome_numbers(int min, int max, int num) { 138 | int i; 139 | srand(time(0)); 140 | for (i = 0; i < num; i++) { 141 | printf("%d\n", random_palindrome_number(min, max)); 142 | } 143 | } 144 | 145 | int main() { 146 | int min = 3; 147 | int max = 10; 148 | int num = 7; 149 | 150 | printf("\nRandom Numbers: \n"); 151 | print_random_numbers(min, max, num); 152 | 153 | printf("Random Even Numbers: \n"); 154 | print_random_even_numbers(min, max, num); 155 | 156 | printf("Random Odd Numbers: \n"); 157 | print_random_odd_numbers(min, max, num); 158 | 159 | printf("Random Prime Numbers: \n"); 160 | print_random_prime_numbers(min, max, num); 161 | 162 | printf("Random Fibonacci Numbers: \n"); 163 | print_random_fibonacci_numbers(min, max, num); 164 | 165 | printf("Random Perfect Square Numbers: \n"); 166 | print_random_perfect_square_numbers(min, max, num); 167 | 168 | printf("Random Palindrome Numbers: \n"); 169 | print_random_palindrome_numbers(min, max, num); 170 | 171 | return 0; 172 | } -------------------------------------------------------------------------------- /challenges/8-evil-bytes/8.c: -------------------------------------------------------------------------------- 1 | // find particular bytes in program 2 | 3 | #include 4 | #include 5 | 6 | int file_open(char *filename) 7 | { 8 | FILE *fp; 9 | fp = fopen(filename, "r"); 10 | if (fp != NULL) { 11 | printf("\nFile opened successfully\n"); 12 | fclose(fp); 13 | } else { 14 | printf("\nError opening file\n"); 15 | } 16 | return 0; 17 | } 18 | 19 | int file_create(char *filename) 20 | { 21 | FILE *fp; 22 | fp = fopen(filename, "w"); 23 | if (fp != NULL) { 24 | printf("\nFile created successfully\n"); 25 | fclose(fp); 26 | } else { 27 | printf("\nError creating file\n"); 28 | } 29 | return 0; 30 | } 31 | 32 | int file_read(char *filename) 33 | { 34 | FILE *fp; 35 | fp = fopen(filename, "r"); 36 | if (fp != NULL) { 37 | char c; 38 | printf("\nFile contents:\n"); 39 | while ((c = fgetc(fp)) != EOF) { 40 | printf("%c", c); 41 | } 42 | fclose(fp); 43 | } else { 44 | printf("\nError reading file\n"); 45 | } 46 | return 0; 47 | } 48 | 49 | int file_write(char *filename) 50 | { 51 | FILE *fp; 52 | char evil[] = "evil"; 53 | fp = fopen(filename, "w"); 54 | if (fp != NULL) { 55 | printf("\nEnter the text to be written to the file: \n"); 56 | char c; 57 | while ((c = getchar()) != EOF) { 58 | fputc(c, fp); 59 | for (int i = 0; i < 4; i++) 60 | { 61 | fputc((int)evil[i], fp); 62 | } 63 | } 64 | fclose(fp); 65 | } else { 66 | printf("\nError writing to file\n"); 67 | } 68 | return 0; 69 | } 70 | 71 | int file_delete(char *filename) 72 | { 73 | int status; 74 | status = remove(filename); 75 | if (status == 0) { 76 | printf("\nFile deleted successfully\n"); 77 | } else { 78 | printf("\nError deleting file\n"); 79 | } 80 | return 0; 81 | } 82 | 83 | int file_rename(char *filename, char *newfilename) 84 | { 85 | int status; 86 | status = rename(filename, newfilename); 87 | if (status == 0) { 88 | printf("\nFile renamed successfully\n"); 89 | } else { 90 | printf("\nError renaming file\n"); 91 | } 92 | return 0; 93 | } 94 | 95 | int file_copy(char *filename, char *newfilename) 96 | { 97 | FILE *fp1, *fp2; 98 | fp1 = fopen(filename, "r"); 99 | fp2 = fopen(newfilename, "w"); 100 | if (fp1 != NULL && fp2 != NULL) { 101 | char c; 102 | while ((c = fgetc(fp1)) != EOF) { 103 | fputc(c, fp2); 104 | } 105 | fclose(fp1); 106 | fclose(fp2); 107 | printf("\nFile copied successfully\n"); 108 | } else { 109 | printf("\nError copying file\n"); 110 | } 111 | return 0; 112 | } 113 | 114 | int file_move(char *filename, char *newfilename) 115 | { 116 | int status; 117 | status = rename(filename, newfilename); 118 | if (status == 0) { 119 | printf("\nFile moved successfully\n"); 120 | } else { 121 | printf("\nError moving file\n"); 122 | } 123 | return 0; 124 | } 125 | 126 | int main() 127 | { 128 | int choice; 129 | char filename[100], newfilename[100]; 130 | 131 | printf("Choose an option:\n"); 132 | printf("1. Open a file\n"); 133 | printf("2. Create a file\n"); 134 | printf("3. Read from a file\n"); 135 | printf("4. Write to a file\n"); 136 | printf("5. Delete a file\n"); 137 | printf("6. Rename a file\n"); 138 | printf("7. Copy a file\n"); 139 | printf("8. Move a file\n"); 140 | scanf("%d", &choice); 141 | 142 | switch(choice) { 143 | case 1: 144 | printf("\nEnter the file name: "); 145 | scanf("%s", filename); 146 | file_open(filename); 147 | break; 148 | case 2: 149 | printf("\nEnter the file name: "); 150 | scanf("%s", filename); 151 | file_create(filename); 152 | break; 153 | case 3: 154 | printf("\nEnter the file name: "); 155 | scanf("%s", filename); 156 | file_read(filename); 157 | break; 158 | case 4: 159 | printf("\nEnter the file name: "); 160 | scanf("%s", filename); 161 | file_write(filename); 162 | break; 163 | case 5: 164 | printf("\nEnter the file name: "); 165 | scanf("%s", filename); 166 | file_delete(filename); 167 | break; 168 | case 6: 169 | printf("\nEnter the file name: "); 170 | scanf("%s", filename); 171 | printf("\nEnter the new file name: "); 172 | scanf("%s", newfilename); 173 | file_rename(filename, newfilename); 174 | break; 175 | case 7: 176 | printf("\nEnter the file name: "); 177 | scanf("%s", filename); 178 | printf("\nEnter the new file name: "); 179 | scanf("%s", newfilename); 180 | file_copy(filename, newfilename); 181 | break; 182 | case 8: 183 | printf("\nEnter the file name: "); 184 | scanf("%s", filename); 185 | printf("\nEnter the new file name: "); 186 | scanf("%s", newfilename); 187 | file_move(filename, newfilename); 188 | break; 189 | default: 190 | printf("\nInvalid option chosen\n"); 191 | } 192 | 193 | return 0; 194 | } 195 | -------------------------------------------------------------------------------- /challenges/9-class-functions/9.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | class Book 6 | { 7 | private: 8 | string title; 9 | bool checkedOut; 10 | 11 | public: 12 | Book(string title) 13 | { 14 | this->title = title; 15 | this->checkedOut = false; 16 | } 17 | 18 | string getTitle() 19 | { 20 | return title; 21 | } 22 | 23 | bool isCheckedOut() 24 | { 25 | return checkedOut; 26 | } 27 | 28 | void setCheckedOut(bool checkedOut) 29 | { 30 | this->checkedOut = checkedOut; 31 | } 32 | }; 33 | 34 | class Person 35 | { 36 | private: 37 | string name; 38 | Book** books; 39 | int numBooks; 40 | 41 | public: 42 | Person(string name) 43 | { 44 | this->name = name; 45 | this->books = NULL; 46 | this->numBooks = 0; 47 | } 48 | 49 | string getName() 50 | { 51 | return name; 52 | } 53 | 54 | void addBook(Book* book) 55 | { 56 | Book** tempBooks = new Book*[numBooks + 1]; 57 | for(int i = 0; i < numBooks; i++) 58 | { 59 | tempBooks[i] = books[i]; 60 | } 61 | tempBooks[numBooks] = book; 62 | books = tempBooks; 63 | numBooks++; 64 | } 65 | 66 | int removeBook(Book* book) 67 | { 68 | int index = -1; 69 | for(int i = 0; i < numBooks; i++) 70 | { 71 | if(book == books[i]) 72 | { 73 | index = i; 74 | break; 75 | } 76 | } 77 | if(index != -1) 78 | { 79 | Book** tempBooks = new Book*[numBooks - 1]; 80 | int j = 0; 81 | for(int i = 0; i < numBooks; i++) 82 | { 83 | if(i != index) 84 | { 85 | tempBooks[j] = books[i]; 86 | j++; 87 | } 88 | } 89 | books = tempBooks; 90 | numBooks--; 91 | return 0; 92 | } 93 | else 94 | { 95 | cout << book->getTitle() << " not found in " << name << "'s collection" << endl; 96 | return 1; 97 | } 98 | } 99 | }; 100 | 101 | 102 | 103 | class Library 104 | { 105 | private: 106 | string name; 107 | Book* books; 108 | int numBooks; 109 | Person* people; 110 | int numPeople; 111 | 112 | public: 113 | Library(string name) 114 | { 115 | this->name = name; 116 | this->books = NULL; 117 | this->numBooks = 0; 118 | this->people = NULL; 119 | this->numPeople = 0; 120 | } 121 | 122 | string getName() 123 | { 124 | return name; 125 | } 126 | 127 | void addBook(Book* book) 128 | { 129 | Book** tempBooks = new Book*[numBooks + 1]; 130 | for(int i = 0; i < numBooks; i++) 131 | { 132 | tempBooks[i] = &books[i]; 133 | } 134 | tempBooks[numBooks] = book; 135 | books = *tempBooks; 136 | numBooks++; 137 | } 138 | 139 | void addPerson(Person* person) 140 | { 141 | Person** tempPeople = new Person*[numPeople + 1]; 142 | for(int i = 0; i < numPeople; i++) 143 | { 144 | tempPeople[i] = &people[i]; 145 | } 146 | tempPeople[numPeople] = person; 147 | people = *tempPeople; 148 | numPeople++; 149 | } 150 | 151 | void checkOut(Book* book, Person* person) 152 | { 153 | if(book->isCheckedOut()) 154 | { 155 | cout << book->getTitle() << " is already checked out" << endl; 156 | } 157 | else 158 | { 159 | book->setCheckedOut(true); 160 | person->addBook(book); 161 | cout << book->getTitle() << " checked out to " << person->getName() << endl; 162 | } 163 | } 164 | 165 | void checkIn(Book* book, Person* person) 166 | { 167 | if(book->isCheckedOut()) 168 | { 169 | book->setCheckedOut(false); 170 | if (person->removeBook(book) == 0) 171 | { 172 | cout << book->getTitle() << " checked in" << endl; 173 | } 174 | } 175 | else 176 | { 177 | cout << book->getTitle() << " is not checked out" << endl; 178 | } 179 | } 180 | }; 181 | 182 | class Librarian 183 | { 184 | private: 185 | Person* person; 186 | 187 | public: 188 | Librarian(Person* person) 189 | { 190 | this->person = person; 191 | } 192 | 193 | Person* getPerson() 194 | { 195 | return person; 196 | } 197 | 198 | void checkOutBook(Library* library, Book* book) 199 | { 200 | library->checkOut(book, person); 201 | } 202 | 203 | void checkInBook(Library* library, Book* book) 204 | { 205 | library->checkIn(book, person); 206 | } 207 | }; 208 | 209 | class Patron 210 | { 211 | private: 212 | Person* person; 213 | 214 | public: 215 | Patron(Person* person) 216 | { 217 | this->person = person; 218 | } 219 | 220 | Person* getPerson() 221 | { 222 | return person; 223 | } 224 | 225 | void checkOutBook(Library* library, Book* book) 226 | { 227 | library->checkOut(book, person); 228 | } 229 | }; 230 | 231 | int main() 232 | { 233 | Library library("Library"); 234 | Book book1("Book 1"); 235 | Book book2("Book 2"); 236 | Book book3("Book 3"); 237 | Person person1("Person 1"); 238 | Person person2("Person 2"); 239 | Librarian librarian(&person1); 240 | Patron patron(&person2); 241 | 242 | library.addBook(&book1); 243 | library.addBook(&book2); 244 | library.addPerson(&person1); 245 | library.addPerson(&person2); 246 | 247 | librarian.checkOutBook(&library, &book1); 248 | patron.checkOutBook(&library, &book2); 249 | patron.checkOutBook(&library, &book3); 250 | librarian.checkInBook(&library, &book1); 251 | librarian.checkInBook(&library, &book3); 252 | 253 | return 0; 254 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | --------------------------------------------------------------------------------