Skip to content
View in the app

A better way to browse. Learn more.

MSFN

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

cldaha01

Member
  • Joined

  • Last visited

  • Country

    United States
  1. Thanks Jaclaz for suggestions! I am trying to access the firewall rules such as destination ports and source Ip address from the datacenter made in Microsoft access, given Ip address and destination host. I made one using only Ip address but its not accessing all information so I am trying to make one that inputs ip address and destination host and outputs the information with dports and source IP address in text file.
  2. Here is my code I am working on but I am not able to get valid output when running the program <job><runtime> <description>This script searches the destination using IP addresses and dst_host in the firewall databases.</description> <named name="run" helpstring="Firewall to search" type="string" /> <named name="search" helpstring="IP address to search for" type="string" /> helpstring="dst_host to search for" type="string"/> <example>fw-ip-search.wsf /search:"%136.165.238.%"</example> <example>fw-ip-search.wsf /run:internet /search:"%136.165.238.%"</example> <example>fw-dst_host-search.wsf/search:"%dmp-ll02-1%"</example> <example>fw-dst_host-search.wsf/run:internet / search:"%dmp-ll02-1%"</example></runtime><script id="fw-search" language="vbscript">' Declare the variables that we are using.Dim strMF, strProvider, strCpu, strCmd, strSearch, strTextX, strTextY, strWDDim arrSN, arrLine, dtmNow, dtmformat, objArgs, objSh, objFS, objMF, objOF, strFileConst DEFAULT_TEST_SWITCH = 0Const ForWriting = 2Const ForReading = 1'Specify file computers namestrFile = "c:\Scripts\Computers.txt"' Set some defaults.' Master firewall list file.' <firewall name>;<status>;<location/vlan>;<IP Block>strMF = "firewall_relationships.txt"' What database provider/library to use. Jet is only 32bit 'strProvider = "Provider=Microsoft.Jet.OLEDB.4.0;"strProvider = "Provider=Microsoft.ACE.OLEDB.12.0;"'strProvider = "Provider=Microsoft.ACE.OLEDB.14.0;"' Create a WshShell objectSet objSh = CreateObject("Wscript.Shell")' What Architecture are we running in x86, AMD64, or IA64?strCpu = objSh.ExpandEnvironmentStrings("%PROCESSOR_ARCHITECTURE%")If strCpu = "AMD64" And InStr(1,Wscript.FullName,"system32",1) > 0 Then strCmd = Replace(Wscript.FullName,"system32","SysWOW64",1,-1,1) strCmd = strCmd & " " & chr(34) & Wscript.ScriptFullName & chr(34) If Wscript.Arguments.Count > 0 Then For i = 0 to Wscript.Arguments.Count - 1 strCmd = strCmd & " " & chr(34) & Wscript.Arguments(i) & chr(34) Next End If objSh.Run strCmd, 0, FALSE Wscript.QuitEnd If' Get the current working directory that the script was ran from.strWD = objSh.CurrentDirectory & "\"' Get the current date and time into YYYYMMDDHHMMSS format.dtmNow = Nowdtmformat = ((((100*Year(dtmNow) + Month(dtmNow))*100 + Day(dtmNow))*100 _ + Hour(dtmNow))*100 + Minute(dtmNow))*100 + Second(dtmNow)' Allows the user to provide the search string on the command line.strSearch = "Please Enter the dst_host to search for: " & chr(10) & _ " you can use % as a wildcard and [ ] to match any single char."Set objArgs = Wscript.Arguments.NamedIf objArgs.Exists("search") Then strTextX = objArgs.Item("search")Else strTextX = InputBox(strSearch,"dst_host Search") If strTextX = "" Then wscript.Quit End IfEnd IfstrSearch = "Please Enter the IP address to search for: " & chr(13) & _ " you can use % as a wildcard and [ ] to match any single char."Set objArgs = Wscript.Arguments.NamedIf objArgs.Exists("search") Then strTextY = objArgs.Item("search")Else strTextY = InputBox(strSearch,"IP Address Search") If strTextY = "" Then wscript.Quit End IfEnd If' Create file system object to open files.Set objFS = CreateObject("Scripting.FileSystemObject")' Output file: <script name>_YYYYMMDDHHMMSS.logarrSN = Split(Wscript.ScriptName,".")If (objFS.FileExists(strWD & arrSN(0) & "_" & dtmformat & ".log")) Then Set objOF = objFS.OpenTextFile(strWD & arrSN(0) & "_" & dtmformat & _ ".log", ForWriting, True)Else Set objOF = objFS.CreateTextFile(strWD & arrSN(0) & "_" & dtmformat & _ ".log")End If' Write out a header line.' To get a double quote to print out you have to escape it with another' double quote.' Write out a header line.' To get a double quote to print out you have to escape it with another' double quote.objOF.Write("""Firewall"",""destination dst_host"",""rule name"",""")objOF.WriteLine("protocol/services"",""source IP""")' Write out the search text.objOF.Write("""query"",""" & strTextX & """,""search text"",""")objOF.WriteLine(""",""" & strTextX & """")objOF.Write("""Firewall"",""destination IP"",""rule name"",""")objOF.WriteLine("protocol/services"",""source IP""")' Write out the search text.objOF.Write("""query"",""" & strTextY & """,""search text"",""")objOF.WriteLine(""",""" & strTextY & """")' This block allows the user to run this script for just one' firewall database.' cscript fw-ip-search.wsf /run:internetIf objArgs.Exists("run") Then SearchDB, objArgs.Item("run"),strTextX, strTextYElse ' Open a text file as read only if it exists. If (not (objFS.FileExists(strWD & strMF))) Then Wscript.Echo "Cannot locate the Firewall Relationships file." Wscript.Quit End If Set objMF = objFS.OpenTextFile(strWD & strMF, ForReading) ' Remove the header line in the file. objMF.SkipLine ' Reading though each line of the Master firewall list and take action on ' each firewall that is active. Do until objMF.AtEndOfStream arrLine = Split(objMF.ReadLine) ' If the second field is "on" then process that firewall. If arrLine(1 and 2) = "on" Then SearchDB, arrLine(0), strTextX, strTextY 'else If arrLine(2) = "on" Then 'SearchDB, arrLine(0), strTextX, strTextY End If Loop'clean up objMF.closeEnd IfobjOF.closeSub SearchDB(strDBd, strBaseN, strSearchText) ' searches the dst_ip, src_ip and dst_host of a database. Dim objAccessDB, objRules Const adOpenStatic = 3 Const adLockOptimistic = 3 Const adUseClient = 3 Const adCmdText = &H0001 ' Create objects to open a MS Access db. Set objAccessDB = CreateObject("ADODB.Connection") Set objRules = CreateObject("ADODB.Recordset") ' Open the MS Access db. objAccessDB.Open strProvider & "Data Source=" & strDBd & _ "fw_" & strBaseN & ".mdb" ' This is the statement that searches the database. objRules.Open "SELECT * FROM devices WHERE dst_ip Like '" & _ strSearchText & "' OR src_ip Like '" & _ strSearchText & "'OR dports Like '" &_ strSearchText & "'", _ objAccessDB, adOpenStatic, adLockOptimistic ' If no rows were found exit the procdure. If objRules.RecordCount < 1 Then Exit Sub End If objRules.MoveFirst Do Until objRules.EOF If ((objRules.Fields.Item("dports") <> "")) Then ' chr(34) is a double quote (") objOF.Write(chr(34) & strBaseN & chr(34) & "," & chr(34) & _ objRules.Fields.Item("dst_ip") & chr(34) & "," & chr(34) & _ objRules.Fields.Item("dst_host") & chr(34) & "," & chr(34) & _ objRules.Fields.Item("dports") & chr(34) & "," & chr(34)) If IsNull(objRules.Fields.Item("src_ip")) Then objOF.Write("any" & chr(34)) Else objOF.Write(objRules.Fields.Item("src_ip") & chr(34)) End If objOF.WriteLine End If objRules.MoveNext Loop objRules.Close objAccessDB.CloseEnd Sub</script></job>
  3. Hey Guys, I work in one of the company and I am trying write a code in vbscript to locate a destination using IP Address from the datacenter. Any could help me to write a code please?

Account

Navigation

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.