Monday, September 2, 2013

OWASP ESAPI encoder library

ESAPI is a library for user input cleansing for a web application. ESAPI encoder sanitizes user input so that the input can be safely displayed on a user's browser. ESAPI is a great help preventing code injection (inc. SQL injection) and XSS.

OWASP ESAPI (OWASP Enterprise Security API)
https://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API

ESAPI supports
- Java, .NET, Python, Ruby, PHP, etc.
- Base 64 encoding/decoding is also supported.

P.S. For XSS prevention,
Set cookies HTTP access only and block Javascript access.

Thursday, August 29, 2013

Vim: Converting tabs into spaces

`set expandtab` option automatically converts tabs into spaces. However, the command does not affect the tabs existed before the option is set.

To convert such tabs into spaces, issue :retab

Ref:
Converting tabs to spaces
http://vim.wikia.com/wiki/Converting_tabs_to_spaces

Monday, August 19, 2013

GNS3 bug: %OSPF-4-ERRRCV: Received invalid packet: Bad Checksum

SYMPTOM:
I've got an error when testing a simple OSPF network with GNS3 0.8.4-RC4.
%OSPF-4-ERRRCV: Received invalid packet: Bad Checksum from X.X.X.X, INTERFACE_ID

WORKAROUND:
1. Open topology.net from an editor
2. Change "Sparsemem = True" to "Sparsemem = False"

NOTE
The problem seems to be fixed on dynamips-0.2.10. GNS3 0.8.5 and Dynamips-0.2.10 with sparsemem option does not cause a problem.

Saturday, August 17, 2013

Failure of injecting default route to EIGRP with "ip default-network"

"ip default-network" command seems not inject a default route. The behavior looks different from what is written on Wendell Odon's CCNP book.
  • "ip default-network" creates a default route on a router from which the "default-network" command is issued. However, other routers learns only a candidate default route (They have no default route set.).
  • "ip default-network" command needs to be issued from a router that is not directly connected to the target default route.
  • A router that is connected to a default route side (R3 in the following experiment) does not learn the candidate default route from the command.
Note: 192.0.0.1/24 on R2 is not used in the experiment
Misc: To reflect the result of `no ip default-network`, the target interface needs to be shut down. 

Used IOS: 15.0(1)M ADVENTERPRISEK9-M

CASE 1
*Topology*
R1 fa0/0 <---> R2 fa0/0

*Interfaces*
R1
fa0/0 10.0.0.1/8
lo0 128.0.0.1/16

R2
fa0/0 10.0.0.2/8
lo0 192.0.0.1/24

*Commands*
R1
eigrp 1
    net 10.0.0.0
    net 128.0.0.0
ip default-network 128.0.0.0

R2
eigrp 1
    net 10.0.0.0
    net 192.0.0.0

*Result*
"ip default-network" has no effect because it is issued on R1 where 128.0.0.0 network is directly connected.

R1# sh ip route
Gateway of last resort is not set

      10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C        10.0.0.0/8 is directly connected, FastEthernet0/0
L        10.0.0.1/32 is directly connected, FastEthernet0/0
 *    128.0.0.0/16 is variably subnetted, 2 subnets, 2 masks
C*       128.0.0.0/16 is directly connected, Loopback0
L        128.0.0.1/32 is directly connected, Loopback0
D     192.0.0.0/24 [90/156160] via 10.0.0.2, 00:16:24, FastEthernet0/0


R2# sh ip route
Gateway of last resort is not set

      10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C        10.0.0.0/8 is directly connected, FastEthernet0/0
L        10.0.0.2/32 is directly connected, FastEthernet0/0
D*    128.0.0.0/16 [90/156160] via 10.0.0.1, 00:10:06, FastEthernet0/0
      192.0.0.0/24 is variably subnetted, 2 subnets, 2 masks
C        192.0.0.0/24 is directly connected, Loopback0
L        192.0.0.1/32 is directly connected, Loopback0


