macee / w4sp-lab

Lab environment for the Wireshark for Security Professionals book
https://github.com/w4sp-book/w4sp-lab/wiki/Lab-Installation
0 stars 0 forks source link

Docker Restart Issue #1

Open thedini opened 4 years ago

thedini commented 4 years ago

W4SP Lab has something broken and needs fixing. Below is the suggested startup that throws the error followed at the bottom by the docker status that shows how it failed:

w4sp-lab@kali:~/jaubin$ sudo python3 w4sp_webapp.py 
[sudo] password for w4sp-lab: 
['which', 'dumpcap']
['getcap', b'/usr/bin/dumpcap']
[*] Caps set correctly on dumpcap
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
[*] Not enough w4sp/labs images found, building now
/home/w4sp-lab/jaubin/images
['docker', 'build', '-t', 'w4sp/labs:base', 'base']
['docker', 'build', '-t', 'w4sp/labs:inet', 'inet']
['docker', 'build', '-t', 'w4sp/labs:samba', 'samba']
['docker', 'build', '-t', 'w4sp/labs:ftp_tel', 'ftp_tel']
['docker', 'build', '-t', 'w4sp/labs:temp', 'temp']
['docker', 'build', '-t', 'w4sp/labs:wireless', 'wireless']
['docker', 'build', '-t', 'w4sp/labs:switch', 'switch']
['docker', 'build', '-t', 'w4sp/labs:elk', 'elk']
['docker', 'build', '-t', 'w4sp/labs:victims', 'victims']
['docker', 'build', '-t', 'w4sp/labs:vrrpd', 'vrrpd']
['docker', 'ps', '-aq', '--filter', 'label=w4sp=true']
['ifconfig', '-a']
['ip', 'link', 'delete', b'docker0:']
['ip', 'link', 'delete', b'eth0:']
RTNETLINK answers: Operation not supported
['ip', 'link', 'delete', b'lo:']
RTNETLINK answers: Operation not supported
['ip', 'netns']
['pkill', 'dhclient']
['ifconfig', '-a']                                                          
['service', 'network-manager', 'start']                                       
['service', 'networking', 'restart']                                           
['service', 'docker', 'restart']                                                 
 * Serving Flask app "w4sp_webapp" (lazy loading)                                 
 * Environment: production                                                          
   WARNING: This is a development server. Do not use it in a production deployment.   
   Use a production WSGI server instead.                                              
 * Debug mode: off                                                                       
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)                                
[*] Lab Launched, Starting Browser                                                         
[*] Do not close this terminal. Closing Terminal will terminate lab.                          
Error: no DISPLAY environment variable specified                                                 
127.0.0.1 - - [17/Jul/2020 13:46:04] "GET / HTTP/1.1" 200 -                                      
{'nodes': [{'id': 1, 'label': ' kali ', 'color': 'rgb(204,0,0)', 'title': 'eth0 : 10.0.2.15 <br>docker0 : 172.17.0.1 <br>'}], 'edges': []}
127.0.0.1 - - [17/Jul/2020 13:46:04] "GET /getnet HTTP/1.1" 200 -                                    
[2020-07-17 13:46:04,586] ERROR in app: Exception on /is_ips [GET]                                       
Traceback (most recent call last):                                                                       
  File "/usr/lib/python3/dist-packages/flask/app.py", line 2447, in wsgi_app                                 
    response = self.full_dispatch_request()                                                                  
  File "/usr/lib/python3/dist-packages/flask/app.py", line 1952, in full_dispatch_request                    
    rv = self.handle_user_exception(e)                                                                           
  File "/usr/lib/python3/dist-packages/flask/app.py", line 1821, in handle_user_exception                        
    reraise(exc_type, exc_value, tb)                                                                                   
  File "/usr/lib/python3/dist-packages/flask/_compat.py", line 39, in reraise                                          
    raise value                                                                                                        
  File "/usr/lib/python3/dist-packages/flask/app.py", line 1950, in full_dispatch_request                                  
    rv = self.dispatch_request()                                                                                           
  File "/usr/lib/python3/dist-packages/flask/app.py", line 1936, in dispatch_request                                            
    return self.view_functions[rule.endpoint](**req.view_args)                                                                  
  File "w4sp_webapp.py", line 213, in is_ips                                                                                        
    if psef('suricata'):                                                                                                            
  File "w4sp_webapp.py", line 70, in psef                                                                                               
    if grep in cmd:                                                                                                                       
