old notes

UofTBootcamp

#UofTBootcamp #netsec #cyberkillchain #c2 #homework #classwork

Follow-up Questions

11.1 Notes – how does firewall affect zoom/signal? – review TCP flags – meaning of “stateness” as agnostic of network connection? – ACTIVITY: blocking all ICMP pings – i thought this was not a good practice


Homework

Layered Security: multiple products to address a single aspect of security

  • gateway (hardware) and firewall (hard and soft) to restrict access
  • subset of defense in depth
  • evaluated in three areas: administrative, physical, technical
  • admin: policies and procedures, i.e. role-based access control (RBAC) or employee training against phishing scams
  • physical: locking server rooms

Defense in Depth: Redundancy approach

  • strategy leveraging multiple security measures so if one line of defense is compromised, additional layers are backup
  • buys time to launch countermeasures if infiltrated
  • addresses hardware, software, people re: negligence, human error
  • includes anti-virus, firewalls, secure gateways, VPNs, machine learning to detect anomalies in behaviour of employees and endpoints

common issues organizations have to deal with when implementing a cybersecurity strategy:

  • anti-malware software not updated or is not installed on all devices.
  • Employees have not been trained and are falling victim to phishing schemes.
  • Software patches are not being updated or are ignored.
  • Security policies are not enforced or even known by employees.
  • Missing or poorly implemented encryption.
  • Remote employees are connecting to unsecured networks, such as the public internet.
  • Physical security flaws, such as unsecured server rooms.
  • Business partners, such as cloud service providers, are not fully secure.

Elements of Defense in Depth System:

1. Physical Controls: key cards to enter a building or scanners to read fingerprints 2. Net Sec controls: software authenticating employee to enter network/use device/application 3. Admin controls: authorizes employees, once authenticated, to access only certain applications or parts of the network 4. Antivirus: stops malicious software from entering network/spreading 5. Behavioural Analysis: algorithmns/ML can detect anomalies in the behaviour of employees and in the application and devices themselves

Core layers of defense in depth strategy should include:

  • Strong, complex passwords
  • Antivirus software
  • Secure gateway
  • Firewall
  • Patch management
  • Backup and recovery
  • least privilege

  • As companies grow and the number of devices, applications, and services used across the organization increases, these serve as important security layers in a defense-in-depth strategy:

  • Two-factor authentication (2FA) or multi-factor authentication (MFA)

  • Intrusion detection and prevention systems

  • Endpoint detection and response (EDR)

  • Network segmentation

  • Encryption

  • Data loss prevention

  • VPNs

Intrusion Detection and Attack indicators

difference-between-ids-ips-venn-diagram-768x611.webp

1. What's the difference between an IDS and an IPS?

IDS (Intrusion Detection System) is a detection and monitoring tool that doe snot take action on its own so a human (or another system) has to read and interpret the results. IPS (Intrusion Prevention System) is a control system that accepts or rejects a packet based on the rulelist — this means that unlike IDS, the IPS can take action against potential attacks.

Another difference is that IPS sits on the network in the same area as a firewall might (between the outside and internal network) so traffic has to flow through the IPS. An IDS only monitors the traffic, it is not in the line of traffic.

The last difference is that while both are known for generaeting false positives, in the event of an IDS, the false positive will only create alerts whereas for the IPS, this coudl cause the loss of important data or functions (again because it sits on the network).

2. What's the difference between an Indicator of Attack and an Indicator of Compromise?

An Indicator of Attack (IOA) focuses on detecting the intent of what an attacker is trying to accomplish regardless of the malware or exploit being used and is typically an alert before a network or application is exploited. On the other hand, an Indicator of Compromise (IOC) is regarded as the evidence that indicates a network security breach. It is usually gathered after a suspicious incident, on a scheduled basis or after an unusual discovery.

The Cyber Kill Chain

Name each of the seven stages for the Cyber Kill chain and provide a brief example of each.

1. Stage 1: Reconnaisance – Attackers pick a target and perform analysis, collect information (such as email addresses, conference information, technology stack, etc) and evaluate their target's weaknesses.

Example: Trying to discover what firewalls or intrusion prevention systems are in place for a targeted network. Using tools such as nmap, stan, or Strobe to search for vulnerabilities.

2. Stage 2: Weaponization – Attackers determine how best to get inside the network by exploiting the discovered vulnerabilities.

Example: Using a malware tailored to exploit the specific techhology that they discovered in the Reconnaisance stagethat the target network uses. Using a Zero-day vulnerability they have discovered.

3. Stage 3: Delivery – The chosen attack method is delivered to the target encironment.

Example: An infected USB drive is dropped off at the target office, a malicious attachment is sent via a phishing email, etc.

4. Stage 4: Exploitation– The attackers leverage the vulnerabilities and execute the malicious code on the target network.

__Example: __Triggering a Buffer overflow/underflow on a vulnerable database.

5. Stage 5: Installation – The malware weapon is installed, giving the attaker's an access point to the target environment, ideally one that they can return to effortlessly.

Example: A DLL Hijacking attack that exploits the way some Windows applicatons search and load Dynamic Link Libraries (DLL) by copying the name of a legitimate DLL and placing the malicious DLL in a position that the application will search first so that the malicious DLL will load instead. The malicious DLL could be written to launch the malware and then the legitimate DLL can be loaded to avoid suspicion, creating a persistent point of entry for the attacker.

6. Stage 6: Command and Control (C2) – The attackers have uninterrupted remote access to the target environment and can manipulate it to their choosing.

__Example: __

7. Stage 7: Actions on Objective – The original goal(s) of the attack can be executed.

Week 11.1 Notes: Intro Netsec + Firewalls

Defense in Depth: Perimeter || Network || Host || Application || Data

Net Sec Definition from SANS:

  • physical and software preventative measures to protect underlying network infrastructure from unauthorized access, misuse, malfunction, modification, destruction, or improper disclosure
  • goal is to create a secure platform for computers, user, programs to perform permitted critical functions within secure environment

Firewall: between application servers and routers to provide access control

  • control access to single host or network
  • first layer of defense on perimeter of the network's edge
  • can slow connections, affect lack of connection, break networked apps like zoom, messager
  • filter incoming/outgoing packets
  • access policies / rules

Firewall Steps:

(1) Intercept traffic before it reaches target host or router (2) Inspect source and destination address, ports, TCP flags, and other features of incoming packets (3) Allow/deny packets

Firewall Types + OSI

MAC: useless comparison to approval list, can be spoofed easily

STATELESS Packet Filtering : create checkpoints within a router and examine packets as they progress through an interface; if not pass inspection, drop – stateless = does not care about network connection – layer 3-4 – statically evaluate contents of packets and do not keep track of the state of a network connection – use rules based on individual packets such as: source/destination IP, source/destination port info, IP protocols, Ingress and egress interface – vulnerable to spoofing, no custom rules

