Sponsored Content
Top Forums Shell Programming and Scripting Add NA When String is not found Post 303024050 by dis0wned on Thursday 27th of September 2018 02:06:02 PM
Old 09-27-2018
Sorry - Windows os running cygwin

Sample input:
Code:
Device ID: ciscoblah
,
  IP address: 1.1.1.1
,
Platform: C5548P,  Capabilities: Switch IGMP CVTA phone port 
,
Interface: TenGigabitEthernet1/1,  Port ID (outgoing port): Ethernet1/1
,
Cisco Nexus Operating System (NX-OS) Software, Version 7.1(4)N1(1)
,
  IP address: 1.1.1.1
,


Desired output:

Code:
Device ID: ciscoblah,
  IP address: 1.1.1.1, Platform: C5548P,  Capabilities: Switch IGMP CVTA phone port ,Interface: TenGigabitEthernet1/1,  Port ID (outgoing port): Ethernet1/1,Cisco Nexus Operating System (NX-OS) Software, Version 7.1(4)N1(1), NA,  IP address: 1.1.1.1,

Code Im using:

Code:
awk '/Device ID:/ || /address:/ || /Interface:/ || /VLAN:/ || /Platform:/ || /Software/ {print $0,"NA"}' $tempdir/shcdpnedet > $tempdir/newtt

When a field that I am pulling with the awk command
Code:
'/Device ID:/ || /address:/ || /Interface:/ || /VLAN:/ || /Platform:/ || /Software/

isnt present, I would Like NA to be output in the place of the missing field.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Display only found string

Is there a way for grep to output only the found string and not the whole line? I have a ksh script which reads in a file and loops through every line looking up on a grep -f list. For it to only display only the string found i pass this to awk as a variable and loop through the list file using... (5 Replies)
Discussion started by: Cranie
5 Replies

2. Shell Programming and Scripting

Search for string and display those NOT found

In my script I read a input file and search all the files in a directory and it's sub-directories for that string using: find . -type f -print | xargs grep $var1 This just displays all the lines the string was found on. Too much data. What I need is to store in a file one time those... (17 Replies)
Discussion started by: John Rihn
17 Replies

3. Solaris

Can't install Unicode::String due to String.so not found

CPAN.pm: Going to build G/GA/GAAS/Unicode-String-2.09.tar.gz Checking if your kit is complete... Looks good Writing Makefile for Unicode::String cp String.pm blib/lib/Unicode/String.pm cp lib/Unicode/CharName.pm blib/lib/Unicode/CharName.pm /usr/bin/perl /usr/perl5/5.8.4/lib/ExtUtils/xsubpp... (5 Replies)
Discussion started by: PatrickBaer
5 Replies

4. Shell Programming and Scripting

Finding a string with another string is found

finding a string with another string is found EX: abs c/- i want to find /-, then copy abs. i know it's easy use awk, but my problem is the substr syntax. substr($2,2,2) will give me /- but the conflict is /- is not always the second characted of the second string. (11 Replies)
Discussion started by: engr.jay
11 Replies

5. Linux

Find String in FileName and move the String to new File if not found

Hi all, I have a question.. Here is my requirement..I have 500 files in a path say /a/b/c I have some numbers in a file which are comma seperated...and I wanted to check if the numbers are present in the FileName in the path /a/b/c..if the number is there in the file that is fine..but if... (1 Reply)
Discussion started by: us_pokiri
1 Replies

6. Shell Programming and Scripting

grep on string and printing line after until another string has been found

Hello Everyone, I just started scripting this week. I have no background in programming or scripting. I'm working on a script to grep for a variable in a log file Heres what the log file looks like. The x's are all random clutter xxxxxxxxxxxxxxxxxxxxx START: xxxxxxxxxxxx... (7 Replies)
Discussion started by: rxc23816
7 Replies

7. Shell Programming and Scripting

Grep a string and write a value to next line of found string

Hi, I have two variables x and y. i need to find a particular string in a file, a workflow name and then insert the values of x and y into the next lines of the workflow name. basically it is like as below wf_xxxxxx $$a= $$b= $$c= figo $$d=bentley i need to grep the 'wf_xxxx' and then... (6 Replies)
Discussion started by: angel12345
6 Replies

8. UNIX for Dummies Questions & Answers

