| 
									
										
										
										
											2018-12-02 04:29:58 +02:00
										 |  |  | [](https://travis-ci.org/jollheef/out-of-tree) | 
					
						
							| 
									
										
										
										
											2018-10-05 07:47:49 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-02 04:29:58 +02:00
										 |  |  | # [out-of-tree](https://out-of-tree.io)
 | 
					
						
							| 
									
										
										
										
											2018-12-02 02:27:07 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-05 07:47:49 +00:00
										 |  |  | out-of-tree kernel {module, exploit} development tool | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-19 19:39:03 +00:00
										 |  |  |  | 
					
						
							| 
									
										
										
										
											2018-10-08 19:35:54 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-01 17:58:16 +00:00
										 |  |  | ## Requirements
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [Qemu](https://www.qemu.org), [docker](https://docker.com) and [golang](https://golang.org) is required. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-01 18:15:34 +00:00
										 |  |  | Also do not forget to set GOPATH and PATH e.g.: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     $ echo 'export GOPATH=$HOME' >> ~/.bashrc | 
					
						
							|  |  |  |     $ echo 'export PATH=$PATH:$HOME/bin' >> ~/.bashrc | 
					
						
							|  |  |  |     $ source ~/.bashrc | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-01 17:58:16 +00:00
										 |  |  | ### Gentoo
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # emerge app-emulation/qemu app-emulation/docker dev-lang/go | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ### macOS
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     $ brew install go qemu | 
					
						
							|  |  |  |     $ brew cask install docker | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-02 05:04:15 +02:00
										 |  |  | ## Build from source
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-02 12:15:39 +00:00
										 |  |  |     $ go get -u github.com/jollheef/out-of-tree | 
					
						
							| 
									
										
										
										
											2018-12-01 17:05:40 +00:00
										 |  |  |     $ out-of-tree bootstrap | 
					
						
							| 
									
										
										
										
											2018-10-06 17:47:13 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-01 17:05:40 +00:00
										 |  |  | Then you can check it on kernel module example: | 
					
						
							| 
									
										
										
										
											2018-10-08 20:15:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-01 17:05:40 +00:00
										 |  |  |     $ cd $GOPATH/github.com/jollheef/out-of-tree/examples/kernel-module | 
					
						
							|  |  |  |     $ out-of-tree kernel autogen # generate kernels based on .out-of-tree.toml | 
					
						
							|  |  |  |     $ out-of-tree pew | 
					
						
							| 
									
										
										
										
											2018-10-08 20:15:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-27 15:00:41 +00:00
										 |  |  | ## Examples
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-27 17:37:58 +00:00
										 |  |  | Run by absolute path | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     $ out-of-tree --path /path/to/exploit/directory pew | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-27 15:00:41 +00:00
										 |  |  | Test only with one kernel: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     $ out-of-tree pew --kernel='Ubuntu:4.10.0-30-generic' | 
					
						
							| 
									
										
										
										
											2018-10-27 15:33:54 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-25 14:46:29 +00:00
										 |  |  | Run debug environment: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     $ out-of-tree debug --kernel='Ubuntu:4.10.0-30-generic' | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-27 20:07:52 +00:00
										 |  |  | Test binary module/exploit with implicit defined test ($BINARY_test) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     $ out-of-tree pew --binary /path/to/exploit | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Test binary module/exploit with explicit defined test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     $ out-of-tree pew --binary /path/to/exploit --test /path/to/exploit_test | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-27 15:33:54 +00:00
										 |  |  | Guess work kernels: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     $ out-of-tree pew --guess | 
					
						
							| 
									
										
										
										
											2018-10-27 17:37:58 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | Use custom kernels config | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     $ out-of-tree --kernels /path/to/kernels.toml pew | 
					
						
							| 
									
										
										
										
											2018-12-01 17:05:40 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-01 17:16:34 +00:00
										 |  |  | ## Generate all kernels
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Does not required if you dont need to use `--guess`. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     $ cd $GOPATH/src/github.com/jollheef/out-of-tree/tools/kernel-factory | 
					
						
							|  |  |  |     $ ./bootstrap.sh # more than 6-8 hours for all kernels | 
					
						
							|  |  |  |     $ export OUT_OF_TREE_KCFG=$GOPATH/src/github.com/jollheef/out-of-tree/tools/kernel-factory/output/kernels.toml | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-01 17:05:40 +00:00
										 |  |  | ## Development
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Read [Qemu API](qemu/README.md). | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ### Generate images
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     $ cd $GOPATH/src/github.com/jollheef/out-of-tree/tools/qemu-debian-img/ | 
					
						
							|  |  |  |     $ docker run --privileged -v $(pwd):/shared -e IMAGE=/shared/ubuntu1404.img -e RELEASE=trusty -t gen-ubuntu1804-image | 
					
						
							|  |  |  |     $ docker run --privileged -v $(pwd):/shared -e IMAGE=/shared/ubuntu1604.img -e RELEASE=xenial -t gen-ubuntu1804-image |