STATELESS Packet Filtering : still L3-4 but is stateful so it can determine whether a packet is NEW, ESTABLISHED, or rogue bc it understands context of entire data stream. – statefull firewalls do not look at individual packets but connection as a whole – inspect packets' conversation and routing tables, use a combination of TCP handshake verification and packet inspection tech – cannot determine what traffic is doing, only identify that a connection is using x protocol, not what the payload is

Circuit-level gateways: SESSION LAYER – verify the TCP handshake by looking at the HEADER of a packet only – NOT PAYLOAD – TCP handshake checks verify: unique session identifier, state of connection (established vs closed), sequencing info – ensures that session packets are from legit sources – fast/easy but does not check contents of packets – if packet contains malware but has correct TCP, data is allowed to pass

Application gateways: Proxy firewalls L3-7, STATEFUL – inspect actual contents of packet, including authentication and encryption – use deep packet inspection and stateful inspection to determine if incoming traffic is safe or harmful – intercept all traffic without data source knowing – connection is established to proxy firewall which inspects traffic and passes/drops – more secure, provides log/file audit – resource intensive, requires hardware, bypassed with encryption

UFW: Uncomplicated Firewall: provides stateless and stateful packet filtering

  • works on all kinds of network address and port translation, i.e. NAT, NAP (Network Addressing Protection)
  • manage multiple devices over CLI UFW features:
  • host-based
  • multi-level logs, great insight into attacks
  • remote management – security concern?
  • rules for allow/deny regarding: source/destination IP addresses, port numbers, packet types — all without opening packet
  • TCP handshake, packet inspection
  • rate-limited connections to protect from brute force DISADVANTAGE: all firewall services must be stopped/restarted for changes, interrupting service

firewalld: dynamically managed firewall w/o disruption using zones to divide network interfaces into groups of shared trust level

Zones: each zone has rules/configs that can runtime (valid until next reboot or service reload, used for testing) or permanent Services: designate which service you want ot allow, it will automatically open those ports

11.1 Activities

Activity UFW (Uncomplicated Firewall) – need to have ports 110, 143, 587, 80, 443 to be open at all times as part of its daily operations. -


#networking #dns #nslookup #dig #cname #aircrackng #UofTBootcamp

Follow-Up Questions from Homework9

Q2 – does it matter that we are getting non-authoritative answers from a recursive resolver (8.8.8.8) vs getting an authoritative one? – what is the difference between using this: nslookup -type=cname www.theforce.net And getting: Non-authoritative answer: www.theforce.net canonical name = theforce.net.

VS.

nslookup -type=cname theforce.net and getting: Non-authoritative answer: *** Can't find theforce.net: No answer

Authoritative answers can be found from: theforce.net origin = WebPublish_Othe mail addr = hostmaster serial = 2017110901 refresh = 900 retry = 600 expire = 86400 minimum = 3600

https://stackoverflow.com/questions/66014432/how-to-find-the-canonical-name-with-nslookup

Q3: – what does NX DOMAIN tell us for sure? https://bluecatnetworks.com/blog/what-you-can-learn-from-an-nxdomain-response/ – follow-up on conclusion


Networking Fundamentals: Homework 9

Your task is a crucial one: Restore the Resistance's core DNS infrastructure and verify that traffic is routing as expected.

Mission 1:

Network Issue:

The Resistence has taken down their primary DNS and email servers in order to a build and deply a new DNS and mail server but they are not currently receiving emails because they have no configured MX Records for the new email servers.

DNS record type found:

We want to check the MX records (mail exchanger records) which specify which mail servers can accept email that's sent to our domain with: starwars.com: nslookup -type=mx starwars.com

DNS records that can explain the reasons for existing network issue:

According to our nslookup results, the new mail servers are not listed. The primary mail server for starwars.com should be asltx.l.google.com and the secondary email should be asltx.2.google.com.

`Server: 192.168.2.1 Address: 192.168.2.1#53

Non-authoritative answer: starwars.com mail exchanger = 5 alt2.aspmx.l.google.com. starwars.com mail exchanger = 1 aspmx.l.google.com. starwars.com mail exchanger = 10 aspmx2.googlemail.com. starwars.com mail exchanger = 10 aspmx3.googlemail.com. starwars.com mail exchanger = 5 alt1.aspx.l.google.com.`

Instead, the primary server (indicated by the numeric value of 1 before the server address) is: aspmx.l.google.com. The secondary server is either: aspmx.l.google.com. or alt1.aspx.l.google.com. as both addresses have the next priority value of 5.

It's likely that these are the old servers and someone has forgotten to change the MX record configuration to the new servers at: asltx.l.google.com and asltx.2.google.com.

Recommended fixes to save the Galaxy!

The corrected MX record should be:

starwars.com mail exchanger = 1 asltx.l.google.com starwars.com mail exhanger = 2 asltx.2.google.com

Mission 2:

Network Issue:

Official emails are going into spam or being blocked because the SPF record has not been updated to reflect the new IP address of their mail server. Since the SPF record is used to indicate which mail servers are allowed to send emails on behalf of a domain, emails from the IP address of the new mail server (missing from the current SPF record) is likely to be filtered out as spam.

DNS record type found:

Looking up the SPF (Sender Policy Framework) record using nslookup -type=txt theforce.net | grep spf to find the following SPF record::

theforce.net text = "v=spf1 a mx mx:smtp.secureserver.net include:aspmx.googlemail.com ip4:104.156.250.80 ip4:45.63.15.159 ip4:45.63.4.215"

Alternatively, we can also use the dig DNS lookup utility: dig theforce.net txt | grep spf which confirms the same SPF record:

theforce.net. 3498 IN TXT "v=spf1 a mx mx:smtp.secureserver.net include:aspmx.googlemail.com ip4:104.156.250.80 ip4:45.63.15.159 ip4:45.63.4.215"

DNS records that can explain the reasons for existing network issues:

The servers currently configured to be allowed to send emails for the domain are from the following IPv4 hosts: 104.156.250.80, 45.63.15.159, and 45.63.4.215. The new one (45.23.176.21) has not beed added. It is likely that similar to Mission 1, someone has forgotten to update changes made while the network was down.

Recommended fixes to save the Galaxy!

We have not been given data regarding the other mail server IP addresses — if we assume that those are still correct and do not need to removed, we only need to add the missing IP so that the corrected record should be:

theforce.net. 3498 IN TXT "v=spf1 a mx mx:smtp.secureserver.net include:aspmx.googlemail.com ip4:104.156.250.80 ip4:45.63.15.159 ip4:45.63.4.215 ip4:45.23.176.21

Mission 3:

Network Issue:

DNS record type found:

We need to check the CNAME record of the resistance.theforce.net domain in order to see why it is not redirecting to theforce.net. A CNAME record is used to point one domain to another so if we want the resistance.theforce.net subdomain to point to theforce.net, we need to have the CNAME configured to do so.

DNS records that can explain the reasons for existing network issues:

Looking up the CNAME (Canonical Name) of www.theforce.net with nslookup in interactive mode in order to examine a correct CNAME configuration where www.theforce.net will be redirected to theforce.net:

nslookup to enter into interactive mode

> set query=CNAME to set the query type to CNAME > www.theforce.net to set the domain to query