CASE 2
*Topology*
R1 fa0/0 <---> R2 fa0/0

*Interfaces*
R1
fa0/0 10.0.0.1/8
lo0 128.0.0.1/16

R2
fa0/0 10.0.0.2/8
lo0 192.0.0.1/24

*Commands*
R1
eigrp 1
    net 10.0.0.0
    net 128.0.0.0

R2
eigrp 1
    net 10.0.0.0
    net 192.0.0.0
ip default-network 128.0.0.0

*Result*
R2 uses "128.0.0.0" as a default route.

R1
Gateway of last resort is not set

      10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C        10.0.0.0/8 is directly connected, FastEthernet0/0
L        10.0.0.1/32 is directly connected, FastEthernet0/0
      128.0.0.0/16 is variably subnetted, 2 subnets, 2 masks
C        128.0.0.0/16 is directly connected, Loopback0
L        128.0.0.1/32 is directly connected, Loopback0
D     192.0.0.0/24 [90/156160] via 10.0.0.2, 00:32:27, FastEthernet0/0
      192.168.0.0/24 is variably subnetted, 2 subnets, 2 masks
C        192.168.0.0/24 is directly connected, FastEthernet0/1
L        192.168.0.1/32 is directly connected, FastEthernet0/1


R2
Gateway of last resort is 10.0.0.1 to network 128.0.0.0

S*    0.0.0.0/0 [90/156160] via 10.0.0.1, FastEthernet0/0
      10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C        10.0.0.0/8 is directly connected, FastEthernet0/0
L        10.0.0.2/32 is directly connected, FastEthernet0/0
D*    128.0.0.0/16 [90/156160] via 10.0.0.1, 00:00:39, FastEthernet0/0
      192.0.0.0/24 is variably subnetted, 2 subnets, 2 masks
C        192.0.0.0/24 is directly connected, Loopback0
L        192.0.0.1/32 is directly connected, Loopback0


CASE 3
*Topology*
R3 fa0/1 <---> fa0/1 R1 fa0/0 <---> fa0/0 R2 fa0/1 <---> fa0/1 R4

*Interfaces*
R1
fa0/0 10.0.0.1/8
fa0/1 192.168.0.1/24
lo0 128.0.0.1/16

R2
fa0/0 10.0.0.2/8
fa0/1 172.0.0.1/16
lo0 192.0.0.1/24

R3
fa0/1 192.168.0.2/24

R4
fa0/1 172.0.0.2/16

*Commands*
R1
eigrp 1
    net 10.0.0.0
    net 128.0.0.0
    net 192.168.0.0

R2
eigrp 1
    net 10.0.0.0
    net 172.0.0.0
    net 192.0.0.0
ip default-network 128.0.0.0

R3
eigrp 1
    net 192.168.0.0

R4
eigrp 1
    net 172.0.0.0

*Result*
R2 uses "128.0.0.0" as the default route.
On R4, 128.0.0.0 is marked as a candidate default, but gateway of last resort is not set.
On R3, 128.0.0.0 is not even marked as a candidate defaut. 


R1
Gateway of last resort is not set

      10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C        10.0.0.0/8 is directly connected, FastEthernet0/0
L        10.0.0.1/32 is directly connected, FastEthernet0/0
      128.0.0.0/16 is variably subnetted, 2 subnets, 2 masks
C        128.0.0.0/16 is directly connected, Loopback0
L        128.0.0.1/32 is directly connected, Loopback0
D     172.0.0.0/16 [90/30720] via 10.0.0.2, 00:09:41, FastEthernet0/0
D     192.0.0.0/24 [90/156160] via 10.0.0.2, 00:50:24, FastEthernet0/0
      192.168.0.0/24 is variably subnetted, 2 subnets, 2 masks
C        192.168.0.0/24 is directly connected, FastEthernet0/1
L        192.168.0.1/32 is directly connected, FastEthernet0/1


R2
Gateway of last resort is 10.0.0.1 to network 128.0.0.0

