├── README.md ├── config_files └── dnsmasq.conf ├── filecp.sh ├── imgwatch.sh └── systemd_services ├── godns.service ├── imgwatch.service └── webchan.service /README.md: -------------------------------------------------------------------------------- 1 | ## Repo for the paper "USB Devices phoning home" 2 | 3 | ### Setup 4 | 5 | General information about our armory setup 6 | 7 | #### Misc 8 | 9 | * add _sudo_ group 10 | * uncomment _sudo_ group line (visudo) 11 | * add users with groups, add users to _sudo_ group 12 | 13 | #### Network 14 | 15 | * Default config in `/etc/systemd/network/gadget-deadbeef.network` 16 | * Changed default IP to `10.1.1.1` and gateway to `10.1.1.2` 17 | * Host-Script to NAT network traffic for the armory: 18 | 19 | ```bash 20 | #!/bin/bash 21 | /sbin/ip l s usb0 up 22 | /sbin/ip addr add 10.1.1.2/24 dev usb0 23 | /sbin/iptables -t nat -A POSTROUTING -s 10.1.1.1/32 -o wlan0 -j MASQUERADE 24 | echo 1 > /proc/sys/net/ipv4/ip_forward 25 | ``` 26 | 27 | #### Installed Packages 28 | 29 | * dnsmasq 30 | * inotify-tools 31 | * vim 32 | * base-devel 33 | * screen 34 | * tmux 35 | * wget 36 | * go: 37 | 38 | ```console 39 | # cd /opt 40 | # git clone https://go.googlesource.com/go 41 | # cd go 42 | # git checkout go1.4.2 43 | # cd src 44 | # ./all.bash 45 | ``` 46 | 47 | * The file `file_test.go` had to be deleted from `src/net` as the test failed (see [source](https://github.com/golang/go/issues/10730)) 48 | * Add Go env settings to `/etc/profile` 49 | 50 | ```console 51 | GOROOT=/opt/go 52 | export GOROOT 53 | GOPATH=$HOME/go 54 | export GOPATH 55 | 56 | PATH="/usr/local/sbin:/usr/local/bin:/usr/bin:$GOROOT/bin" 57 | export PATH 58 | ``` 59 | 60 | #### USB Gadget 61 | 62 | Switched from g_cdc to g_multi because it includes g_mass_storage. 63 | Using the PID and VID of a SAMSUNG N7000 to make Windows 8 load the necessary drivers. 64 | 65 | ```console 66 | # cd /etc/modprobe.d/ 67 | # echo 'options g_multi dev_addr=de:ad:be:ef:00:01 iManufacturer="Android" idVendor=0x04e8 idProduct=0x6864 file="/root/pendrive.img"' > gadget-deadbeef_multi.conf 68 | # dd if=/dev/zero bs=1M count=128 of=/root/pendrive.img 69 | # use fdisk to create one partition in pendrive.img 70 | # and use mkfs.vat -F 32 to give it a FAT32 filesystem 71 | # cd /etc/modules-load.d/ 72 | # mv gadget-deadbeef.conf gadget-deadbeef.off 73 | # echo 'g_multi' > gadget-deadbeef_multi.conf 74 | ``` 75 | 76 | Rebuild g_multi without ecm cdc support for better windows compatibility: 77 | 78 | ```console 79 | svn co https://github.com/archlinuxarm/PKGBUILDs/trunk/core/linux-armv7 80 | make oldconfig && make prepare 81 | make scripts 82 | make menuconfig # enable usb gadget drivers and enable only rndis for g_multi 83 | make -C /full/path/linux-armv7/src/linux-4.1/ M=/full/path/linux-armv7/src/linux-4.1/drivers/usb/gadget/legacy/ 84 | cp linux-armv7/src/linux-4.1/drivers/usb/gadget/legacy/g_multi.ko /lib/modules/$(uname -r)/kernel/drivers/usb/gadget/ 85 | sudo depmod -a 86 | ``` 87 | 88 | #### Services 89 | 90 | * Copy [imgwatch.sh and filecp.sh](https://github.com/willnix/usbpoc/tree/master) to /opt 91 | * Copy [godns]((https://github.com/willnix/godns/tree/master) to /opt/godns/ 92 | * Copy [webchan]((https://github.com/willnix/webchan/tree/master) to /opt/webchan/ and edit the file js/ga.js. Set the IP address of your remote server and the usb armory. 93 | * Deploy the [systemd.service files](https://github.com/willnix/usbpoc/tree/master/systemd_services) in `/etc/systemd/system/multi-user.target.wants` 94 | 95 | Enable them by running: 96 | ```console 97 | # systemctl daemon-reload 98 | ``` 99 | 100 | * Copy the [dnsmasq config]https://github.com/willnix/usbpoc/blob/master/config_files/dnsmasq.conf) to /etc/dnsmasq.conf 101 | -------------------------------------------------------------------------------- /config_files/dnsmasq.conf: -------------------------------------------------------------------------------- 1 | # Configuration file for dnsmasq. 2 | # 3 | # Format is one option per line, legal options are the same 4 | # as the long options legal on the command line. See 5 | # "/usr/sbin/dnsmasq --help" or "man 8 dnsmasq" for details. 6 | 7 | # Listen on this specific port instead of the standard DNS port 8 | # (53). Setting this to zero completely disables DNS function, 9 | # leaving only DHCP and/or TFTP. 10 | port=0 11 | 12 | # The following two options make you a better netizen, since they 13 | # tell dnsmasq to filter out queries which the public DNS cannot 14 | # answer, and which load the servers (especially the root servers) 15 | # unnecessarily. If you have a dial-on-demand link they also stop 16 | # these requests from bringing up the link unnecessarily. 17 | 18 | # Never forward plain names (without a dot or domain part) 19 | #domain-needed 20 | # Never forward addresses in the non-routed address spaces. 21 | #bogus-priv 22 | 23 | # Uncomment these to enable DNSSEC validation and caching: 24 | # (Requires dnsmasq to be built with DNSSEC option.) 25 | #conf-file=/usr/share/dnsmasq/trust-anchors.conf 26 | #dnssec 27 | 28 | # Replies which are not DNSSEC signed may be legitimate, because the domain 29 | # is unsigned, or may be forgeries. Setting this option tells dnsmasq to 30 | # check that an unsigned reply is OK, by finding a secure proof that a DS 31 | # record somewhere between the root and the domain does not exist. 32 | # The cost of setting this is that even queries in unsigned domains will need 33 | # one or more extra DNS queries to verify. 34 | #dnssec-check-unsigned 35 | 36 | # Uncomment this to filter useless windows-originated DNS requests 37 | # which can trigger dial-on-demand links needlessly. 38 | # Note that (amongst other things) this blocks all SRV requests, 39 | # so don't use it if you use eg Kerberos, SIP, XMMP or Google-talk. 40 | # This option only affects forwarding, SRV records originating for 41 | # dnsmasq (via srv-host= lines) are not suppressed by it. 42 | #filterwin2k 43 | 44 | # Change this line if you want dns to get its upstream servers from 45 | # somewhere other that /etc/resolv.conf 46 | #resolv-file= 47 | 48 | # By default, dnsmasq will send queries to any of the upstream 49 | # servers it knows about and tries to favour servers to are known 50 | # to be up. Uncommenting this forces dnsmasq to try each query 51 | # with each server strictly in the order they appear in 52 | # /etc/resolv.conf 53 | #strict-order 54 | 55 | # If you don't want dnsmasq to read /etc/resolv.conf or any other 56 | # file, getting its servers from this file instead (see below), then 57 | # uncomment this. 58 | no-resolv 59 | 60 | # If you don't want dnsmasq to poll /etc/resolv.conf or other resolv 61 | # files for changes and re-read them then uncomment this. 62 | #no-poll 63 | 64 | # Add other name servers here, with domain specs if they are for 65 | # non-public domains. 66 | server=127.0.0.1#5353 67 | 68 | # Example of routing PTR queries to nameservers: this will send all 69 | # address->name queries for 192.168.3/24 to nameserver 10.1.2.3 70 | #server=/3.168.192.in-addr.arpa/10.1.2.3 71 | 72 | # Add local-only domains here, queries in these domains are answered 73 | # from /etc/hosts or DHCP only. 74 | #local=/www.google-analytics.com/ 75 | 76 | # Add domains which you want to force to an IP address here. 77 | # The example below send any host in double-click.net to a local 78 | # web-server. 79 | #address=/www.google-analalytics.com/10.1.1.1 80 | 81 | # --address (and --server) work with IPv6 addresses too. 82 | #address=/www.thekelleys.org.uk/fe80::20d:60ff:fe36:f83 83 | 84 | # Add the IPs of all queries to yahoo.com, google.com, and their 85 | # subdomains to the vpn and search ipsets: 86 | #ipset=/yahoo.com/google.com/vpn,search 87 | 88 | # You can control how dnsmasq talks to a server: this forces 89 | # queries to 10.1.2.3 to be routed via eth1 90 | # server=10.1.2.3@eth1 91 | 92 | # and this sets the source (ie local) address used to talk to 93 | # 10.1.2.3 to 192.168.1.1 port 55 (there must be a interface with that 94 | # IP on the machine, obviously). 95 | # server=10.1.2.3@192.168.1.1#55 96 | 97 | # If you want dnsmasq to change uid and gid to something other 98 | # than the default, edit the following lines. 99 | #user= 100 | #group= 101 | 102 | # If you want dnsmasq to listen for DHCP and DNS requests only on 103 | # specified interfaces (and the loopback) give the name of the 104 | # interface (eg eth0) here. 105 | # Repeat the line for more than one interface. 106 | interface=usb0 107 | # Or you can specify which interface _not_ to listen on 108 | except-interface=lo 109 | # Or which to listen on by address (remember to include 127.0.0.1 if 110 | # you use this.) 111 | #listen-address= 112 | # If you want dnsmasq to provide only DNS service on an interface, 113 | # configure it as shown above, and then use the following line to 114 | # disable DHCP and TFTP on it. 115 | #no-dhcp-interface= 116 | 117 | # On systems which support it, dnsmasq binds the wildcard address, 118 | # even when it is listening on only some interfaces. It then discards 119 | # requests that it shouldn't reply to. This has the advantage of 120 | # working even when interfaces come and go and change address. If you 121 | # want dnsmasq to really bind only the interfaces it is listening on, 122 | # uncomment this option. About the only time you may need this is when 123 | # running another nameserver on the same machine. 124 | #bind-interfaces 125 | 126 | # If you don't want dnsmasq to read /etc/hosts, uncomment the 127 | # following line. 128 | #no-hosts 129 | # or if you want it to read another file, as well as /etc/hosts, use 130 | # this. 131 | #addn-hosts=/etc/banner_add_hosts 132 | 133 | # Set this (and domain: see below) if you want to have a domain 134 | # automatically added to simple names in a hosts-file. 135 | #expand-hosts 136 | 137 | # Set the domain for dnsmasq. this is optional, but if it is set, it 138 | # does the following things. 139 | # 1) Allows DHCP hosts to have fully qualified domain names, as long 140 | # as the domain part matches this setting. 141 | # 2) Sets the "domain" DHCP option thereby potentially setting the 142 | # domain of all systems configured by DHCP 143 | # 3) Provides the domain part for "expand-hosts" 144 | #domain=thekelleys.org.uk 145 | 146 | # Set a different domain for a particular subnet 147 | #domain=wireless.thekelleys.org.uk,192.168.2.0/24 148 | 149 | # Same idea, but range rather then subnet 150 | #domain=reserved.thekelleys.org.uk,192.68.3.100,192.168.3.200 151 | 152 | # Uncomment this to enable the integrated DHCP server, you need 153 | # to supply the range of addresses available for lease and optionally 154 | # a lease time. If you have more than one network, you will need to 155 | # repeat this for each network on which you want to supply DHCP 156 | # service. 157 | dhcp-range=10.1.1.2,10.1.1.150,12h 158 | 159 | # This is an example of a DHCP range where the netmask is given. This 160 | # is needed for networks we reach the dnsmasq DHCP server via a relay 161 | # agent. If you don't know what a DHCP relay agent is, you probably 162 | # don't need to worry about this. 163 | #dhcp-range=192.168.0.50,192.168.0.150,255.255.255.0,12h 164 | 165 | # This is an example of a DHCP range which sets a tag, so that 166 | # some DHCP options may be set only for this network. 167 | #dhcp-range=set:red,192.168.0.50,192.168.0.150 168 | 169 | # Use this DHCP range only when the tag "green" is set. 170 | #dhcp-range=tag:green,192.168.0.50,192.168.0.150,12h 171 | 172 | # Specify a subnet which can't be used for dynamic address allocation, 173 | # is available for hosts with matching --dhcp-host lines. Note that 174 | # dhcp-host declarations will be ignored unless there is a dhcp-range 175 | # of some type for the subnet in question. 176 | # In this case the netmask is implied (it comes from the network 177 | # configuration on the machine running dnsmasq) it is possible to give 178 | # an explicit netmask instead. 179 | #dhcp-range=192.168.0.0,static 180 | 181 | # Enable DHCPv6. Note that the prefix-length does not need to be specified 182 | # and defaults to 64 if missing/ 183 | #dhcp-range=1234::2, 1234::500, 64, 12h 184 | 185 | # Do Router Advertisements, BUT NOT DHCP for this subnet. 186 | #dhcp-range=1234::, ra-only 187 | 188 | # Do Router Advertisements, BUT NOT DHCP for this subnet, also try and 189 | # add names to the DNS for the IPv6 address of SLAAC-configured dual-stack 190 | # hosts. Use the DHCPv4 lease to derive the name, network segment and 191 | # MAC address and assume that the host will also have an 192 | # IPv6 address calculated using the SLAAC alogrithm. 193 | #dhcp-range=1234::, ra-names 194 | 195 | # Do Router Advertisements, BUT NOT DHCP for this subnet. 196 | # Set the lifetime to 46 hours. (Note: minimum lifetime is 2 hours.) 197 | #dhcp-range=1234::, ra-only, 48h 198 | 199 | # Do DHCP and Router Advertisements for this subnet. Set the A bit in the RA 200 | # so that clients can use SLAAC addresses as well as DHCP ones. 201 | #dhcp-range=1234::2, 1234::500, slaac 202 | 203 | # Do Router Advertisements and stateless DHCP for this subnet. Clients will 204 | # not get addresses from DHCP, but they will get other configuration information. 205 | # They will use SLAAC for addresses. 206 | #dhcp-range=1234::, ra-stateless 207 | 208 | # Do stateless DHCP, SLAAC, and generate DNS names for SLAAC addresses 209 | # from DHCPv4 leases. 210 | #dhcp-range=1234::, ra-stateless, ra-names 211 | 212 | # Do router advertisements for all subnets where we're doing DHCPv6 213 | # Unless overriden by ra-stateless, ra-names, et al, the router 214 | # advertisements will have the M and O bits set, so that the clients 215 | # get addresses and configuration from DHCPv6, and the A bit reset, so the 216 | # clients don't use SLAAC addresses. 217 | #enable-ra 218 | 219 | # Supply parameters for specified hosts using DHCP. There are lots 220 | # of valid alternatives, so we will give examples of each. Note that 221 | # IP addresses DO NOT have to be in the range given above, they just 222 | # need to be on the same network. The order of the parameters in these 223 | # do not matter, it's permissible to give name, address and MAC in any 224 | # order. 225 | 226 | # Always allocate the host with Ethernet address 11:22:33:44:55:66 227 | # The IP address 192.168.0.60 228 | #dhcp-host=11:22:33:44:55:66,192.168.0.60 229 | 230 | # Always set the name of the host with hardware address 231 | # 11:22:33:44:55:66 to be "fred" 232 | #dhcp-host=11:22:33:44:55:66,fred 233 | 234 | # Always give the host with Ethernet address 11:22:33:44:55:66 235 | # the name fred and IP address 192.168.0.60 and lease time 45 minutes 236 | #dhcp-host=11:22:33:44:55:66,fred,192.168.0.60,45m 237 | 238 | # Give a host with Ethernet address 11:22:33:44:55:66 or 239 | # 12:34:56:78:90:12 the IP address 192.168.0.60. Dnsmasq will assume 240 | # that these two Ethernet interfaces will never be in use at the same 241 | # time, and give the IP address to the second, even if it is already 242 | # in use by the first. Useful for laptops with wired and wireless 243 | # addresses. 244 | #dhcp-host=11:22:33:44:55:66,12:34:56:78:90:12,192.168.0.60 245 | 246 | # Give the machine which says its name is "bert" IP address 247 | # 192.168.0.70 and an infinite lease 248 | #dhcp-host=bert,192.168.0.70,infinite 249 | 250 | # Always give the host with client identifier 01:02:02:04 251 | # the IP address 192.168.0.60 252 | #dhcp-host=id:01:02:02:04,192.168.0.60 253 | 254 | # Always give the Infiniband interface with hardware address 255 | # 80:00:00:48:fe:80:00:00:00:00:00:00:f4:52:14:03:00:28:05:81 the 256 | # ip address 192.168.0.61. The client id is derived from the prefix 257 | # ff:00:00:00:00:00:02:00:00:02:c9:00 and the last 8 pairs of 258 | # hex digits of the hardware address. 259 | #dhcp-host=id:ff:00:00:00:00:00:02:00:00:02:c9:00:f4:52:14:03:00:28:05:81,192.168.0.61 260 | 261 | # Always give the host with client identifier "marjorie" 262 | # the IP address 192.168.0.60 263 | #dhcp-host=id:marjorie,192.168.0.60 264 | 265 | # Enable the address given for "judge" in /etc/hosts 266 | # to be given to a machine presenting the name "judge" when 267 | # it asks for a DHCP lease. 268 | #dhcp-host=judge 269 | 270 | # Never offer DHCP service to a machine whose Ethernet 271 | # address is 11:22:33:44:55:66 272 | #dhcp-host=11:22:33:44:55:66,ignore 273 | 274 | # Ignore any client-id presented by the machine with Ethernet 275 | # address 11:22:33:44:55:66. This is useful to prevent a machine 276 | # being treated differently when running under different OS's or 277 | # between PXE boot and OS boot. 278 | #dhcp-host=11:22:33:44:55:66,id:* 279 | 280 | # Send extra options which are tagged as "red" to 281 | # the machine with Ethernet address 11:22:33:44:55:66 282 | #dhcp-host=11:22:33:44:55:66,set:red 283 | 284 | # Send extra options which are tagged as "red" to 285 | # any machine with Ethernet address starting 11:22:33: 286 | #dhcp-host=11:22:33:*:*:*,set:red 287 | 288 | # Give a fixed IPv6 address and name to client with 289 | # DUID 00:01:00:01:16:d2:83:fc:92:d4:19:e2:d8:b2 290 | # Note the MAC addresses CANNOT be used to identify DHCPv6 clients. 291 | # Note also the they [] around the IPv6 address are obilgatory. 292 | #dhcp-host=id:00:01:00:01:16:d2:83:fc:92:d4:19:e2:d8:b2, fred, [1234::5] 293 | 294 | # Ignore any clients which are not specified in dhcp-host lines 295 | # or /etc/ethers. Equivalent to ISC "deny unknown-clients". 296 | # This relies on the special "known" tag which is set when 297 | # a host is matched. 298 | #dhcp-ignore=tag:!known 299 | 300 | # Send extra options which are tagged as "red" to any machine whose 301 | # DHCP vendorclass string includes the substring "Linux" 302 | #dhcp-vendorclass=set:red,Linux 303 | 304 | # Send extra options which are tagged as "red" to any machine one 305 | # of whose DHCP userclass strings includes the substring "accounts" 306 | #dhcp-userclass=set:red,accounts 307 | 308 | # Send extra options which are tagged as "red" to any machine whose 309 | # MAC address matches the pattern. 310 | #dhcp-mac=set:red,00:60:8C:*:*:* 311 | 312 | # If this line is uncommented, dnsmasq will read /etc/ethers and act 313 | # on the ethernet-address/IP pairs found there just as if they had 314 | # been given as --dhcp-host options. Useful if you keep 315 | # MAC-address/host mappings there for other purposes. 316 | #read-ethers 317 | 318 | # Send options to hosts which ask for a DHCP lease. 319 | # See RFC 2132 for details of available options. 320 | # Common options can be given to dnsmasq by name: 321 | # run "dnsmasq --help dhcp" to get a list. 322 | # Note that all the common settings, such as netmask and 323 | # broadcast address, DNS server and default route, are given 324 | # sane defaults by dnsmasq. You very likely will not need 325 | # any dhcp-options. If you use Windows clients and Samba, there 326 | # are some options which are recommended, they are detailed at the 327 | # end of this section. 328 | 329 | # Override the default route supplied by dnsmasq, which assumes the 330 | # router is the same machine as the one running dnsmasq. 331 | #dhcp-option=3,1.2.3.4 332 | 333 | # Do the same thing, but using the option name 334 | #dhcp-option=option:router,1.2.3.4 335 | 336 | # Override the default route supplied by dnsmasq and send no default 337 | # route at all. Note that this only works for the options sent by 338 | # default (1, 3, 6, 12, 28) the same line will send a zero-length option 339 | # for all other option numbers. 340 | #dhcp-option=3 341 | 342 | # Set the DNS Server 343 | dhcp-option=option:dns-server,10.1.1.1,8.8.8.8 344 | 345 | # Do not set a gateway via DHCP 346 | dhcp-option=3 347 | 348 | # Set the NTP time server addresses to 192.168.0.4 and 10.10.0.5 349 | #dhcp-option=option:ntp-server,192.168.0.4,10.10.0.5 350 | 351 | # Send DHCPv6 option. Note [] around IPv6 addresses. 352 | #dhcp-option=option6:dns-server,[1234::77],[1234::88] 353 | 354 | # Send DHCPv6 option for namservers as the machine running 355 | # dnsmasq and another. 356 | #dhcp-option=option6:dns-server,[::],[1234::88] 357 | 358 | # Ask client to poll for option changes every six hours. (RFC4242) 359 | #dhcp-option=option6:information-refresh-time,6h 360 | 361 | # Set option 58 client renewal time (T1). Defaults to half of the 362 | # lease time if not specified. (RFC2132) 363 | #dhcp-option=option:T1:1m 364 | 365 | # Set option 59 rebinding time (T2). Defaults to 7/8 of the 366 | # lease time if not specified. (RFC2132) 367 | #dhcp-option=option:T2:2m 368 | 369 | # Set the NTP time server address to be the same machine as 370 | # is running dnsmasq 371 | #dhcp-option=42,0.0.0.0 372 | 373 | # Set the NIS domain name to "welly" 374 | #dhcp-option=40,welly 375 | 376 | # Set the default time-to-live to 50 377 | #dhcp-option=23,50 378 | 379 | # Set the "all subnets are local" flag 380 | #dhcp-option=27,1 381 | 382 | # Send the etherboot magic flag and then etherboot options (a string). 383 | #dhcp-option=128,e4:45:74:68:00:00 384 | #dhcp-option=129,NIC=eepro100 385 | 386 | # Specify an option which will only be sent to the "red" network 387 | # (see dhcp-range for the declaration of the "red" network) 388 | # Note that the tag: part must precede the option: part. 389 | #dhcp-option = tag:red, option:ntp-server, 192.168.1.1 390 | 391 | # The following DHCP options set up dnsmasq in the same way as is specified 392 | # for the ISC dhcpcd in 393 | # http://www.samba.org/samba/ftp/docs/textdocs/DHCP-Server-Configuration.txt 394 | # adapted for a typical dnsmasq installation where the host running 395 | # dnsmasq is also the host running samba. 396 | # you may want to uncomment some or all of them if you use 397 | # Windows clients and Samba. 398 | #dhcp-option=19,0 # option ip-forwarding off 399 | #dhcp-option=44,0.0.0.0 # set netbios-over-TCP/IP nameserver(s) aka WINS server(s) 400 | #dhcp-option=45,0.0.0.0 # netbios datagram distribution server 401 | #dhcp-option=46,8 # netbios node type 402 | 403 | # Send an empty WPAD option. This may be REQUIRED to get windows 7 to behave. 404 | #dhcp-option=252,"\n" 405 | 406 | # Send RFC-3397 DNS domain search DHCP option. WARNING: Your DHCP client 407 | # probably doesn't support this...... 408 | #dhcp-option=option:domain-search,eng.apple.com,marketing.apple.com 409 | 410 | # Send RFC-3442 classless static routes (note the netmask encoding) 411 | #dhcp-option=121,192.168.1.0/24,1.2.3.4,10.0.0.0/8,5.6.7.8 412 | 413 | # Send vendor-class specific options encapsulated in DHCP option 43. 414 | # The meaning of the options is defined by the vendor-class so 415 | # options are sent only when the client supplied vendor class 416 | # matches the class given here. (A substring match is OK, so "MSFT" 417 | # matches "MSFT" and "MSFT 5.0"). This example sets the 418 | # mtftp address to 0.0.0.0 for PXEClients. 419 | #dhcp-option=vendor:PXEClient,1,0.0.0.0 420 | 421 | # Send microsoft-specific option to tell windows to release the DHCP lease 422 | # when it shuts down. Note the "i" flag, to tell dnsmasq to send the 423 | # value as a four-byte integer - that's what microsoft wants. See 424 | # http://technet2.microsoft.com/WindowsServer/en/library/a70f1bb7-d2d4-49f0-96d6-4b7414ecfaae1033.mspx?mfr=true 425 | #dhcp-option=vendor:MSFT,2,1i 426 | 427 | # Send the Encapsulated-vendor-class ID needed by some configurations of 428 | # Etherboot to allow is to recognise the DHCP server. 429 | #dhcp-option=vendor:Etherboot,60,"Etherboot" 430 | 431 | # Send options to PXELinux. Note that we need to send the options even 432 | # though they don't appear in the parameter request list, so we need 433 | # to use dhcp-option-force here. 434 | # See http://syslinux.zytor.com/pxe.php#special for details. 435 | # Magic number - needed before anything else is recognised 436 | #dhcp-option-force=208,f1:00:74:7e 437 | # Configuration file name 438 | #dhcp-option-force=209,configs/common 439 | # Path prefix 440 | #dhcp-option-force=210,/tftpboot/pxelinux/files/ 441 | # Reboot time. (Note 'i' to send 32-bit value) 442 | #dhcp-option-force=211,30i 443 | 444 | # Set the boot filename for netboot/PXE. You will only need 445 | # this is you want to boot machines over the network and you will need 446 | # a TFTP server; either dnsmasq's built in TFTP server or an 447 | # external one. (See below for how to enable the TFTP server.) 448 | #dhcp-boot=pxelinux.0 449 | 450 | # The same as above, but use custom tftp-server instead machine running dnsmasq 451 | #dhcp-boot=pxelinux,server.name,192.168.1.100 452 | 453 | # Boot for Etherboot gPXE. The idea is to send two different 454 | # filenames, the first loads gPXE, and the second tells gPXE what to 455 | # load. The dhcp-match sets the gpxe tag for requests from gPXE. 456 | #dhcp-match=set:gpxe,175 # gPXE sends a 175 option. 457 | #dhcp-boot=tag:!gpxe,undionly.kpxe 458 | #dhcp-boot=mybootimage 459 | 460 | # Encapsulated options for Etherboot gPXE. All the options are 461 | # encapsulated within option 175 462 | #dhcp-option=encap:175, 1, 5b # priority code 463 | #dhcp-option=encap:175, 176, 1b # no-proxydhcp 464 | #dhcp-option=encap:175, 177, string # bus-id 465 | #dhcp-option=encap:175, 189, 1b # BIOS drive code 466 | #dhcp-option=encap:175, 190, user # iSCSI username 467 | #dhcp-option=encap:175, 191, pass # iSCSI password 468 | 469 | # Test for the architecture of a netboot client. PXE clients are 470 | # supposed to send their architecture as option 93. (See RFC 4578) 471 | #dhcp-match=peecees, option:client-arch, 0 #x86-32 472 | #dhcp-match=itanics, option:client-arch, 2 #IA64 473 | #dhcp-match=hammers, option:client-arch, 6 #x86-64 474 | #dhcp-match=mactels, option:client-arch, 7 #EFI x86-64 475 | 476 | # Do real PXE, rather than just booting a single file, this is an 477 | # alternative to dhcp-boot. 478 | #pxe-prompt="What system shall I netboot?" 479 | # or with timeout before first available action is taken: 480 | #pxe-prompt="Press F8 for menu.", 60 481 | 482 | # Available boot services. for PXE. 483 | #pxe-service=x86PC, "Boot from local disk" 484 | 485 | # Loads /pxelinux.0 from dnsmasq TFTP server. 486 | #pxe-service=x86PC, "Install Linux", pxelinux 487 | 488 | # Loads /pxelinux.0 from TFTP server at 1.2.3.4. 489 | # Beware this fails on old PXE ROMS. 490 | #pxe-service=x86PC, "Install Linux", pxelinux, 1.2.3.4 491 | 492 | # Use bootserver on network, found my multicast or broadcast. 493 | #pxe-service=x86PC, "Install windows from RIS server", 1 494 | 495 | # Use bootserver at a known IP address. 496 | #pxe-service=x86PC, "Install windows from RIS server", 1, 1.2.3.4 497 | 498 | # If you have multicast-FTP available, 499 | # information for that can be passed in a similar way using options 1 500 | # to 5. See page 19 of 501 | # http://download.intel.com/design/archives/wfm/downloads/pxespec.pdf 502 | 503 | 504 | # Enable dnsmasq's built-in TFTP server 505 | #enable-tftp 506 | 507 | # Set the root directory for files available via FTP. 508 | #tftp-root=/var/ftpd 509 | 510 | # Do not abort if the tftp-root is unavailable 511 | #tftp-no-fail 512 | 513 | # Make the TFTP server more secure: with this set, only files owned by 514 | # the user dnsmasq is running as will be send over the net. 515 | #tftp-secure 516 | 517 | # This option stops dnsmasq from negotiating a larger blocksize for TFTP 518 | # transfers. It will slow things down, but may rescue some broken TFTP 519 | # clients. 520 | #tftp-no-blocksize 521 | 522 | # Set the boot file name only when the "red" tag is set. 523 | #dhcp-boot=tag:red,pxelinux.red-net 524 | 525 | # An example of dhcp-boot with an external TFTP server: the name and IP 526 | # address of the server are given after the filename. 527 | # Can fail with old PXE ROMS. Overridden by --pxe-service. 528 | #dhcp-boot=/var/ftpd/pxelinux.0,boothost,192.168.0.3 529 | 530 | # If there are multiple external tftp servers having a same name 531 | # (using /etc/hosts) then that name can be specified as the 532 | # tftp_servername (the third option to dhcp-boot) and in that 533 | # case dnsmasq resolves this name and returns the resultant IP 534 | # addresses in round robin fasion. This facility can be used to 535 | # load balance the tftp load among a set of servers. 536 | #dhcp-boot=/var/ftpd/pxelinux.0,boothost,tftp_server_name 537 | 538 | # Set the limit on DHCP leases, the default is 150 539 | #dhcp-lease-max=150 540 | 541 | # The DHCP server needs somewhere on disk to keep its lease database. 542 | # This defaults to a sane location, but if you want to change it, use 543 | # the line below. 544 | #dhcp-leasefile=/var/lib/misc/dnsmasq.leases 545 | 546 | # Set the DHCP server to authoritative mode. In this mode it will barge in 547 | # and take over the lease for any client which broadcasts on the network, 548 | # whether it has a record of the lease or not. This avoids long timeouts 549 | # when a machine wakes up on a new network. DO NOT enable this if there's 550 | # the slightest chance that you might end up accidentally configuring a DHCP 551 | # server for your campus/company accidentally. The ISC server uses 552 | # the same option, and this URL provides more information: 553 | # http://www.isc.org/files/auth.html 554 | #dhcp-authoritative 555 | 556 | # Run an executable when a DHCP lease is created or destroyed. 557 | # The arguments sent to the script are "add" or "del", 558 | # then the MAC address, the IP address and finally the hostname 559 | # if there is one. 560 | #dhcp-script=/bin/echo 561 | 562 | # Set the cachesize here. 563 | #cache-size=150 564 | 565 | # If you want to disable negative caching, uncomment this. 566 | #no-negcache 567 | 568 | # Normally responses which come from /etc/hosts and the DHCP lease 569 | # file have Time-To-Live set as zero, which conventionally means 570 | # do not cache further. If you are happy to trade lower load on the 571 | # server for potentially stale date, you can set a time-to-live (in 572 | # seconds) here. 573 | #local-ttl= 574 | 575 | # If you want dnsmasq to detect attempts by Verisign to send queries 576 | # to unregistered .com and .net hosts to its sitefinder service and 577 | # have dnsmasq instead return the correct NXDOMAIN response, uncomment 578 | # this line. You can add similar lines to do the same for other 579 | # registries which have implemented wildcard A records. 580 | #bogus-nxdomain=64.94.110.11 581 | 582 | # If you want to fix up DNS results from upstream servers, use the 583 | # alias option. This only works for IPv4. 584 | # This alias makes a result of 1.2.3.4 appear as 5.6.7.8 585 | #alias=1.2.3.4,5.6.7.8 586 | # and this maps 1.2.3.x to 5.6.7.x 587 | #alias=1.2.3.0,5.6.7.0,255.255.255.0 588 | # and this maps 192.168.0.10->192.168.0.40 to 10.0.0.10->10.0.0.40 589 | #alias=192.168.0.10-192.168.0.40,10.0.0.0,255.255.255.0 590 | 591 | # Change these lines if you want dnsmasq to serve MX records. 592 | 593 | # Return an MX record named "maildomain.com" with target 594 | # servermachine.com and preference 50 595 | #mx-host=maildomain.com,servermachine.com,50 596 | 597 | # Set the default target for MX records created using the localmx option. 598 | #mx-target=servermachine.com 599 | 600 | # Return an MX record pointing to the mx-target for all local 601 | # machines. 602 | #localmx 603 | 604 | # Return an MX record pointing to itself for all local machines. 605 | #selfmx 606 | 607 | # Change the following lines if you want dnsmasq to serve SRV 608 | # records. These are useful if you want to serve ldap requests for 609 | # Active Directory and other windows-originated DNS requests. 610 | # See RFC 2782. 611 | # You may add multiple srv-host lines. 612 | # The fields are ,,,, 613 | # If the domain part if missing from the name (so that is just has the 614 | # service and protocol sections) then the domain given by the domain= 615 | # config option is used. (Note that expand-hosts does not need to be 616 | # set for this to work.) 617 | 618 | # A SRV record sending LDAP for the example.com domain to 619 | # ldapserver.example.com port 389 620 | #srv-host=_ldap._tcp.example.com,ldapserver.example.com,389 621 | 622 | # A SRV record sending LDAP for the example.com domain to 623 | # ldapserver.example.com port 389 (using domain=) 624 | #domain=example.com 625 | #srv-host=_ldap._tcp,ldapserver.example.com,389 626 | 627 | # Two SRV records for LDAP, each with different priorities 628 | #srv-host=_ldap._tcp.example.com,ldapserver.example.com,389,1 629 | #srv-host=_ldap._tcp.example.com,ldapserver.example.com,389,2 630 | 631 | # A SRV record indicating that there is no LDAP server for the domain 632 | # example.com 633 | #srv-host=_ldap._tcp.example.com 634 | 635 | # The following line shows how to make dnsmasq serve an arbitrary PTR 636 | # record. This is useful for DNS-SD. (Note that the 637 | # domain-name expansion done for SRV records _does_not 638 | # occur for PTR records.) 639 | #ptr-record=_http._tcp.dns-sd-services,"New Employee Page._http._tcp.dns-sd-services" 640 | 641 | # Change the following lines to enable dnsmasq to serve TXT records. 642 | # These are used for things like SPF and zeroconf. (Note that the 643 | # domain-name expansion done for SRV records _does_not 644 | # occur for TXT records.) 645 | 646 | #Example SPF. 647 | #txt-record=example.com,"v=spf1 a -all" 648 | 649 | #Example zeroconf 650 | #txt-record=_http._tcp.example.com,name=value,paper=A4 651 | 652 | # Provide an alias for a "local" DNS name. Note that this _only_ works 653 | # for targets which are names from DHCP or /etc/hosts. Give host 654 | # "bert" another name, bertrand 655 | #cname=bertand,bert 656 | 657 | # For debugging purposes, log each DNS query as it passes through 658 | # dnsmasq. 659 | log-queries 660 | 661 | # Log lots of extra information about DHCP transactions. 662 | #log-dhcp 663 | 664 | # Include another lot of configuration options. 665 | #conf-file=/etc/dnsmasq.more.conf 666 | #conf-dir=/etc/dnsmasq.d 667 | 668 | # Include all the files in a directory except those ending in .bak 669 | #conf-dir=/etc/dnsmasq.d,.bak 670 | 671 | # Include all files in a directory which end in .conf 672 | #conf-dir=/etc/dnsmasq.d/,*.conf 673 | -------------------------------------------------------------------------------- /filecp.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | IMG=/root/pendrive.img 3 | MNTPOINT=/mnt/pendrive/ 4 | UPLOADDIR=/opt/webchan/upload/ 5 | 6 | sleep 3 7 | find $MNTPOINT -type f -exec du -b {} \; > tree1 8 | umount $MNTPOINT 9 | mount -oro,loop,offset=$((2048 * 512)) -t vfat $IMG $MNTPOINT 10 | find $MNTPOINT -type f -exec du -b {} \; > tree2 11 | 12 | diff -y --suppress-common-lines -W 20000 tree1 tree2 | rev | cut -f 1 | rev | while read FILE 13 | do 14 | if echo $FILE | grep -q "<$"; then 15 | echo -n 16 | else 17 | cp -v "${FILE[@]}" ${UPLOADDIR} 18 | fi 19 | done -------------------------------------------------------------------------------- /imgwatch.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | IMG=/root/pendrive.img 3 | CPSCRIPT=filecp.sh 4 | 5 | PID="" 6 | 7 | inotifywait -m $IMG | while read line 8 | do 9 | if echo $line | grep -iq "MODIFY"; then 10 | if [ -n "$PID" ]; then 11 | kill -9 $PID && PID="" 12 | fi 13 | ./${CPSCRIPT} & 14 | PID=$! 15 | fi 16 | done 17 | -------------------------------------------------------------------------------- /systemd_services/godns.service: -------------------------------------------------------------------------------- 1 | [Service] 2 | Type=simple 3 | ExecStart=/opt/godns/dns 4 | #User=godns 5 | #Group=godns 6 | ExecReload=/bin/kill -HUP $MAINPID 7 | WorkingDirectory=/opt/godns 8 | 9 | [Install] 10 | WantedBy=multi-user.target 11 | -------------------------------------------------------------------------------- /systemd_services/imgwatch.service: -------------------------------------------------------------------------------- 1 | [Service] 2 | Type=simple 3 | ExecStart=/opt/imgwatch.sh 4 | ExecReload=/bin/kill -HUP $MAINPID 5 | WorkingDirectory=/opt 6 | 7 | [Install] 8 | WantedBy=multi-user.target 9 | -------------------------------------------------------------------------------- /systemd_services/webchan.service: -------------------------------------------------------------------------------- 1 | [Service] 2 | Type=simple 3 | ExecStart=/opt/webchan/webchan 4 | ExecReload=/bin/kill -HUP $MAINPID 5 | WorkingDirectory=/opt/webchan 6 | Environment="PORT=80" 7 | 8 | [Install] 9 | WantedBy=multi-user.target 10 | --------------------------------------------------------------------------------