This gives the following (relevant) output:

www.theforce.net canonical name = theforce.net.

Alternatively, we can also use single line command nslookup -type=CNAME www.theforce.net or dig www.theforce.net | grep CNAME if we like to confirm things in multiple ways before moving forward:

www.theforce.net. 2321 IN CNAME theforce.net. is the output from dig indicating the correct configuration.

Looking up why our resistance.theforce.net is not redirecting to theforce.net:

Using nslookup -type=CNAME resistance.theforce.net we get:** server can't find resistance.theforce.net: NXDOMAIN which is an error message indicating the DNS query failed because the domain name queried (resistance.theforce.net does not exist or that the query could not “know” that it exists.

This could mean (if we assume we have not made a user error in our query, i.e. mistyping the address): – the domain is currently offline or is having server issues – a security control blocking the domain – domain could be compromised or that malware exists

To follow-up, we can first check if the domain is offline using https://isitup.org/resistance.theforce.net which indicates that the domain is down. This makes sense because we are supposed to be redirecting resistance.theforce.net to the CNAME domain theforce.net so the subdomain should not exist on its own.

Recommended fixes to save the Galaxy!

To fix this, we need to correct the CNAME record configuration to have this line:

resistance.theforce.net canonical name = theforce.net.

Mission 4

Network Issue: DNS record type found: DNS records that can explain the reasons for existing network issues: Recommended fixes to save the Galaxy!

Mission 5:

Network Issue:

Slow network traffic from the planet of Batuu to Jedha due to an attack on Planet N.

The routing protocol in use is OSPF Open Shortest Path First.

Recommended fixes to save the Galaxy!

The new path to use is:

Mission 6:

Your Mission:

  • Figure out the Dark Side's secret wireless key by using Aircrack-ng.

Results from running Aircrack-ng with the password list downloaded from: https://github.com/danielmiessler/SecLists/blob/master/Passwords/WiFi-WPA/probable-v2-wpa-top4800.txt

`[00:00:00] 3432/4800 keys tested (10349.88 k/s)

Time left: 0 seconds 71.67%

KEY FOUND! [ dictionary ]

Master Key : B3 52 50 D0 9F 8E AB BD 0D 9E 3D D3 A3 62 12 82 9E FA 89 FC 19 1D A4 4A 3E 7A 40 9C D4 DF 68 DC

Transient Key : DF 26 D4 B0 47 58 E5 AB 33 66 35 14 87 70 7E 46 9E 93 3F 48 3A AE BE F5 0A 58 81 82 B1 59 56 A4 05 C4 04 F4 F0 E2 27 45 49 3D 51 9C A0 E0 AA 83 5F 63 D5 35 A5 56 52 24 35 70 31 08 BE 99 F6 15

EAPOL HMAC : 3E B9 D6 B8 63 69 A7 8B 83 EA 2A 3A 71 ED CF 59`

The password is: dictionary. We use this password to decrypt the WPA traffic via Wireshark.

  • Once you have decrypted the traffic, figure out the following Dark Side information:

    • Host IP Addresses and MAC Addresses by looking at the decrypted ARP traffic.

Host: Sender MAC address: IntelCor_55:98:ef (00:13:ce:55:98:ef) Sender IP address: 172.16.0.101 (172.16.0.101)

Looking for: Sender MAC address: Cisco-Li_e3:e4:01 (00:0f:66:e3:e4:01) Sender IP address: 172.16.0.1 (172.16.0.1)

Mission 7:

Viewing the DNS record from Mission #4, specifically looking for a hidden message in the TXT record:

nslookup -type=txt princessleia.site to find this message:

princessleia.site text = "Run the following in a command line: telnet towel.blinkenlights.nl or as a backup access in a browser: www.asciimation.co.nz"

Take a screen shot of the results:

Note: This was the coolest last homework question ever! And thank you for reading.

#wireshark #networking #ip #tcp #udp #arp #http #dns #aircrack #nslookup #cheatsheet #UofTBootCamp


General

!(arp or icmp or dns) filter out whatever udp contains xx:xx:xx filter for certain HEX values at any offset

Search by string/regex/hex value: Edit > Find Next > Select your Filter/Search Input


802.11

Wireshark Beacon Filter: wlan.fc.type_subtype = 0x08 Wireshark broadcast filter: eth.dst == ff:ff:ff:ff:ff:ff Wireshark multicast filter: (eth.dst[0] & 1)


ARP

arp.opcode == 1 for requests arp.opcode == 2 for responses

Operation code params: https://www.iana.org/assignments/arp-parameters/arp-parameters.xhtml#arp-parameters-1


DNS

queries: dns.flags.response == 0 responses: dns.flags.response == 1

errors: dns.flags.rcode == 0 no error dns.flags.rcode != 0 dns requests couldn't be correctly resolved. dns.flags.rcode == 3 no such name

examples dns.a dns.cname dns.qry.name == example.com dns.resp.name == example.com dns.resp.name == example.com and dns.time > 0.01


HTTP

http.request.method==GET http.request.method==POST. ip.addr==93.184.216.34 and http.request.method==GET


IP

ip.addr == < ip > ip.dest == < ip > ip.src == < ip > !(ip.addr == <ip>) range: ip.addr >= 10.10.50.1 and ip.addr <= 10.10.50.100 multiple: ip.addr == <ip> and ip.addr == <ip> subnet: ip.addr == 10.10.50.1/24 port: tcp.port == 25 or tcp.dstport == 23 ip and port: ip.addr == <ip> and Tcp.port == 25


TCP

handshake: SYN, SYN/ACK, ACK tcp.flags.syn ==1 && tcp.flags.ack == 0 to view only SYN tcp.flags.syn ==1 && tcp.flags.ack == 1 to view only SYN/ACK requests tcp.flags.syn == 0 && tcp.flags.ack == 1 to view only ACK

termination packets: tcp.flags.fin == 1

look for open port: (since it will respond with SYN/ACK) tcp.flags.syn == 1 && tcp.flags.ack == 1

display all TCP resets: (connection killed) tcp.flags.reset==1

packets that contain a certain term in packet: tcp contains xxx

Follow a tcp stream: tcp.stream eq X

Filter by seq num: tcp.seq == x

Detects push events for troubleshooting: tcp.flags.push == 1


nslookup

Syntax: nslookup -type=[NS record type] [domain] look up name server records

nslookup Option Description -domain=[domain-name] Change the default DNS name. -debug Show debugging information. -port=[port-number] Specify the port for queries. The default port number is 53. -timeout=[seconds] Specify the time allowed for the server to respond. -type=a View information about the DNS A address records. -type=any View all available records. -type=hinfo View hardware-related information about the host. -type=mx View Mail Exchange server information. -type=ns View Name Server records. -type=ptr View Pointer records. Used in reverse DNS lookups. -type=soa View Start of Authority records.

nslookup -type=txt <domain> for spf records


