cat auth.log | grep "input_usr_auth_request" | awk '{print $9}' | sort -u > users.txt
Monday, 19 July 2021
Command to find users attacking a file in linux
Python
https://www.kaggle.com/abhat222/python-tutorial-part1#Dictionary
https://www.kaggle.com/abhat222/python-tutorial-part2#Container
https://www.kaggle.com/abhat222/numpy-tutorial
Monday, 5 July 2021
OSPF/BGP Fast Convergence
For OSPF:
a) Failure Detection: BFD
b) Failure Propogation : OSPF Timers (Throttle timers)
OSPF “timers throttle lsa all <lsa-start> <lsa-hold> <lsa-max>” command
Friday, 2 July 2021
JUNOS YAML vs JSON
YAML is superset of JSON
JSON:
- Junos OS configuration
- Junos OS operational command outputs
- Junos REST API
YAML:
- Junos PyEZ tables
- Ansible Playbooks
- JSNAPy
List :
JSON : Arrays
YAML: Sequence
Dictionaries:
JSON: Objects
YAML: Mapping
Junos Automation Stack
- Processes required for automating junos devices are mgd(management process) and jsd(jet service processes)
- mgd handles automation requests invloving junox XML APi, Yang, Rest API
- jsd handles automation requuests involving Juniper Extension Toolkit(JET) API.
JUNOS Architecture
Transit Traffic:
Wont enter RE and directly processed in PFE and requires a forwarding table entry for destination.
If requires duplicates the packet on to multiple egress port.
Exception Traffic:
Traffic destined to local system(routing protocol updates, telnet, ping traceroute)
Ip packets with ip option field set
traffic that requires generation of icmp messages
forwarding plance <-> control plane internal link is rate limited to prevent DOS attacks
Control traffic is given preference
Thursday, 1 July 2021
Python
Example 3.1. Defining a Dictionary
>>> d = {"server":"mpilgrim", "database":"master"} >>> d {'server': 'mpilgrim', 'database': 'master'}
Example 3.2. Modifying a Dictionar
>>> d
{'server': 'mpilgrim', 'database': 'master'} >>> d["database"] = "pubs" >>> d {'server': 'mpilgrim', 'database': 'pubs'} >>> d["uid"] = "sa" >>> d {'server': 'mpilgrim', 'uid': 'sa', 'database': 'pubs'}
Deleting Items from a Dictionary
>>> d {'server': 'mpilgrim', 'uid': 'sa', 'database': 'master', 42: 'douglas', 'retrycount': 3} >>> del d[42] >>> d {'server': 'mpilgrim', 'uid': 'sa', 'database': 'master', 'retrycount': 3} >>> d.clear() >>> d {}
Defining a List
>>> li = ["a", "b", "mpilgrim", "z", "example"] >>> li ['a', 'b', 'mpilgrim', 'z', 'example']
Negative List Indices
>>> li
['a', 'b', 'mpilgrim', 'z', 'example']
>>> li[-1]
'example'
>>> li[-3]
'mpilgrim'
Adding Elements to a List
>>> li
['a', 'b', 'mpilgrim', 'z', 'example']
>>> li.append("new")
>>> li
['a', 'b', 'mpilgrim', 'z', 'example', 'new']
>>> li.insert(2, "new")
>>> li
['a', 'b', 'new', 'mpilgrim', 'z', 'example', 'new']
>>> li.extend(["two", "elements"])
>>> li
['a', 'b', 'new', 'mpilgrim', 'z', 'example', 'new', 'two', 'elements']
The Difference between extend and append
>>> li = ['a', 'b', 'c'] >>> li.extend(['d', 'e', 'f']) >>> li ['a', 'b', 'c', 'd', 'e', 'f'] >>> len(li) 6 >>> li[-1] 'f' >>> li = ['a', 'b', 'c'] >>> li.append(['d', 'e', 'f']) >>> li ['a', 'b', 'c', ['d', 'e', 'f']] >>> len(li) 4 >>> li[-1] ['d', 'e', 'f']
Searching Lists
Example 3.12. Searching a List
>>> li ['a', 'b', 'new', 'mpilgrim', 'z', 'example', 'new', 'two', 'elements'] >>> li.index("example") 5 >>> li.index("new") 2
Removing Elements from a List
>>> li ['a', 'b', 'new', 'mpilgrim', 'z', 'example', 'new', 'two', 'elements'] >>> li.remove("z") >>> li ['a', 'b', 'new', 'mpilgrim', 'example', 'new', 'two', 'elements'] >>> li.remove("new") >>> li ['a', 'b', 'mpilgrim', 'example', 'new', 'two', 'elements']
List Operators
>>> li = ['a', 'b', 'mpilgrim'] >>> li = li + ['example', 'new'] >>> li ['a', 'b', 'mpilgrim', 'example', 'new'] >>> li += ['two'] >>> li ['a', 'b', 'mpilgrim', 'example', 'new', 'two'] >>> li = [1, 2] * 3 >>> li [1, 2, 1, 2, 1, 2]
Defining a tuple
>>> t = ("a", "b", "mpilgrim", "z", "example") >>> t ('a', 'b', 'mpilgrim', 'z', 'example') >>> t[0] 'a'
Assigning multiple values at once
>>> v = ('a', 'b', 'e') >>> (x, y, z) = v >>> x 'a' >>> y 'b' >>> z 'e'
Assigning Consecutive Values
>>> range(7)
[0, 1, 2, 3, 4, 5, 6]
>>> (MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY) = range(7)
>>> MONDAY
0
Introducing String Formatting
>>> k = "uid" >>> v = "sa" >>> "%s=%s" % (k, v) 'uid=sa'
String Formatting vs. Concatenating
>>> uid = "sa"
>>> pwd = "secret"
>>> print pwd + " is not a good password for " + uid
secret is not a good password for sa
>>> print "%s is not a good password for %s" % (pwd, uid)
secret is not a good password for sa
Formatting Numbers
>>> print "Today's stock price: %f" % 50.4625 50.462500 >>> print "Today's stock price: %.2f" % 50.4625 50.46 >>> print "Change since yesterday: %+.2f" % 1.5 +1.50
Introducing List Comprehensions
>>> li = [1, 9, 8, 4] >>> [elem*2 for elem in li] [2, 18, 16, 8] >>> li [1, 9, 8, 4] >>> li = [elem*2 for elem in li] >>> li [2, 18, 16, 8]
The keys, values, and items Functions
>>> params = {"server":"mpilgrim", "database":"master", "uid":"sa", "pwd":"secret"}
>>> params.keys()
['server', 'uid', 'database', 'pwd']
>>> params.values()
['mpilgrim', 'sa', 'master', 'secret']
>>> params.items()
[('server', 'mpilgrim'), ('uid', 'sa'), ('database', 'master'), ('pwd', 'secret')]
List Comprehensions in buildConnectionString, Step by Step
>>> params = {"server":"mpilgrim", "database":"master", "uid":"sa", "pwd":"secret"} >>> params.items() [('server', 'mpilgrim'), ('uid', 'sa'), ('database', 'master'), ('pwd', 'secret')] >>> [k for k, v in params.items()] ['server', 'uid', 'database', 'pwd'] >>> [v for k, v in params.items()] ['mpilgrim', 'sa', 'master', 'secret'] >>> ["%s=%s" % (k, v) for k, v in params.items()] ['server=mpilgrim', 'uid=sa', 'database=master', 'pwd=secret']