TypeError: a bytes-like object is required, not 'str'                                                                                        
127.0.0.1 - - [17/Jul/2020 13:46:04] "GET /is_ips HTTP/1.1" 500 -                                                                            
{'nodes': [{'id': 1, 'label': ' kali ', 'color': 'rgb(204,0,0)', 'title': 'eth0 : 10.0.2.15 <br>docker0 : 172.17.0.1 <br>'}], 'edges': []}       
127.0.0.1 - - [17/Jul/2020 13:46:07] "GET /getnet HTTP/1.1" 200 -                                                                                
['docker', 'ps', '-aq', '--filter', 'label=w4sp=true']                                                                                           
[2020-07-17 13:46:07,405] ERROR in app: Exception on /is_ips [GET]                                                                               
Traceback (most recent call last):                                                                                                               
  File "/usr/lib/python3/dist-packages/flask/app.py", line 2447, in wsgi_app                                                                     
    response = self.full_dispatch_request()                                                                                                      
  File "/usr/lib/python3/dist-packages/flask/app.py", line 1952, in full_dispatch_request                                                        
    rv = self.handle_user_exception(e)
  File "/usr/lib/python3/dist-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/lib/python3/dist-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/usr/lib/python3/dist-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/lib/python3/dist-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "w4sp_webapp.py", line 213, in is_ips
    if psef('suricata'):
  File "w4sp_webapp.py", line 70, in psef
    if grep in cmd:
TypeError: a bytes-like object is required, not 'str'
127.0.0.1 - - [17/Jul/2020 13:46:07] "GET /is_ips HTTP/1.1" 500 -
['ifconfig', '-a']
['ip', 'link', 'delete', b'docker0:']
['ip', 'link', 'delete', b'eth0:']
RTNETLINK answers: Operation not supported
['ip', 'link', 'delete', b'lo:']
RTNETLINK answers: Operation not supported
['ip', 'netns']
['pkill', 'dhclient']
['ifconfig', '-a']
['service', 'network-manager', 'start']
['service', 'networking', 'restart']
['service', 'docker', 'restart']
['docker', 'ps', '-aq', '--filter', 'label=w4sp=true']
['ifconfig', '-a']
['ip', 'link', 'delete', b'docker0:']
['ip', 'link', 'delete', b'eth0:']
RTNETLINK answers: Operation not supported
['ip', 'link', 'delete', b'lo:']
RTNETLINK answers: Operation not supported
['ip', 'netns']
['pkill', 'dhclient']
['ifconfig', '-a']
['service', 'network-manager', 'start']
['service', 'networking', 'restart']
['service', 'docker', 'restart']
Job for docker.service failed.
See "systemctl status docker.service" and "journalctl -xe" for details.
Traceback (most recent call last):
  File "w4sp_webapp.py", line 164, in setup
    w4sp.setup_network2('eth0')
  File "/home/w4sp-lab/jaubin/w4sp.py", line 39, in setup_network2
    docker_clean()
  File "/home/w4sp-lab/jaubin/w4sp_app/utils.py", line 148, in docker_clean
    r('service docker restart')
  File "/home/w4sp-lab/jaubin/w4sp_app/utils.py", line 83, in r
    return subprocess.check_output(cmd)
  File "/usr/lib/python3.8/subprocess.py", line 411, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/usr/lib/python3.8/subprocess.py", line 512, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['service', 'docker', 'restart']' returned non-zero exit status 1.
127.0.0.1 - - [17/Jul/2020 13:46:21] "GET /setup HTTP/1.1" 200

w4sp-lab@kali:~$ sudo systemctl status docker
[sudo] password for w4sp-lab: 
● docker.service - Docker Application Container Engine
     Loaded: loaded (/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
     Active: failed (Result: start-limit-hit) since Fri 2020-07-17 13:46:21 EDT; 1min 27s ago
TriggeredBy: ● docker.socket
       Docs: https://docs.docker.com
    Process: 2383 ExecStart=/usr/sbin/dockerd -H fd:// $DOCKER_OPTS (code=exited, status=0/SUCCESS)
   Main PID: 2383 (code=exited, status=0/SUCCESS)
Jul 17 13:46:20 kali dockerd[2383]: time="2020-07-17T13:46:20.795020950-04:00" level=info msg="Processing signal 'terminated'"
Jul 17 13:46:20 kali dockerd[2383]: time="2020-07-17T13:46:20.795452146-04:00" level=info msg="Daemon shutdown complete"
Jul 17 13:46:20 kali dockerd[2383]: time="2020-07-17T13:46:20.795476028-04:00" level=info msg="stopping event stream following graceful shutdown>
Jul 17 13:46:20 kali dockerd[2383]: time="2020-07-17T13:46:20.795493677-04:00" level=info msg="stopping healthcheck following graceful shutdown">
Jul 17 13:46:20 kali dockerd[2383]: time="2020-07-17T13:46:20.795522471-04:00" level=info msg="stopping event stream following graceful shutdown>
Jul 17 13:46:21 kali systemd[1]: docker.service: Succeeded.
Jul 17 13:46:21 kali systemd[1]: Stopped Docker Application Container Engine.
Jul 17 13:46:21 kali systemd[1]: docker.service: Start request repeated too quickly.
Jul 17 13:46:21 kali systemd[1]: docker.service: Failed with result 'start-limit-hit'.
Jul 17 13:46:21 kali systemd[1]: Failed to start Docker Application Container Engine.
Soups71 commented 4 years ago

For this issue, I have spent about 2 hrs at current time to figure out why this error continues to persist. After doing some research it is believed that this might be a issue on older versions of docker. As a result, I have begun updating docker packages in order to mitigate this issue. If this does not work I will be forced to add new python code to fix the current issue.