Aircrack-ng

  • syntax: Aircrack-ng [.pcap file name]
  • Note: the Wireless Toolbar no longer exists in view > it is now in: Wireshark > Preferences > Protocols > IEEE 802.11 for putting in relevant key

Word lists for WPA https://www.aircrack-ng.org/doku.php?id=faq#where_can_i_find_good_wordlists

#networking #OSI #wireshark #dns #nslookup #tcp #ip #80211 #email #UofTBootcamp #arp

Follow-Up Questions from Class Activities

  • Activity 9.2.09 on Email Security: missing emails? Why is SPF failing – can't see the email Networking Review Activity:
  • What networking devices use these values for mac addresses- don't they all?
  • What is the original source IP? 0.0.0.0??
  • CIDR & ip range review!! Network Attacks Review Activity:
  • if this is the only data, how can you know for sure which is good/which is mac address of hacker's device? [Duplicate IP address detected for 192.168.47.254 (00:0c:29:1d:b3:b1) - also in use by 00:50:56:f9:f5:54 (frame 2013)]

DNS

  • translates URI into IP address
  • DNS zone file: actual file containing all the DNS records for a particular domain
  • lives in DNS server
  • contains a TTL indicating how long a DNS cache will remember the information

DNS Record Types: CONTAINED IN DNS ZONE FILE

  • A Record: Translates domain to IP address
  • PTR Record: Translates IP into domain
  • CNAME Record: Alias record used to point one domain to another domain
  • SOA record: Contains administrative details about a domain, such as: email address of the administrator, TTL value, when the domain was last updated

MX Record: mail exchange: directs emails to specific mail server; if multiple, can be set with preferences

TXT Record: created to include human-readable notes

SPF record: Sender Policy Framework: determines if email is from a trusted server

  • type of TXT Record
  • indicates which mail servers are allowed to send emails on behalf of a domain by checking:
  • Check the sending mail server's IP address, 12.54.54.23.
  • Validate the DNS record of widget.com's SPF record to confirm the sending mail server's IP address is either 23.43.54.235 or 23.43.54.236 (the valid mail server IPs)
  • Since the sender's IP is 12.54.54.23 (not 23.43.54.235 or 23.43.54.236), gadgets.com's mail server can identify the email as spam and potentially reject it or send it to the recipient's spam folder.

nslookup

nslookup -type=[NS record type] [domain] look up name server records

To look up the MX record: nslookup -type=MX gadget.com

To look up the A record: nslookup -type=A gadget.com

To look up the SOA record: nslookup -type=SOA gadget.com

nslookup Option Description -domain=[domain-name] Change the default DNS name. -debug Show debugging information. -port=[port-number] Specify the port for queries. The default port number is 53. -timeout=[seconds] Specify the time allowed for the server to respond. -type=a View information about the DNS A address records. -type=any View all available records. -type=hinfo View hardware-related information about the host. -type=mx View Mail Exchange server information. -type=ns View Name Server records. -type=ptr View Pointer records. Used in reverse DNS lookups. -type=soa View Start of Authority records.

Email Headers

Some of the most important fields in this raw email are:Return-Path: Specifies the sender's return email. – Delivered-To: Specifies the recipients email. – Received: Shows a list of mail servers, illustrating the path taken by the email from its source to destination. – Message-ID: A unique string created by the sending mail server as an identifier of the email. – Received SPF: The SPF verification field, which we will cover in more detail in the next activity.

Security Concerns for Emails

__ SPAM__: mitigate with using SPF records, matching list of known spam senders, and keyword identification Sending Confidential Emails across encrypted channels: – emails are typically routed across multiple mail servers – encryption tools: PGP: Pretty Good Privacy or S/MIME: Secure/Multipurpose Internet Mail ExtensionsEmail Spoofing

Detecting Email Spoofing:

(1) Check the From email header (2) Check the Received-SPF email header – Received-SPF uses the IP address from the Received field and determines if it's an IP of an authorized sender with pass/fail (3) Check the Received Email Header – look up the source IP of the mail server that sent the email – For example, the ARIN Whois/RDAP tool.


Class Activities

Analyzing DNS Records:

MX Record: splunk.com mail exchanger = 20 mx1.splunk.iphmx.com. splunk.com mail exchanger = 20 mx2.splunk.iphmx.com. Type A Record: Non-authoritative answer: Name: splunk.com Address: 52.5.196.118 Name Server Non-authoritative answer: splunk.com nameserver = ha2.markmonitor.zone. splunk.com nameserver = ha1.markmonitor.zone. splunk.com nameserver = ha4.markmonitor.zone. splunk.com nameserver = ha3.markmonitor.zone.

Bonus: dig nmap.org txt | grep "spf" gives us 3 servers authorized to send mail from:

nmap.org. 3600 IN TXT "v=spf1 a mx ptr ip4:45.33.49.119 ip6:2600:3c01::f03c:91ff:fe98:ff4e ip6:2600:3c01:e000:3e6::6d4e:7061 `include:_spf.google.com ~all"

Analyzing Email Headers Activity:

determine the following data points: Email 1: – Delivered-To: juliejones@acme.com – Return-Path: jonathanthomas@microsoft.com – IP address of source domain: 40.76.4.15 from: Received-SPF: pass (google.com: domain of jonathanthomas@microsoft.com designates 40.76.4.15 as permitted sender) client-ip=40.76.4.15; – Message-ID: 1689837351.2998569.1568044304435@mail.microsoft.com

Email 2: permitted by SPF but clearly spam – Delivered-To: juliejones@acme.com – Return-Path: xzvvvret34344@yahoo.com – IP address of source domain: 74.6.130.41 from: Received-SPF: pass (google.com: domain of xzvvvret34344@yahoo.com designates 74.6.130.41 as permitted sender) client-ip=74.6.130.41; – Message-ID: 1689837351.2998569.1568044304435@mail.yahoo.com

Email 3: – Delivered-To: juliejones@acme.com – Return-Path: timmytom@widgets.com – IP address of source domain: 34.86.130.4 from: Received-SPF: fail (google.com: domain of timmytom@widgets.com does not designate 34.86.130.49 as permitted sender) client-ip=34.86.130.49 ; – Message-ID: 1gytrdd9837351.987987abs9.1568044304435@mail.widgets.com

Networking Review Activity

A. Answer the following questions on HTTP: 7. What is the the port number range that this port is part of? 58424 or 62412 There are 49,152 – 65,535 dynamic and/or private ports.

  • Under Ethernet II is a value of Destination: Technico_65:1a:36 (88:f7:c7:65:1a:36)
    1. What does this value represent? MAC address of physical device where this is going
    2. Which OSI layer does this exist in? Datalink (2)
    3. What networking devices use these values? Don't all devices?

Part Two: ARP

  1. What type of networking request does ARP first make? Broadcast

B. Use a filter to find the count of ARP responses, and answer the following questions:

arp.opcode 0 Reserved [RFC5494] 1 REQUEST [RFC826][RFC5227] 2 REPLY [RFC826][RFC5227]