S*    0.0.0.0/0 [90/156160] via 10.0.0.1, FastEthernet0/0
      10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C        10.0.0.0/8 is directly connected, FastEthernet0/0
L        10.0.0.2/32 is directly connected, FastEthernet0/0
D*    128.0.0.0/16 [90/156160] via 10.0.0.1, 00:19:04, FastEthernet0/0
      172.0.0.0/16 is variably subnetted, 2 subnets, 2 masks
C        172.0.0.0/16 is directly connected, FastEthernet0/1
L        172.0.0.1/32 is directly connected, FastEthernet0/1
      192.0.0.0/24 is variably subnetted, 2 subnets, 2 masks
C        192.0.0.0/24 is directly connected, Loopback0
L        192.0.0.1/32 is directly connected, Loopback0
D     192.168.0.0/24 [90/30720] via 10.0.0.1, 00:12:43, FastEthernet0/0


R3
Gateway of last resort is not set

D     10.0.0.0/8 [90/30720] via 192.168.0.1, 00:10:24, FastEthernet0/1
D     128.0.0.0/16 [90/156160] via 192.168.0.1, 00:10:24, FastEthernet0/1
D     172.0.0.0/16 [90/33280] via 192.168.0.1, 00:06:37, FastEthernet0/1
D     192.0.0.0/24 [90/158720] via 192.168.0.1, 00:10:24, FastEthernet0/1
      192.168.0.0/24 is variably subnetted, 2 subnets, 2 masks
C        192.168.0.0/24 is directly connected, FastEthernet0/1
L        192.168.0.2/32 is directly connected, FastEthernet0/1


R4
Gateway of last resort is not set

D     10.0.0.0/8 [90/30720] via 172.0.0.1, 00:07:31, FastEthernet0/1
D*    128.0.0.0/16 [90/158720] via 172.0.0.1, 00:07:31, FastEthernet0/1
      172.0.0.0/16 is variably subnetted, 2 subnets, 2 masks
C        172.0.0.0/16 is directly connected, FastEthernet0/1
L        172.0.0.2/32 is directly connected, FastEthernet0/1
D     192.0.0.0/24 [90/156160] via 172.0.0.1, 00:07:31, FastEthernet0/1
D     192.168.0.0/24 [90/33280] via 172.0.0.1, 00:07:31, FastEthernet0/1


CASE 4
*Topology*
R3 fa0/1 <---> fa0/1 R1 fa0/0 <---> fa0/0 R2 fa0/1 <---> fa0/1 R4

*Interfaces*
R1
fa0/0 10.0.0.1/8
fa0/1 192.168.0.1/24
lo0 128.0.0.1/16

R2
fa0/0 10.0.0.2/8
fa0/1 172.0.0.1/16
lo0 192.0.0.1/24

R3
fa0/1 192.168.0.2/24

R4
fa0/1 172.0.0.2/16

*Commands*
R1
eigrp 1
    net 10.0.0.0
    net 128.0.0.0
    net 192.168.0.0

R2
eigrp 1
    net 0.0.0.0
    net 10.0.0.0
    net 172.0.0.0
    net 192.0.0.0
ip default-network 128.0.0.0

R3
eigrp 1
    net 192.168.0.0

R4
eigrp 1
    net 172.0.0.0

*Result*
"net 0.0.0.0" has no effect.

R1
Gateway of last resort is not set

      10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C        10.0.0.0/8 is directly connected, FastEthernet0/0
L        10.0.0.1/32 is directly connected, FastEthernet0/0
      128.0.0.0/16 is variably subnetted, 2 subnets, 2 masks
C        128.0.0.0/16 is directly connected, Loopback0
L        128.0.0.1/32 is directly connected, Loopback0
D     172.0.0.0/16 [90/30720] via 10.0.0.2, 00:09:41, FastEthernet0/0
D     192.0.0.0/24 [90/156160] via 10.0.0.2, 00:50:24, FastEthernet0/0
      192.168.0.0/24 is variably subnetted, 2 subnets, 2 masks
