Check the interfaces and add to dictionary the below lines - parsing

#--------------------------------------------------
router Base
interface "DXB6004-AGG1:DXB3186-SCSG1"
address 10.3.141.1/31
ldp-sync-timer 5
port lag-16:3
bfd 100 receive 100 multiplier 3 type cpm-np
no shutdown
exit
interface "DXB6004-AGG1:DXB3230-SCSG1"
address 10.3.193.1/31
ldp-sync-timer 5
port lag-32:3
bfd 100 receive 100 multiplier 3 type cpm-np
no shutdown
exit
interface "DXB6004-AGG1:DXB6004-AGG2_Inst3"
address 10.3.252.217/30
ldp-sync-timer 5
port lag-199:3
bfd 100 receive 100 multiplier 3 type cpm-np
no shutdown
exit
As per the text example above. I need a script to to add its interface name with its contents in a dictionary form.
I am expecting the output as below:
DXB6004-AGG1:DXB3186-SCSG1 = {"address" : "10.3.141.1/31", "port" : "lag-16:3", "Status" : "no shutdown"}

Related

pydrake- Error when connecting IiwaCommandSender to LcmPublisherSystem

I have the following lines in my program-
lcm = DrakeLcm()
lcm_command_sender = builder.AddSystem(IiwaCommandSender())
lcm_publisher = builder.AddSystem(LcmPublisherSystem.Make(channel="IIWA_COMMAND", lcm_type=lcmt_iiwa_command, lcm=lcm, publish_period=0.01))
//Connect controller to command sender
builder.Connect(controller.GetOutputPort("joint_positions"), lcm_command_sender.get_position_input_port())
//Connect lcm command sender to publisher
builder.Connect(lcm_command_sender.GetOutputPort("lcmt_iiwa_command"), lcm_publisher.get_input_port())
Upon running, the last line gives the following runtime error-
RuntimeError: DiagramBuilder::Connect: Mismatched value types while connecting output port lcmt_iiwa_command of System lcm_command_sender (type drake::lcmt_iiwa_command) to input port lcm_message of System LcmPublisherSystem(IIWA_COMMAND) (type drake::pydrake::Object)
I am not sure why this happens, since the documentation specifically says that the output port of IiwaCommandSender should be connected to the input port of LcmPublisherSystem, and both of them are of the type AbstractValue. What is it that I'm missing?
In the code above, the output port of the IiwaCommandSender is of type "drake::lcmt_iiwa_command" (a C++ class wrapped in Python), but the input port of the LcmPublisherSystem is of type "drake.lcmt_iiwa_command" (a Python class). Those are two different runtime types, even though they both represent an LCM message.
In this case, you should set use_cpp_serializer=True when calling LcmPublisherSystem.Make so that the input port is the C++ type, instead of the Python type.
https://drake.mit.edu/pydrake/pydrake.systems.lcm.html#pydrake.systems.lcm.LcmPublisherSystem.Make

What does a Windows service type of 0x30 mean?