arp.opcode == 1 for requests arp.opcode == 2 for responses

  1. What is the IP of the device that is responding? Sender MAC address: IntelCor_10:ac:c0 (a0:a4:c5:10:ac:c0) Sender IP address: 10.0.0.32 (10.0.0.32)

  2. To what IP is the device responding to? Target IP address: c66251b0-093d Target MAC address: c66251b0-093d-7d9c-4f7c-c2fc9df7c3ca.local (e4:f0:42:3b:7a:de) -7d9c-4f7c-c2fc9df7c3ca.local (10.0.0.10)

  3. Write out in simple terms what has taken place, describing the request and response. Host makes a broadcast to find the MAC address of the IP = request. Response = information locating the MAC address.

DHCP B. Use a filter to view the DHCP Discover, and answer the following questions on that packet:

###1. What is the original source IP? 0.0.0.0????###

  1. Why does it have that value? Unknown IP – usually to indicate that the local IP address is not assigned.

  2. What is the original destination IP? Internet Protocol Version 4, Src: 0.0.0.0 (0.0.0.0), Dst: 255.255.255.255 (255.255.255.255)

  3. What does that value signify? broadcast

C. Use a filter to view the DHCP ACK, and answer the following questions on that packet. dhcp.option.dhcp == 5

### 1. Explain in simple terms what is happening in this packet.

  • DHCP Ack server which received the DHCP request message fro client checks if the IP address shown in the DHCP Server Identifier matches its own
  • broadcasts a DHCP Ack message ensuring client can receive the message -transfer net config data to client including:

    • IP address
    • Subnet mask
    • Default gateway IP address
    • DNS server IP address
    • Lease time (during which a client can use the IP address allocated/leased by a DHCP server)
    1. Define the term “DHCP lease.” Amount of time in minutes or seconds a network device can use an IP address in a network. IP is reserved for that device until expiration.

    2. What is the DHCP lease time provided in this packet? IP Address Lease Time: (604800s) 7 days

    3. What are the steps in a TCP connection? SYN, SYN-ACK, ACK

    4. What are the steps in a TCP termination? FIN. ACK, FIN, ACK

    5. What steps appear in the packets displayed? the handshake steps

    6. What type of activity/protocol is TCP establishing a connection for? in this case httpTCP is generally used to provide reliable stream delivery service, i.e. delivering data as a stream of bytes and deceiving data as a stream of bytes.

    7. What is the website name being accessed after the TCP connection? Host: sportingnews.com\r\n

Topologies

  1. What are the Topologies for A, B, C? Tree, Hybrid of Bus and Tree, Disconnected ring?

  2. What are the advantages and disadvantages for each?

    • Network Devices
  3. In the network devices illustration, what are numbers one through four? Internet, Firewall, router, Switch

  4. What does the dashed line represent in number five? firewall security?

  5. What is a load balancer? distributes traffic across multiple servers to improve application availability and responsiveness and prevent server overload

4. Where would you place a load balancer? Between access and servers? Internet || servers or switch || servers?

  • Network Routing
  • Which routing protocols use distance as criteria? Distance Vector Routing Protocols:
  • RIP (Routing Information protocol)
  • EIGRP (Enhanced Interior Gateway Routing Protocol)
  1. Which routing protocols use speed as criteria? Link-State Routing Protocols
  2. OSPF: Open Shortest Path First

Part Six: Network Addressing:

  1. Define binary. base-2 number system (0 and 1s) used to write machine code

  2. What are IP addresses used for? network interface identification and location addressing

  3. What are the two primary versions of IP addresses? IPv4 and IPv6

  4. How many octets are in a IPV4 address? IPv4 – 32 bits – 4 octects IPv6 – 128 bits – 16 octets

  5. What is the difference between primary and public IP addresses? private is within a network or subnet, public is on the internet and unique.

8. What is CIDR? “Classless Inter-Domain routing”

  • allocating IP addesses and IP routing

9. What is the range of IP addresses in: 192.18.65.0/24?


Network Attacks Review Activity

  • ARP spoof attack – redirects traffic
  • DHCP starvation attack – floods with DHCP requests so runs out of IP, type of denial of service
  • TCP packets show port scanning,
  • Wireless Attacks:
  • What are the different security types available for Wireless communications? List them in order from least to most secure. WEP – WPA – WPA2
  1. What is 802.11? Wifi Standard (protocol)

  2. What is an SSID? a more recognizable format of how a networking hardware device identifies itself as broadcasting a wireless signal beacon

  3. What is the name of the the signal a WAP sends out identifying its SSID? beacon

  4. If a user has WEP encrypted wireless, what is a potential negative outcome? it's old and hackable easily with aircrack-ng

#networking #UofTBootcamp #classwork #dns #binary #OSI #wireshark

Follow-UpQuestions

Layer 2: data link From class slides: – class covers arp here which yes, tracks MAC so layer 2 but isn't ARP itself a layer 3 (network) protocol? – what does “primary vendor for the MAC addresses” mean? in Activity 8.3.1 on ARP packets – do we need to know the details of TTL columns? – STILL CONFUSED ABOUT LAYER 1-2!!!!!

Layer 3: network

Layer 4: transport – asynchronous response > does this count as one request/response cycle? From class TCP demo: – Where is the flag set to 1 or 0 in the tcp packets for Wireshark?

Layer 7: application From homework: – authoritative vs non-authoritative DNS & usage/security implications? – DNS vulnerabilities question: why was hacker able to access server as root to create ARP spoof and is there evidence of this?

NOTES ON TROUBLE-SHOOTING FROM MIRZA @ END


Subnetting Basics

  • flat networking = everyone on the same network
  • the use of subnetting to create segmentation bc otherwise it becomes congested – router in between networks, switch within a network
  • subnetting also called “broadcast domains”

  • as soon as you fire up a machine, it starts broadcasting

enumeration: the process of gathering data for a specific network, usually for the purpose of finding new ways to gain access into that network

ARP: Address resolution protocol: find the MAC address of a device from an IP address

  • communication between devices on a local network
  • example: ethernet network that requires physical addresses to be known before sending packets

ARP request and reply process: (1) device sends ARP request message containing the IP address of the receiving device (2) all devices on a local network segment see the message but only the device that has the IP address response with ARP reply containing its MAC address

ARP cache: – mapping of MAC address to IP address that is added to the ARP cache — called dynamic ARP entry of the – ARP cache timeout: record is removed from ARP cache so any future requests for hosts require a new ARP request

Wireshark + ARP:

arp.code == 1 shows only ARP requests arp.code == 2 shows only the ARP responses

SECURITY IMPLICATIONS of ARP:

ARP cache poisoning or ARP spoofing – terms used interchangeable though poisoning is corrupting and spoofy is impersonation – Any device on the network can answer an ARP request regardless of whether the original message was intended for it or not. F – example: If Computer A asks for the MAC address of Computer B, an attacker at Computer C can respond and Computer A would accept this response as authentic.

DETECT ARP ATTACK:

arp -a will check your current mapping

Boot Camp Example:

The good host's address is <example ip> and the good host's correct MAC address is <example MAC address> – the hacker will send a spoof ARP message so that all future traffic intended for the good MAC address will instead to the hacker's MAC address. It will look like this when detected with WireShark:

