Kai's profilePrelude: AniccaBlog Tools Help

Blog


    September 30

    让GNS3从"R1"开始添加路由器

    方便你就叫!

     

    实现:

    1. 用UltraEdit等十六进制编辑器打开执行文件:gns3.exe

    2. 搜索十六进制字串:5A 1C 00 64 1C 00 61 1D 00

    3. 将"1C"修改为"06":5A 1C 00 64 06 00 61 1D 00

     

    思路:

    GNS3是用Python编写的开源软件。

    1. 下载源代码,分析后得知应修改:\GNS3\Node\IOSRouter.py

    2. 从执行文件中解压出编译过的比特码文件:\GNS3\Node\IOSRouter.pyo

    3. 安装Python,进入IDLE:

    f = open('IOSRouter.pyo','rb')
    
    import marshal
    
    co = marshal.load(f)
    
    print co.co_consts

    4. 算出常量池中"0"和"1"的索引号。

    5. 在十六进制编辑器中打开执行文件,修改/替换其索引号。

    March 06

    GNS3,SecureCRT,VBScript

    First, thanks for ronsun from NetEmu forum give us the helpful VBScript (here).

    Since this VBS has a little collision with the date format of my Windows 7 English Version, I remodified it to be more pithy and efficient.

    #$language = "VBScript"
    
    #$interface = "1.0"
    
    Option Explicit
    
    Dim MyLocale
    
    Sub Main
    
      On Error Resume Next
    
      crt.Screen.Synchronous = True
    
      crt.Screen.WaitForString "Console port"
    
      crt.Screen.Send vbCr
    
      crt.Screen.WaitForString("[yes/no]:")
    
      crt.Screen.Send "no" & vbCr & vbCr
    
      crt.Screen.WaitForString "Router>"
    
      crt.Screen.Send "enable" & vbCr
    
      MyLocale = GetLocale()
    
      SetLocale(1033)
    
      crt.Screen.Send "clock set " & Hour(Time) & ":" & Minute(Time) & ":" & Second(Time) & " " & MonthName(Month(Date)) & " " & Day(Date) & " " & Year(Date) & vbCr
    
      SetLocale(MyLocale)
    
      crt.Screen.Send "configure terminal" & vbCr
    
      crt.Screen.Send "no ip domain-lookup " & vbCr
    
      crt.Screen.Send "hostname " & crt.GetScriptTab.Caption & vbCr
    
      crt.Screen.Send "line console 0" & vbCr
    
      crt.Screen.Send "exec-timeout 0 0" & vbCr
    
      crt.Screen.Send "logging synchronous" & vbCr
    
      crt.Screen.Send "exit" & vbCr
    
      crt.Screen.Synchronous = False
    
    End Sub

    Function:

    1. Tab sessions when telnet routers in GNS3.
    2. Doing fews necessary commands to make simulated routers be more stable and convenient.

    Usage:

    1. Copy the codes above to a blank notepad and save it as .vbs file. (e.g., gnscrt.vbs)
    2. Open your GNS3, open the Preference by “Edit – Preference” or “Ctrl+Shift+P”.
    3. Focus on “General – General Settings – Terminal command”, fill in:

    (somewhere)\SecureCRT.exe /ARG %d /N %d /SCRIPT (somewhere)\gns3.vbs /T /TELNET %h %p

    e.g. GNSCRT\SecureCRT.exe /ARG %d /N %d /SCRIPT GNSCRT\GNS3.vbs /T /TELNET %h %p

    (supported relative path, somewhere will as your favor)

        4.   Before you click the “Telnet to all IOS” button in GNS3, you should start one SecureCRT instance, otherwise it will open several SecureCRT windows instead of several tabs in one windows which you excepted.

     

    Other something else:

    1.   The problem at “Usage – 4”, I didn’t find any way to solve it, even use sleep.exe(Windows 2003 Resource Kit) or some shell script. I think it’s SecureCRT’s problem due to it can’t recognize dozen commands started at the same time unless there’s already a program instance opened, their support engineer mentioned it in offical forum, maybe they’ll fixit it in new versions.

    2.   By the habitual way, we prefer to use “R1” at first router, then R2, R3, R4… This will be convenient to address the ip, e.g. 192.168.12.1, 192.168.23.2. But the GNS3 will count the first router as “R0”, rather than a natural number. Also I can’t settle it except editing the source code or crack it, that’ll be shit for god’s sake. Let me out!