C        192.168.0.0/24 is directly connected, FastEthernet0/1
L        192.168.0.1/32 is directly connected, FastEthernet0/1


R2
Gateway of last resort is 10.0.0.1 to network 128.0.0.0

S*    0.0.0.0/0 [90/156160] via 10.0.0.1, FastEthernet0/0
      10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C        10.0.0.0/8 is directly connected, FastEthernet0/0
L        10.0.0.2/32 is directly connected, FastEthernet0/0
D*    128.0.0.0/16 [90/156160] via 10.0.0.1, 00:19:04, FastEthernet0/0
      172.0.0.0/16 is variably subnetted, 2 subnets, 2 masks
C        172.0.0.0/16 is directly connected, FastEthernet0/1
L        172.0.0.1/32 is directly connected, FastEthernet0/1
      192.0.0.0/24 is variably subnetted, 2 subnets, 2 masks
C        192.0.0.0/24 is directly connected, Loopback0
L        192.0.0.1/32 is directly connected, Loopback0
D     192.168.0.0/24 [90/30720] via 10.0.0.1, 00:12:43, FastEthernet0/0


R3
Gateway of last resort is not set

D     10.0.0.0/8 [90/30720] via 192.168.0.1, 00:10:24, FastEthernet0/1
D     128.0.0.0/16 [90/156160] via 192.168.0.1, 00:10:24, FastEthernet0/1
D     172.0.0.0/16 [90/33280] via 192.168.0.1, 00:06:37, FastEthernet0/1
D     192.0.0.0/24 [90/158720] via 192.168.0.1, 00:10:24, FastEthernet0/1
      192.168.0.0/24 is variably subnetted, 2 subnets, 2 masks
C        192.168.0.0/24 is directly connected, FastEthernet0/1
L        192.168.0.2/32 is directly connected, FastEthernet0/1


R4
Gateway of last resort is not set

D     10.0.0.0/8 [90/30720] via 172.0.0.1, 00:07:31, FastEthernet0/1
D*    128.0.0.0/16 [90/158720] via 172.0.0.1, 00:07:31, FastEthernet0/1
      172.0.0.0/16 is variably subnetted, 2 subnets, 2 masks
C        172.0.0.0/16 is directly connected, FastEthernet0/1
L        172.0.0.2/32 is directly connected, FastEthernet0/1
D     192.0.0.0/24 [90/156160] via 172.0.0.1, 00:07:31, FastEthernet0/1
D     192.168.0.0/24 [90/33280] via 172.0.0.1, 00:07:31, FastEthernet0/1


CASE 5
*Topology*
R3 fa0/1 <---> fa0/1 R1 fa0/0 <---> fa0/0 R2 fa0/1 <---> fa0/1 R4

*Interfaces*
R1
fa0/0 10.0.0.1/8
fa0/1 192.168.0.1/24
lo0 128.0.0.1/16

R2
fa0/0 10.0.0.2/8
fa0/1 172.0.0.1/16
lo0 192.0.0.1/24

R3
fa0/1 192.168.0.2/24

R4
fa0/1 172.0.0.2/16

*Commands*
R1
eigrp 1
    net 10.0.0.0
    net 128.0.0.0
    net 192.168.0.0

R2
eigrp 1
    net 10.0.0.0
    net 172.0.0.0
    net 192.0.0.0
redistribute static
ip default-network 128.0.0.0


R3
eigrp 1
    net 192.168.0.0

R4
eigrp 1
    net 172.0.0.0


*Result*
"redistribute static" has no effect.

R1
Gateway of last resort is not set

      10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C        10.0.0.0/8 is directly connected, FastEthernet0/0
L        10.0.0.1/32 is directly connected, FastEthernet0/0
      128.0.0.0/16 is variably subnetted, 2 subnets, 2 masks