Duplicate IP address detected for 192.168.47.2 (00:0c:29:1d:b3:b1) - also in use by 00:50:56:fd:2f:16 (frame 301)

ARP Poisoning Attack Steps According to Self-Study: 1. Attacker Selects a Victim Machine/Machines: – select a target such as a specific endpoint, a group of endpoints, or a network device like a router. – routers are attractive targets because a successful ARP poisoning attack against a router can disrupt traffic for an entire subnet

  1. Attacker Launches Tools and Begins the Attack:
  2. arpspoof or driftnet

  3. Attacker does something with the steered traffic:

  4. inpsect, alter, blackhole it, etc.

TWO general types of ARP Poisoning Attacks 1. wait to see ARP requests for a particular target and issue a response 2. send out an unsolicited broadcast message known as a gratuitous ARP

Man-in-the-Middle (MiTN) Attack: – attacker sends out falsified ARP responses for a given IP, typically the default gateway for a subnet – victim machines populate their ARP cache with the MAC of attacker's machine instead of local router's MAC address – Victim machines now forward network traffic to the attacker – tools like Ettercap allow attacker to act as proxy for viewing or modifying info before sending to intended destination – victim will never notice

Denial of Service (DOS) Attack: – denying one or more victims access to network resources – attacker sends out ARP Response messages that falsely map hundreds or even thousands of IP addresses to a single MAC address, potentially overwhelming the target machine – type of attack, such as ARP flooding, can also be used to target switches, impacting performance of entire network

Session Hijacking – similar to MiTM except attacker does not directly forward traffic from victim machine to intended destination but instead captures a genuine TCP sequence number or web cookie from the victim to use it to assume the victim's identity – can be used to login anywhere!!!

Consequences of ARP poisoning attack?

  • ARP caches are deleted in anywhere from a few minutes to several hours so no permanent infection
  • can be chained in larger campaign

MITIGATION:

(1) Static ARP Tables: – highly effective but huge admin burden bc changes require manual updates of ARP tables across all hosts, making static ARP tables unfeasible for most larger orgs – can carve out separate network segment for static ARP tables where sec is crucial

(2) Switch Security: – Business-grade ethernet switches have __Dynamic ARP Inspection (DAI) used to eval validity of ARP messages, drop suspicious/malicious. Config rate of ARP messages to prevent DOS.

(3) Physical Security: – ARP messages are not routed beyond the boundaries of the local network so would-be attackers must be in physical proximity to vitim network or already have control of a machine on network

(4) Network isolation: – ARP messages don't travel beyond local subnet. therefore, well-segmented network will be less susceptible to ARP cache poisoning

(5) Encryption: – mitigate potential damage, i.e. SSL/TLS encryption on web makes MiTM attacks to capture login credentials a lot harder.

—-Who has 192.168.47.1? Tell 192.168.47.171

ESP: Encapsulating Security Payload (ESP) protocol: – provides data confidentiality, and also optionally provides data origin authentication, data integrity checking, and replay protection.

ESP vs Authentication Header (AH) protocol is that ESP provides encryption, while both protocols provide authentication, integrity checking, and replay protection. With ESP, both communicating systems use a shared key for encrypting and decrypting the data they exchange.


Layer 3

ICMP: Internet Control Message Protocol echo request = ping

  • a protocl that network devices use to send error messages and operational info about whether a requested service or host can be reached
  • not usually used to exchange data
  • devices can block this

traceroute: like ping but with time taken to travel across each hop from source to destination

TTL: Time to Live: Prevents data from being stuck in infinite loop

  • how long a data packet can exist in a network
  • decrementing hop counter – every router that forwards the packet decrements (reduces) the TTL value by one
  • once TTL hits zero, will send a “time exceeded” error
  • different OS have different default TTL so an easy way to figure out what server you are working with if pentesting is to ping and check that: https://ostechnix.com/identify-operating-system-ttl-ping/

tracert-copy.png

  • *** means time out

Layer 4: TCP

TCP: Connection-Oriented Protocol

  • used for: HTTP/S, FTP, SSH, SMTP

The Three-Way-Handshake

(1) **SYN** (Synchronize) – client to server – client sends SYN data packet to the server to determine if it is ready to open a connection (2) **SYN/ACK** (Synchronize/Acknowledge) – server to client – sever acknowledges or confirms receipt of the SYN packet (3) **ACK** (Acknowledge) – client to server – client acknowledges receipt of the SYN/ACK packet

Four-Way Termination

(1) **FIN** (Finish) – client to server – client sends a FIN packet to server to close the connection (2) **ACK** (Acknowledge) – server to client – server acknowledges receipt of FIN packet (3) **FIN** (Finish) – server to client – server terminates connection, sends a FIN (4) **ACK** (Acknowledge) – client to server – client acknowledges the termiantion

UDP: Connectionless

  • reducing latency versus transmitting all data
  • used for ping and traceroute or VoIP

WIRESHARK: Syn Packets

3wayhs-copy.png

tcp.flags.syn ==1 && tcp.flags.ack == 0 to view only SYN

tcp.flags.syn ==1 && tcp.flags.ack == 1 to view only SYN/ACK requests

tcp.flags.syn == 0 && tcp.flags.ack == 1 to view only ACK

tcp.flags.fin == 1 to view FIN flag set to 1

WIRESHARK + PORTS

  • “The important takeaway is that in this SYN scan, the behavior of a closed port is one packet in a conversation.” ???

Wireshark Open Port Behaviour: – how to look for an open port? An open for TCP would be one where the initial synchronization step of the 3 step handshake has been acknowledged so your filter is: tcp.flags.syn == 1 && tcp.flags.ack == 1 – behaviour of open TCP port is as expected: 3 packets in a conversation: synscanrst-copy.png] – TAKEAWAY: OPEN TCP = 3 PACKETS

Wireshark Filtered Port Behaviour: – A filter port indicates that a firewall, filter, or other network issue is blocking the port – can be created by a server or network firewall, router, or security device – servers typically do not respond to filtered ports – TAKEAWAY: FILTERED = 1 PACKET

Wireshark Closed Port Behaviour: – for closed ports, server's firewall will often respond with RST flag to indicate that they are not accepting connections. – configurable in firewall's settings – TAKEAWAY: CLOSED = 2 PACKETS

Wireshark View STATES of all ports:

  • Statistics —> Conversations

Security Implications

  • use firewall to block source IP of suspicious activity

Syn Analysis Activity:

3 ports have 5 packets: 53, 80, and 22 – Following port 53 shows that there was an initial request from 36050 to 53, a response back, and then 3 x TCP Retransmissions from 53 to 36050 meaning that “the TCP sender is not seeing ACKs that cover earlier transmitted packets in a timely manner.” – same with other ports


Week 8.1

  1. A hacker logged into Microsoft Outlook with the stolen username and password of Acme's CFO. The hacker sent an email to the head of accounting asking them to wire $10,000 to a foreign account owned by the hacker.
  • logging in means sending a request for a session
  • sending an email in TCP/IP terms means:

(1) APPLICATION LAYER: write email in email client > message data is sent to a a port for the relevant service, likely 25 for SMTP?

(2) TRANSPORT LAYER: encapsulates the data with TCP or UDP header with destination and source ports —–> segment is sent to...

(3) NETWORK LAYER: encapsulates the segment inside IP packet with source and destination IP —–> packet is sent to...

(4) LINK LAYER: packet reaches physical hardware, encapsulates into frame with source and destination MAC addresses —–> frame is received by the link layer on the other end.

  • the receiver of the email has to make a request to the email server to retrieve the email before they can read it. the retrieved email is the response.
  1. A hacker used Firefox to visit the administrative website of Acme Corp, where they attempted to log into the CFO's account multiple times, until they correctly guessed the password.

visiting the website: (1) DNS look-up so that the URL can be translated into the IP address of the server containing the resources for the site. Checking – browser cache – OS system cache – Router cache – ISP DNS cache (2) browser sends an http request to the server (3) server responds (4) browser renders server's response (5) this can be synchronous or asychronous

  • each time the hacker tries to log into the account, a session request is made to the server from browser
  1. A hacker stole the Acme CFO's mobile phone. Login credentials were saved on the phone, allowing the hacker to log into Acme Corp's mobile admin application.
  2. same idea?

  1. Design the office with the following computer and network devices:

    • (6) Employee computers
    • (2) Switches
    • (1) Router
    • (2) Load balancers
    • (1) Firewall
    • (1) Representation of the internet
    • (1) Server
    • (1) Wireless access point with (1) firewall to protect it
  2. DMZ

  3. add the server and load balancers to the DMZ

  • internet || firewall || router –> everything else?
  • load balancer between server and client
  • DMZ switch between firewall and public-access servers?

  1. Convert the following binary representations into numeric IP addresses:

    1. 11000000101010000100010110010001 > 192.168.69.145 (private)
    2. 00001010000000000000000000101010 > 10.0.0.42 (public?)
    3. 11000000101011000100010110010001 > 192.172.69.145 (private)
    4. 00101001001011011011011000100000 > 41.45.182.32 (public?)
    5. 00001010000000000000000001001100 > 10.0.0.76 (public?)
  2. Compare the numeric IP addresses to the Acme server list and determine which server the IPs belong to.

  3. Summarize your findings to determine what resources the hacker is trying to access.

Your security manager also found the following binary data in the hacker's logs:

  • 100010001111011111000111011001010001101000110110

Determine what this binary data represents.


spoofing a DNS on linux

/etc/hosts is where the DNS translation occurs on Linux The syntax for adding a DNS look up is: [ip] [domain] For example: 137.74.187.102 krebsonsecurity.com – only works on root though

Week 8.2

Translating raw binary into readable format

Log file 1 GET / HTTP/1.1 Host: widgets.com Connection: keep-alive Upgrade-Insecure-Requests: 1 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.117 Safari/537.36 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8 Accept-Encoding: gzip, deflate Accept-Language: en-US,en;q=0.9,nb;q=0.8

Log file 2 File Transfer Protocol (FTP) 230 Login successful.\r\n Response code: User logged in, proceed (230) Response arg: Login successful.

Log file 3 TLSv1.2 Record Layer: Application Data Protocol: http-over-tls Content Type: Application Data (23) Version: TLS 1.2 (0x0303) Length: 56 Encrypted Application Data: d03ff41452da9e9c3ec76cbeb35e8ffc1f64bf80f512924a?

Log file 4 Domain Name System (query) Transaction ID: 0x18b6 Flags: 0x0100 Standard query 0... .... .... .... = Response: Message is a query .000 0... .... .... = Opcode: Standard query (0) .... ..0. .... .... = Truncated: Message is not truncated .... ...1 .... .... = Recursion desired: Do query recursively .... .... .0.. .... = Z: reserved (0) .... .... ...0 .... = Non-authenticated data: Unacceptable Questions: 1 Answer RRs: 0 Authority RRs: 0 Additional RRs: 0 Queries applegate.com: type A, class IN [Response In: 623]

Log file 5

Address Resolution Protocol (request) Hardware type: Ethernet (1) Protocol type: IPv4 (0x0800) Hardware size: 6 Protocol size: 4 Opcode: request (1) Sender MAC address: Technico_65:1a:36 (88:f7:c7:65:1a:36) Sender IP address: 10.0.0.1 Target MAC address: 00:00:00_00:00:00 (00:00:00:00:00:00) Target IP address: 10.0.0.6

Log file 6