A Windows service of type WIN32_SHARE_PROCESS (0x20) runs as a thread in a process which it shares with other services. (Although, in recent Windows 10 builds, it may get its own process anyway.) A Windows service of type WIN32_OWN_PROCESS (0x10) runs in its own isolated process. But, some Windows services have type wIN32_OWN_PROCESS | WIN32_SHARE_PROCESS (0x30). What does that combination mean?
sc query calls that combination WIN32. For example, sc query AppInfo reports:
SERVICE_NAME: AppInfo
TYPE : 30 WIN32
STATE : 4 RUNNING
(STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x0
The Windows API docs don't mention this possibility. They talk about what each flag means independently, but not in combination. They do reference 0x30 in the documentation of EnumServicesStatusA, but in the context of that function it is documented as returning services with either types set, it doesn't talk about what it means for a service to have both types set.
(The service type field can take several other values: driver services like SERVIC_KERNEL_DRIVER, the SERVICE_INTERACTIVE_PROCESS flag, user services, etc. I am not asking about any of those other values/flags in this question, only about the 0x30 combination.)
As you point out, changes to service host grouping in Windows 10 may result in services of type SERVICE_WIN32_SHARE_PROCESS running in their own, isolated process. Whenever that happens to a service, SC will show it as SERVICE_WIN32 -- the confusing union of SERVICE_WIN32_OWN_PROCESS and SERVICE_WIN32_SHARE_PROCESS.
We've confirmed this situation by playing with the registry.
On our Windows 10 VM (which has ample RAM to trigger the process isolation enhancements), SC says AppInfo is of type WIN32 (30):
Task Manager reported that AppInfo was running in its own process.
As per the documentation, we disabled process isolation for the AppInfo service by adding the SvcHostSplitDisable value:
And after a reboot, SC reported AppInfo of type WIN32_SHARE_PROCESS (20):
The Task Manager confirmed that the process was indeed shared.
So its all down to those changes to service process isolation in Windows 10 Creators Update (version 1703).

Nmap match three ports

I'm trying to make a script for nmap, which only executes its action, if three ports are open.
The end result would be if port 515, 631 and 9100 are open for tcp traffic, script should print a message (at first, later it should make a os detection).
My script so far:
function portrule(host,port)
return port.state == 'open' and
port.protocol == 'tcp' and
515 <= port.number and
631 <= port.number and
9100 <= port.number
end
action = function(host, port)
return "hello"
end
But this will execute for all ports after 9100 is hit.
Any help is appriciated!
NSE scripts match based on a rule function, and there are four different types. You are using a portrule, which tests each port on a host. Since you want to test multiple ports on a host, you should be using a hostrule instead.
The hostrule is tested after the state of all ports is known. You can check the state of all of these ports by using the nmap.get_ports function like nfs-ls does, or you can check individual ports using the nmap.get_port_state function like the nbstat script does. Actually, nbstat looks like a good example of exactly what you want to do.

ndisproto sample not reading any traffic

i was trying to get familiar with ndisproto samples in wdk. As per the doc, the -r -n 10 option should read 10 packets off the interface, but nothing in result even if I ping to the interface! The only time it reads traffic is when we use write option.
The sample is same, without any modification other than altering to #define NPROTO_PACKET_FILTER (NDIS_PACKET_TYPE_ALL_LOCAL|NDIS_PACKET_TYPE_PROMISCUOUS).
Is the driver really wired to read traffic originating from other sources?
What am I missing? Any idea how to read/sniff the traffic using ndisproto?
C:\Users\Administrator\Desktop\ndisprot>prottest.exe -r -n 10 \DEVICE\{17152850-6288-471A-9708-2889E7F55EE8}
Option: NumberOfPackets = 10
Trying to access NDIS Device: \DEVICE\{17152850-6288-471A-9708-2889E7F55EE8}
Opened device \DEVICE\{17152850-6288-471A-9708-2889E7F55EE8} successfully!
Trying to get src mac address
GetSrcMac: IoControl success, BytesReturned = 14
Got local MAC: 00:0c:29:23:b1:09
DoReadProc
C:\Users\Administrator\Desktop\ndisprot>prottest.exe -w -n 1 \DEVICE\{17152850-6288-471A-9708-2889E7F55EE8}
Option: NumberOfPackets = 1
Trying to access NDIS Device: \DEVICE\{17152850-6288-471A-9708-2889E7F55EE8}
Opened device \DEVICE\{17152850-6288-471A-9708-2889E7F55EE8} successfully!
Trying to get src mac address
GetSrcMac: IoControl success, BytesReturned = 14
Got local MAC: 00:0c:29:23:b1:09
DoWriteProc
DoWriteProc: sent 100 bytes
DoWriteProc: finished sending 1 packets of 100 bytes each
DoReadProc
DoReadProc: read pkt # 1, 100 bytes
DoReadProc finished: read 1 packets
Got the answer at last. The reason is, the driver sample is specifically designed to send/receive EAP over LAN frames, not all. There are a couple of break statements in NdisprotReceiveNetBufferLists that prevents any other packets other than frames of ethertype 0x888E from reaching the client app.
Same is the case for send.

How do I determine the status of a specific service?

I'd like to run a command that will give me the status of a specific windows service. Using sc query, I was able to get this information, see below.
C:\Windows\System32>sc query "IBM Cognos"
SERVICE_NAME: IBM Cognos
TYPE : 10 WIN32_OWN_PROCESS
STATE : 1 STOPPED
WIN32_EXIT_CODE : 1077 (0x435)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x0
The only bit of information that I really need to access is the "STATE". Can I filter the output so I am only seeing the STATE or "1 STOPPED"? I was hoping I could do something like:
sc query[STATE] "IBM Cognos"
My ultimate goal is to run a .bat file that will output the status of a service to a file. I can then read that file from another program and use that value to determine whether I should display a green icon indicating "started" or a red icon indicating "stopped" to the user in the UI.
Thanks in advance for your help,
Jeff
How about:
sc query "IBM Cognos" | find "STATE"
Should return something like:
STATE : 1 STOPPED

Resources