C        128.0.0.0/16 is directly connected, Loopback0
L        128.0.0.1/32 is directly connected, Loopback0
D     172.0.0.0/16 [90/30720] via 10.0.0.2, 00:09:41, FastEthernet0/0
D     192.0.0.0/24 [90/156160] via 10.0.0.2, 00:50:24, FastEthernet0/0
      192.168.0.0/24 is variably subnetted, 2 subnets, 2 masks
C        192.168.0.0/24 is directly connected, FastEthernet0/1
L        192.168.0.1/32 is directly connected, FastEthernet0/1


R2
Gateway of last resort is 10.0.0.1 to network 128.0.0.0

S*    0.0.0.0/0 [90/156160] via 10.0.0.1, FastEthernet0/0
      10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C        10.0.0.0/8 is directly connected, FastEthernet0/0
L        10.0.0.2/32 is directly connected, FastEthernet0/0
D*    128.0.0.0/16 [90/156160] via 10.0.0.1, 00:19:04, FastEthernet0/0
      172.0.0.0/16 is variably subnetted, 2 subnets, 2 masks
C        172.0.0.0/16 is directly connected, FastEthernet0/1
L        172.0.0.1/32 is directly connected, FastEthernet0/1
      192.0.0.0/24 is variably subnetted, 2 subnets, 2 masks
C        192.0.0.0/24 is directly connected, Loopback0
L        192.0.0.1/32 is directly connected, Loopback0
D     192.168.0.0/24 [90/30720] via 10.0.0.1, 00:12:43, FastEthernet0/0


R3
Gateway of last resort is not set

D     10.0.0.0/8 [90/30720] via 192.168.0.1, 00:10:24, FastEthernet0/1
D     128.0.0.0/16 [90/156160] via 192.168.0.1, 00:10:24, FastEthernet0/1
D     172.0.0.0/16 [90/33280] via 192.168.0.1, 00:06:37, FastEthernet0/1
D     192.0.0.0/24 [90/158720] via 192.168.0.1, 00:10:24, FastEthernet0/1
      192.168.0.0/24 is variably subnetted, 2 subnets, 2 masks
C        192.168.0.0/24 is directly connected, FastEthernet0/1
L        192.168.0.2/32 is directly connected, FastEthernet0/1


R4
Gateway of last resort is not set

D     10.0.0.0/8 [90/30720] via 172.0.0.1, 00:07:31, FastEthernet0/1
D*    128.0.0.0/16 [90/158720] via 172.0.0.1, 00:07:31, FastEthernet0/1
      172.0.0.0/16 is variably subnetted, 2 subnets, 2 masks
C        172.0.0.0/16 is directly connected, FastEthernet0/1
L        172.0.0.2/32 is directly connected, FastEthernet0/1
D     192.0.0.0/24 [90/156160] via 172.0.0.1, 00:07:31, FastEthernet0/1
D     192.168.0.0/24 [90/33280] via 172.0.0.1, 00:07:31, FastEthernet0/1



Monday, July 8, 2013

EtherChannel "on" mode can cause a bridging loop.

I thought EtherChannel's "on" mode was a good thing, in which no opportunity for unexpected malfunction, but it's not true.

Misconfigured EtherChannel can form a bridging loop, and STP EtherChannel Misconfig Guard cannot stop all bridging loops scenarios. It's recommended to use PAgP or LACP's negotiation (use "desirable non-silent" or "active") for inter-switch connections and prevent misconfigured ports from being active.

Reference:
How does a loop form in a misconfigured Etherchannel?

Understanding EtherChannel Inconsistency Detection

Friday, June 14, 2013

Small tips on bash

Famous tips but I didn't know before.

1. Oh, I forgot to type sudo and got permission error...
Type
$ sudo !!

Here, !! refers to the previous command issued.


2. I don't wanna type that lengthy command or arguments or whatever again...
Type first several letters of the command and hit ^r (Control - r). If the completed command is not what you want, type ^r again and again until you get what you want.

^r searches command history and complete the command line. You can see your command line history with "history" command. Each command line history has an index, and a command can be reissued by typing ! followed by a index number. (e.g. $ !1)