Append a string on the next line after a pattern string is found

Right now, my code is: s/Secondary Ins./Secondary Ins.\ 1/g It's adding a 1 as soon as it finds Secondary Ins. Primary Ins.: MEDICARE B DMERC Secondary Ins. 1: CONTINENTAL LIFE INS What I really want to achieve is having a 1 added on the next line that contain "Secondary Ins." It... (4 Replies)
Discussion started by: newbeee
4 Replies

9. Shell Programming and Scripting

Modify a file by another file: add new line and variable after string is found

hello, I have problem with writing/adjusting a shell script. I searched forum and unfortunately couldn't write scipt based on the information I found. I never wtire such so it's hard for me and I do need to modify one script immediately. case looks like: 1. 'file' that needs to be modified... (3 Replies)
Discussion started by: bipbip
3 Replies

10. Shell Programming and Scripting

Get 20 lines above string found, and 35 below string

i want to search a log for a string. when that string is found, i want to grab the a set number of lines that came before the string, and a set number of lines that come after the string. so if i search for the word "Error" in the /var/log/messages file, how can I output the 20 lines that came... (4 Replies)
Discussion started by: SkySmart
4 Replies
YERSINIA(8)															       YERSINIA(8)

NAME
Yersinia - A FrameWork for layer 2 attacks SYNOPSIS
yersinia [-hVGIDd] [-l logfile] [-c conffile] protocol [-M] [protocol_options] DESCRIPTION
yersinia is a framework for performing layer 2 attacks. The following protocols have been implemented in Yersinia current version: Spanning Tree Protocol (STP), VLAN Trunking Protocol (VTP), Hot Standby Router Protocol (HSRP), Dynamic Trunking Protocol (DTP), IEEE 802.1Q, Cisco Discovery Protocol (CDP), Dynamic Host Configuration Protocol (DHCP) and, finally, the Inter-Switch Link Protocol (ISL). Some of the attacks implemented will cause a DoS in a network, other will help to perform any other more advanced attack, or both. In addi- tion, some of them will be first released to the public since there isn't any public implementation. Yersinia will definitely help both pen-testers and network administrators in their daily tasks. Some of the mentioned attacks are DoS attacks, so TAKE CARE about what you're doing because you can convert your network into an UNSTABLE one. A lot of examples are given at this page EXAMPLES section, showing a real and useful program execution. OPTIONS
-h, --help Help screen. -V, --Version Program version. -G Start a graphical GTK session. -I, --interactive Start an interactive ncurses session. -D, --daemon Start the network listener for remote admin (Cisco CLI emulation). -d Enable debug messages. -l logfile Save the current session to the file logfile. If logfile exists, the data will be appended at the end. -c conffile Read/write configuration variables from/to conffile. -M Disable MAC spoofing. PROTOCOLS
The following protocols are implemented in yersinia current version: Spanning Tree Protocol (STP and RSTP) Cisco Discovery Protocol (CDP) Hot Standby Router Protocol (HSRP) Dynamic Host Configuration Protocol (DHCP) Dynamic Trunking Protocol (DTP) IEEE 802.1Q VLAN Trunking Protocol (VTP) Inter-Switch Link Protocol (ISL) PROTOCOLS OPTIONS
Spanning Tree Protocol (STP): is a link management protocol that provides path redundancy while preventing undesirable loops in the net- work. The supported options are: -version version BPDU version (0 STP, 2 RSTP, 3 MSTP) -type type BPDU type (Configuration, TCN) -flags flags BPDU Flags -id id BPDU ID -cost pathcost BPDU root path cost -rootid id BPDU Root ID -bridgeid id BPDU Bridge ID -portid id BPDU Port ID -message secs BPDU Message Age -max-age secs BPDU Max Age (default is 20) -hello secs BPDU Hello Time (default is 2) -forward secs BPDU Forward Delay -source hw_addr Source MAC address -dest hw_addr Destination MAC address -interface iface Set network interface to use -attack attack Attack to launch Cisco Discovery Protocol (CDP): is a Cisco propietary Protocol which main aim is to let Cisco devices to communicate to each other about their device settings and protocol configurations. The supported options are: -source hw_addr MAC Source Address -dest hw_addr MAC Destination Address -v version CDP Version -ttl ttl Time To Live -devid id Device ID -address address Device Address -port id Device Port -capability cap Device Capabilities -version version Device IOS Version -duplex 0|1 Device Duplex Configuration -platform platform Device Platform -ipprefix ip Device IP Prefix -phello hello Device Protocol Hello -mtu mtu Device MTU -vtp_mgm_dom domain Device VTP Management Domain -native_vlan vlan Device Native VLAN -voip_vlan_r req Device VoIP VLAN Reply -voip_vlan_q query Device VoIP VLAN Query -t_bitmap bitmap Device Trust Bitmap -untrust_cos cos Device Untrusted CoS -system_name name Device System Name -system_oid oid Device System ObjectID -mgm_address address Device Management Address -location location Device Location -attack attack Attack to launch Hot Standby Router Protocol (HSRP): Inter-Switch Link Protocol (ISL): VLAN Trunking Protocol (VTP): Dynamic Host Configuration Protocol (DHCP): IEEE 802.1Q: Dynamic Trunking Protocol (DTP): ATTACKS
Attacks Implemented in STP: 0: NONDOS attack sending conf BPDU 1: NONDOS attack sending tcn BPDU 2: DOS attack sending conf BPDUs 3: DOS attack sending tcn BPDUs 4: NONDOS attack Claiming Root Role 5: NONDOS attack Claiming Other Role 6: DOS attack Claiming Root Role with MiTM Attacks Implemented in CDP: 0: NONDOS attack sending CDP packet 1: DOS attack flooding CDP table 2: NONDOS attack Setting up a virtual device Attacks Implemented in HSRP: 0: NONDOS attack sending raw HSRP packet 1: NONDOS attack becoming ACTIVE router 2: NONDOS attack becoming ACTIVE router (MITM) Attacks Implemented in DHCP: 0: NONDOS attack sending RAW packet 1: DOS attack sending DISCOVER packet 2: NONDOS attack creating DHCP rogue server 3: DOS attack sending RELEASE packet Attacks Implemented in DTP: 0: NONDOS attack sending DTP packet 1: NONDOS attack enabling trunking Attacks Implemented in 802.1Q: 0: NONDOS attack sending 802.1Q packet 1: NONDOS attack sending 802.1Q double enc. packet 2: DOS attack sending 802.1Q arp poisoning Attacks Implemented in VTP: 0: NONDOS attack sending VTP packet 1: DOS attack deleting all VTP vlans 2: DOS attack deleting one vlan 3: NONDOS attack adding one vlan 4: DOS attack Catalyst zero day Attacks Implemented in ISL: None at the moment GTK GUI
The GTK GUI (-G) is a GTK graphical interface with all of the yersinia powerful features and a professional 'look and feel'. NCURSES GUI
The ncurses GUI (-I) is a ncurses (or curses) based console where the user can take advantage of yersinia powerful features. Press 'h' to display the Help Screen and enjoy your session :) NETWORK DAEMON
The Network Daemon (-D) is a telnet based server (ala Cisco mode) that listens by default in port 12000/tcp waiting for incoming telnet connections. It supports a CLI similar to a Cisco device where the user (once authenticated) can display different settings and can launch attacks with- out having yersinia running in her own machine (specially useful for Windows users). EXAMPLES
- Send a Rapid Spanning-Tree BPDU with port role designated, port state agreement, learning and port id 0x3000 to eth1: yersinia stp -attack 0 -version 2 -flags 5c -portid 3000 -interface eth1 - Start a Spanning-Tree nonDoS root claiming attack in the first nonloopback interface (keep in mind that this kind of attack will use the first BPDU on the network interface to fill in the BPDU fields properly): yersinia stp -attack 4 - Start a Spanning-Tree DoS attack sending TCN BPDUs in the eth0 interface with MAC address 66:66:66:66:66:66: yersinia stp -attack 3 -source 66:66:66:66:66:66 SEE ALSO
The README file contains more in-depth documentation about the attacks. COPYRIGHT
Yersinia is Copyright (c) BUGS
Lots AUTHORS
Alfredo Andres Omella <alfredo@yersinia.net> David Barroso Berrueta <tomac@yersinia.net> Yersinia v0.7 $Date: 2006/02/17 22:48:40 $ YERSINIA(8)
All times are GMT -4. The time now is 04:02 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy