omriher / CapTipper

Malicious HTTP traffic explorer
GNU General Public License v3.0
712 stars 159 forks source link

hosts command on Linux #1

Closed kevthehermit closed 9 years ago

kevthehermit commented 9 years ago

First I love this project and looking forward to its development. I found an issue running the hosts command on a Linux machine results in the following;

CT> hosts
Found Hosts:

 www.bing.com

Exiting CapTipper
WebServer Shutdown.

The issue is with the unichr options.

on windows they are fine

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\Admin>python
Python 2.7.8 (default, Jun 30 2014, 16:03:49) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> print unichr(9500)
├
>>> print unichr(9492)
└
>>>

On Linux not so much

root@viper:~/github/CapTipper# python
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> print unichr(9500)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
UnicodeEncodeError: 'ascii' codec can't encode character u'\u251c' in position 0: ordinal not in range(128)
>>> print unichr(9492)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2514' in position 0: ordinal not in range(128)
>>>

A Simple fix is to replace the chars with a |

 for host_uri in hosts[host]:
            print " " + "|"  + "-- " + host_uri.encode('utf8')

Which then outputs the expected results

CT> hosts
Found Hosts:

 www.bing.com
 |-- /fd/ls/GLinkPing.aspx?IG=aee5908ea2d64991aa8b8996fd170a75&&ID=SERP,5091.1   [0]
 |-- /fd/ls/lsp.aspx   [36]

 www.ciniholland.nl
 |-- /wp-content/plugins/contact-form-7/includes/css/styles.css?ver=3.7.2   [1]
 |-- /wp-content/themes/cini/js/functions.js   [2]
 |-- /wp-content/plugins/sitemap/css/page-list.css?ver=4.2   [3]
 |-- /   [4]

Or use a try / except to display | if unichr fails

Ill send a pull request when I get home

omriher commented 9 years ago

Hi,

That's odd, it works great on Kali (Debian)

root@kali:~# python
Python 2.7.3 (default, Mar 14 2014, 11:57:14) 
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> print unichr(9500)
├
>>> print unichr(9492)
└
>>> 

Will wrap in try / except as a temporary solution.

Thanks a lot!