HCI H4 [Direction: Unspecified (0xffffffff)] HCI Packet Type: HCI Command (0x01) HCI Command – Read Local Supported Features Command Opcode: Read Local Supported Features (0x1003) Parameter Total Length: 0 [Response in frame: 4] [Command-Response Delta: 4.181ms]`

Determining source and destination ports, protocol, and summarize findings for each request in logfile:

Log file 1 Source: 192.168.1.9:50152 Destination: 192.124.249.168:80 Protocol: TCP 6 Summary: stealing of accessing data?

Log file 2 Source: 10.0.0.42:53367 Destination: 35.186.241.40:443 Protocol: TCP 6

Third one is also TCP. So exciting. I'm enthralled.

OSI Modeling

LINK: https://write.as/effyverse/networking-basics-47md

Review the list of 10 suspicious activities and determine which of the seven OSI layers each falls under:

1) A networking cable was cut in the Data Center and now no traffic can go out. Layer 1: Physical

2) A code injection was submitted from an administrative website, and it's possible that an attacker can now see unauthorized directories from your Linux server. Layer 7 Application for the code inject and layer 3 for the server?

3) The MAC address of one of your network interface cards has been spoofed and is preventing some traffic from reaching its destination. Layer 2: data link

4) Your encrypted web traffic is now using a weak encryption cipher and the web traffic is now vulnerable to decryption. Layer 6: Presentation

5) The destination IP address has been modified and traffic is being routed to an unauthorized location. Layer 3: Network

6) A flood of TCP requests is causing performance issues. Layer 4: Transport

7) A SQL injection attack has been detected by the SOC. This SQL injection may have deleted several database tables. Layer 5: Session

8) A switch suddenly stopped working and local machines aren't receiving any traffic. Layer 2: Datalink

9) An ethernet cable was disconnected and the machine connected isn't able to receive any external traffic. Layer 1: Physical

10) Traffic within the network is now being directed from the switch to a suspicious device. Layer 3: Network

HOW TO APPLY THE OSI TO TROUBLE-SHOOT?

Question: How would one trouble-shooting an unreachable IP given only the information available from ping?

THE GOAL: is to narrow down your problem domain methodically

  • server admin/team –> check ilo connection (console connection) to narrow down network vs server problem, if connected, validates that server is good. if not, check server itself

layer 1-2 – check hardware: beyond server, check switch – enterprise switches are smart – if you know the NIC, you can find the ARP translation to trace the MAC address – once you have the MAC, you check its switch: from the switch perspective, are you seeing the server? if yes, you have validated that physical layer is good – if layer two is good, you should be able to find the mac address

layer 3 – layer 3: is this an IP problem or does it affect all the servers on this subnet? – if you can ping the other IPs, recheck the hardware because every other IP is working so it's a problem with localhost not network aka it is the specific machine pinging from and not necessarily the machine we are pinging to – reverse the ping direction to check – VLAN – opnet/tcp dump – track the packet

#bash #scripting #bashsyntax #UofTBootCamp #homework

Takeaways

  • quotes around the array in a for loop is best practice:

Without them, the for loop will break up the array by substrings separated >by any spaces within the strings instead of by whole string elements within >the array. ie: if you had declare -a arr=("element 1" "element 2" "element 3"), >then for i in ${arr[@]} would mistakenly iterate 6 times since each string >becomes 2 substrings separated by the space in the string, whereas for i in >"${arr[@]}" would iterate 3 times, correctly, as desired, maintaining each >string as a single unit despite having a space in it.

  • you can only capture with echo. Using return is the same as exit (so you can only capture the exit code)

Syntax Quickies

quick init + iteration

read -a arr <<< "one two three" for i in ${arr[@]} do echo $i done

  • access elements

passing multiple arrays as arguments

`takesaryas_arg() { declare -a argAry1=(“${!1}”) echo “${argAry1[@]}”

declare -a argAry2=(“${!2}”) echo “${argAry2[@]}” } trywithlocalarys() { # array variables could have local scope local descTable=( “sli4-iread” “sli4-iwrite” “sli3-iread” “sli3-iwrite” ) local optsTable=( “—msix —iread” “—msix —iwrite” “—msi —iread” “—msi —iwrite” ) takesaryasarg descTable[@] optsTable[@] } trywithlocal_arys`

#UofTBootCamp #classwork #linux #permissions #users #groups #su #sudo #less #more #shellbreaking #shellexploit #exploit #escapeexploit

Running commands from inside of less with sudo access

Run !bash inside of less to drop to a root shell

sudo

sudo and su basics

su substitute user identity sudo execute a command as another user

sudo -l will list (if no command is specific) the allowed/forbidden commands for the invoking user (or a specific user if -U). If a command is specific, it will list the “fully-qualified” path to the command.

sudo -lU <user> to check if has can run sudo OR sudo -nv

Updating the /etc/sudoers/ file withvisudo`

sudo visudo to see the file john ALL=(ALL:ALL) /usr/bin/apt, /usr/bin/less to give john access to run apt as root and less

Syntax for /etc/sudoers/

The first ALL is the users allowed (john) The second one is the hosts (ALL, as in all machines) The third one is the user as you are running the command The last one is the commands allowed

Activity 1

Determine what sudo activities the sysadmin user has using sudo -lU sysadmin:

(ALL : ALL) ALL meaning that sysadmin user can run on all commands as root on all hosts.

Record what access each user on the machine has:

Find all real users:

grep -E '^UID_MIN|^UID_MAX' /etc/login.defs to find the range for the real users on the machine.

getent passwd {1000..6000} to display only those users.

However, this does not tell us what commands each user has effectively bc I would now have to manually search each one then save that into a file.

Display all users:

awk -F':' '{ print $1}' /etc/passwd OR compgen

Display all sudo users:

getent group sudo | cut -d: -f4

grep '^sudo:.*$' /etc/group | cut -d: -f4

Find the user who has sudo access to the less command

cat /etc/sudoers | grep less

Switch to Root

sudo su root

Check for users or groups

grep <user or group name> /etc/passwd or group

Users and Groups

UID over 1000 = standard user

groups or groups <user> prints your user's groups to the screen

id prints the groups + GIDs

sudo usermod -L <user> to lock the account

sudo usermod -G <group-to-remove> <user> to remove from a

sudo deluser --remove-home <user> to remove

--remove-home flag removes the home folder, too

`sudo usermod -aG to add to the

Activity 2

1. Use a command to display your ID info.

2. Use the same command to display the ID info for each user on the system.

– In case you forgot, how can you learn what these usernames are? – Record the output from this series of commands to a new file in your research folder.

3. Print the groups that you and the other users belong to.

– Record the output from this series of commands to a new file in your research folder.

– Hint: Are there any users that shouldn't be there?

5. Make sure you have a copy of the home folder for any rogue users and then remove any users from the system that should not be there. Make sure to remove their home folders as well.

Hint: Remember from the first activity, the only standard users that should be on the system are: admin, adam, billy, sally and max.

  1. Verify that all non-admin users are part of the group developers.
    • If the developers group doesn't exist, create it and add the users.

#UofTBootCamp #classwork #linux #processes #ps #grep #awk

Given a VM with a shady user running a shady script...

###...list all processes running in real time

top for finding running processes in real time

lsof -u jack for finding jack's processes lsof | grep jack for highlighting ps aux | grep jack

How many tasks have been started on the host?

ps aux | wc -l ps aux | grep jack | wc -l ^ not great because grep has not filtered out occurrences of jack elsewhere

ps -eo user | grep jack | wc -l -o allows you to specify format -e selects all processes, including those of other users

ps -U jack -u jack u every process running as jack (real and effective ID) in user format?

How many are these are sleeping?

ps -U jack -u jack u | awk '{if ($8=="S" || $8=="D") print $0' | wc -l (1 process is sleeping)

ps -eo user,state | awk '{if ($2=="S" || $2=="D") print $1,$2}' | wc -l

Which process uses the most memory?

ps -eo user,pid,cmd,%cpu,%mem --sort=-%mem | head -20

Search all running processes by a specific user

ps -eo user,pid,cmd,state | grep root | awk '{if ($4=="R") print $1,$2,$3, $4}'

ps -U root -u root u | awk '{if ($8 == "R") print $0}'

BONUS:

List all processes with a TTY terminal

ps -t ps -eo pid,tty,cmd | grep pts

Identify the ID of suspicious processes:

ps -eo pid,user,tty,cmd | awk '/str.sh/{print $0}' – returns the matches including the awk command process

ps -eo pid,user,tty,cmd | awk '/[s]tr.sh/{print $0}' – adding the [] around the first character will avoid matching the awk command itself

ps -t | grep "[s]tr.sh" | awk '{print $0}'

WHY DOESN'T A WILDCARD WORK HERE?????

ps -t | grep “*.sh” |


About Me

#whoami #cv #extendedcv #favouritebooks #philosophy #email #me #at #yffenim@protonmail.com #guaranteed #slow #reply


CTF Learning Journey

#bandit #overthewire #hackthebox #leviathan


Infosec Concept Notes and Cheatsheets

#threatmodeling


UofT Cybersecurity Bootcamp

#UofTBootcamp #classwork #homework #classwork


Homelab Experimentations

#brainstorm #config_1


Searchable Tags by Topic

#ssh #nmap #nc #git #grep #awk #ps


Other Careers

#activism #poetry #prose #fiction #literature #movementtherapy #personaltraining