Armageddon421's Hackingblog

Stats from the “Alice Modem 1111″

by on Jan.24, 2011, under quickhack

This weekend a friend of mine asked me if I could make his fileserver display some intersting stats. One of those stats would be the internet traffic. The problem was the crappy modem/router thing from Alice that he has to use. The webinterface has very sparse information, there is also no traffic monitor.

Running nmap revealed that the modem has a telnet interface.


Starting Nmap 5.00 ( http://nmap.org ) at 2011-01-24 10:18 CET
Interesting ports on alicebox.localdomain (192.168.1.1):
Not shown: 996 closed ports
PORT STATE SERVICE
23/tcp open telnet
80/tcp open http
2800/tcp open unknown
8008/tcp open http

I tried connecting, and then there was the next problem: It asked for login and password. I found out that it is not the same as for the webinterface, so I googled. The login would be “admin” and the password would consist of “Alice” + the last 6 Bytes of the MAC in hex + “123″, for example “AliceFFFFFF123″.

The I was confronted with some strange shell that allowed to press “?” to display the possibilities.


Trying 192.168.1.1...
Connected to 192.168.1.1.
Escape character is '^]'.

Alice Modem 1111
Alice Software Version : 4.19

Login: admin
Password: **************

Login successful

-->
agent            Get a file from a remote host
bridge           Configure layer 2 bridge.
bridgevlan       VLAN transport configuration
classifier       Packet classifier configuration commands
console          Console access
dhcpclient       DHCP client configuration commands
dhcprelay        DHCP relay Configuration
dhcpserver       DHCP server configuration commands
dnsrelay         DNS relay configuration
ethernet         Commands to configure ethernet transports
firewall         Firewall configuration commands
help             Top level CLI help
imdebug          Directly access the information model
ip               Configure IP router
l2filter         Packet filter configuration commands
nat              NAT configuration commands
port             Physical port configuration commands
pppoa            PPP over ATM configuration
pppoe            PPP over Ethernet Configuration
security         Security configuration commands not specific to NAT or firewall
sntpclient       Simple Network Time Protocol Client commands
stop
system           System administration commands
transports       Transport configuration commands
upnp             UPnP configuration commands
user             User commands
-->

After toying around a bit, I found what I needed:

--> port ethernet show

Version = 1.01
RxNoBuffer = 121
TxNoBuffer = 0
PortClassEthernet = true
Disable = false
PromiscuousEnable = true
RxBroadcastEnable = true
RxMulticastEnable = true
RxMulticastAllEnable = true
RxUnicastEnable = true
RxAddressEnable = false
RxPassBad = false
FullDuplexEnable = true
CrcEnable = false
PadShortDataEnable = false
Loopback = false
HaltImmediately = true
MAC = 00:85:a0:01:01:00
RxOK = 4657743
TxOK = 6663192
MaxFilterEntries = 21
TxIntTx = 6663192
Tx10Stat = 0
TxPar = 0
TxHalted = 0
TxSQErr = 0
TxMCast = 7788
TxBCast = 2018
TxVLAN = 0
TxMACC = 0
TxPause = 0
TxExcessiveCollisions = 0
TxLateCollisions = 0
TxUnderrun = 0
TxCarrierLoss = 0
TxDeferred = 0
TxAfterOneCollision = 0
TxAfterMoreCollision = 0
TxCollisions = 0
TxExcessiveDeferrals = 0
RxIntRx = 0
RxMIIErrors = 0
RxPar = 0
RxHalted = 0
RxMulticastPackets = 62675
RxBroadcastPackets = 693755
RxVLAN1Frames = 0
RxPAUSE = 0
RxCRCErrors = 0
RxErrorAlign = 0
RxOverlongPackets = 0
RxOverruns = 112852
RxControlFrames = 0
RxShortPackets = 749
txOKBytes = 211726529
rxOKBytes = 541541832

txUCastPkts = 6653390
rxUCastPkts = 4012768
PhyMode = MII
resetDefaults = false
portSnmpIfIndex = 0
portSnmpIfType = 0

All I had to do now was automate this process. The finished python script, using expect to simulate the interaction and rrdtool to store and graph the data, looked like this:

#!/usr/bin/python

import pexpect, sys, os

os.linesep = "\r"  #telnet expects \r instead of \n, expect uses os.liensep

#Connect and simulate interaction
c = pexpect.spawn("telnet 192.168.1.1 23")
c.expect("Login: ")
c.sendline("admin")
c.expect("Password: ")
c.sendline("AliceFFFFFF123")
c.expect("--> ")
c.sendline("port ethernet show")
c.expect("--> ")
res = c.before
c.close()

#Find the required values
lines = res.split("\r\n")
for line in lines:
	if line.startswith("txOKBytes"):
		tx = line.split("= ")[1]
	if line.startswith("rxOKBytes"):
		rx = line.split("= ")[1]

#Update RRD
pexpect.run("rrdtool update /home/ave/rrd/database/internet.rrd N:%s:%s" % (tx,rx))

The finished output of rrdtool looks like this:

Later I added a second graph that shows the number of devices in the LAN that respond to ping probes. It’s as simple as

#!/bin/bash

res=`nmap -sP 192.168.1.50-253 | wc -l`   #nmap the LAN, count the lines
num=$(($res - 3))                         #substract nmap's static status lines
rrdtool update /home/ave/rrd/database/devices.rrd N:$num     #update RRD

I hope I could give some of you an example on how to approach such a problem. Comment if you did something similar or want to do it!

:, , , , , , , ,

Leave a Reply