Vyacheslav Goreev
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # FSA Lab №2 Performed by Vyacheslav Goreev (SB-1) ### Task №1 Given the codebook with day-keys and rotor settings. For example, for this particular day have the plugboard settings `H/R – A/J – X/E – O/P – R/F`, rotor setting `3 — 2 — 1` and rotor orientations `S — K — A` 1. We have to swap the letters `H` and `A` by connecting them on the plugboard, swap A and J, and the same with the other letter pairs. So now, if we encode the message `HAXXOR`, this would be encoded as `RJEEPF`. 2. We have to arrange rotors in given sequence `3 — 2 — 1` 3. We have to rotate the rotors so that they will have letters `S — K — A` selected in correspondent rotors. 4. Type the letter 5. The encoded letter will appear at lamp board. 6. Append encoded letter to the message string 7. Repeat 4-6 steps until done ### Task №2 If we consider Viola machine with $r=10$ rotors each with 30 characters chosen among $n=50$ rotors; a plugboard with $w<=15$ wires all plugged; and 1 static reflector with 5 options to select 1. The rotors can be ordered in ${n!\over(n-r)!}=37,276,043,023,296,000$ ways 2. The relative position of the rotor and their internal wiring can be set to 30 values; for $30^r=590,490,000,000,000$ combinations. 3. On the reflector $\sum_{v=0}^{w} {30!\over(30-2v)!\cdot2^v\cdot v!}$ $0$ wires has $73096577329197271449600000$ combinations $1$ wires has $365482886645986357248000000$ combinations $2$ wires has $822336494953469303808000000$ combinations $3$ wires has $1096448659937959071744000000$ combinations $4$ wires has $959392577445714187776000000$ combinations $5$ wires has $575635546467428512665600000$ combinations $6$ wires has $239848144361428546944000000$ combinations $7$ wires has $68528041246122441984000000$ combinations $8$ wires has $12849007733647957872000000$ combinations $9$ wires has $1427667525960884208000000$ combinations $10$ wires has $71383376298044210400000$ combinations $11$ wires has $3244698922638373200000$ combinations $12$ wires has $135195788443265550000$ combinations $13$ wires has $5199838017048675000$ combinations $14$ wires has $185708500608881250$ combinations $15$ wires has $6190283353629375$ combinations So in total there is $4,215,120,372,309,660,462,559,535,625$ combinations for $w <= 15$ wires 4. There is 5 reflectors so there is 5 times more variants to make permutation 5. So the total number of combinations is $s={n!\over(n-r)!}\cdot 30^r \cdot {\sum_{v=0}^{w} {30!\over(30-2v)!\cdot2^v\cdot v!} * 5}=$ $463,897,825,992,878,889,462,162,403,678,166,141,015,454,000,000,000,000,000,000$ 6. To make things easier it is $4.638978259928789e+59$ --- If we consider typical Enigma machine with $r=3$ rotors chosen among $n=5$ rotors; a plugboard with $w=10$ wires all plugged; and 1 static reflector 1. The rotors can be ordered in ${n!\over(n-r)!}=60$ ways 2. The relative position of the rotor and their internal wiring can be set to 26 values; for $26^r=17,576$ combinations. 3. On the reflector, each of the $2w$ extremities of the wires can be plugged into any of 26 positions not otherwise occupied, with the two extremities of a given wire equivalent, as well as the wires themselves; for ${26!\over(26-2w)!\cdot2^w\cdot w!}=108,531,557,954,820,000$ 4. So the total number of combinations is $s={n!\over(n-r)!}\cdot26^r\cdot{26!\over(26-2w)!\cdot2^w\cdot w!}=158,962,555,217,826,360,000$ The typical Enigma is $2918283650871111025772059714178425125170$ times easier to break. ### Task №3 1. John the Ripper 2. Hashcat I have selected Hashcat as it probably the most widely used password cracking tool out there ### Task №4 ``` hashcat -m 1800 -a 0 -o cracked.txt hashedpassword.txt rockyou-60.txt --force -d 1,2 ``` The cracked password is `kissme` ### Task №5 In a stream cipher, the plaintext is encrypted one bit at a time. In a block cipher, the plaintext is broken into blocks of a set length and the bits in each block are encrypted together. #### Block cipher ###### Advantages 1. The ease of implementation and less restrictive requirements (e.g. random generation) 2. Integrity protection mechanisms (like the MAC in the GCM mode of operation). This allows the recipient to verify that the message was not tampered with in transit. ###### Disadvantages 1. Block ciphers are slower and less memory efficient than stream ciphers. 2. High memory requirements of the cipher to store the padded plaintext and ciphertext. 3. Transmission errors often cause the rest of the ciphertext to be unrecoverable. #### Stream cipher ###### Advantages 1. Stream ciphers are usually best for cases where the amount of data is either unknown, or continuous - such as network streams 2. Stream ciphers are typically faster than block ones. 3. Takes less memory 4. Stream ciphers are more difficult to implement correctly, and prone to weaknesses based on usage - since the principles are similar to one-time pad, the keystream has very strict requirements. On the other hand, that's usually the tricky part, and can be offloaded to e.g. an external box. ###### Disadvantages 1. Do not provide integrity protection or authentication. ### Task №6 ##### Electronic Code Book (ECB) Mode Electronic Code Book (ECB) is the simplest block cipher mode of operation. In this mode, as shown in the Figure below, each block of plaintext is encrypted separately. The main **disadvantage to this mode is that identical plaintexts encrypted with the same key create identical ciphertexts, which allows an attacker to learn some information about the encrypted message based solely on the ciphertext**. ###### ECB Mode ![](https://static.commonlounge.com/fp/original/szgMXQC86aqQFiad9C4Nl2P2I1520488760_kc) ###### Possible attack A cut-and-paste attack is an assault on the integrity of a security system in which the attacker substitutes a section of ciphertext (encrypted text) with a different section that looks like (but is not the same as) the one removed. The substituted section appears to decrypt normally, along with the authentic sections, but results in plaintext (unencrypted text) that serves a particular purpose for the attacker. Essentially, the attacker cuts one or more sections from the ciphertext and reassembles these sections so that the decrypted data will result in coherent but invalid information. Cut-and-paste is a type of message modification attack: the attacker removes a message from network traffic, alters it, and reinserts it. This is called an active attack, because it involves an attempts to change information; in comparison, a passive attack, such as password sniffing, seeks information but does not itself modify the valid information, although it may be used in conjunction with an active form of attack for various purposes. ##### Cipher Block Chaining (CBC) Mode In the cipher block chaining (CBC) mode of operation, an initialization vector (IV) is XOR-ed with the plaintext prior to encryption. For the first round of encryption, this is a random, public value. For subsequent rounds, it is the ciphertext of the previous round. This is intended to **fix the issue with ECB mode where identical plaintext blocks create identical ciphertext blocks**. ![](https://static.commonlounge.com/fp/original/w1w4rGxE19jbqWwltXWLDFbMg1520488767_kc) ##### Cipher Feedback (CFB) Mode The cipher feedback (CFB) mode differs from the previous two in that the plaintext never passes through the encryption algorithm at all. Instead an initialization vector (IV) is encrypted and the result is exclusive-ored with the plaintext to create the ciphertext of a block. This is the equivalent of encrypting the plaintext with a one-time pad generating from the encryption of the IV. Similar to CBC mode, this IV is a random value for the first block and the previous block's ciphertext. ![](https://static.commonlounge.com/fp/original/HMi9X9AHmkbZBtyLvWY8uwzC41520488774_kc) ##### Counter (CTR) Mode The counter (CTR) mode of operation differs from the all of the others that we have seen so far. Similar to ECB mode, every encryption operation is completely separate, which is **useful for parallelization of encryption** (since each block can be encrypted simultaneously). Counter mode also uses a non-plaintext output to encryption (like the feedback modes), but, instead of an initialization vector, it uses a combination of a nonce and a counter. The nonce is a random number used for all blocks of an encryption operation and the counter is exactly what it sounds like: a value that starts at zero for block zero and increments to one for block one and so on. This combination **guarantees that the same values will not pass through the encryption algorithm in the same encryption session** (where every block will have the same nonce but different counter values) or the same blocks in different sessions (where every block will have the same counter value but difference nonces). Similar to the feedback modes of operation (OFB and CFB), the plaintext is exclusive-ored with the output of the encryption operation to produce the ciphertext. ![](https://static.commonlounge.com/fp/original/VsriQ0yQQGcUnwvYc7TaeIn941520488789_kc) ### Task №7 **Confusion** means that each binary digit (bit) of the ciphertext should depend on several parts of the key, obscuring the connections between the two. *Confusion = Substitution* Caesar Cipher a --> b **Diffusion** means that if we change a single bit of the plaintext, then (statistically) half of the bits in the ciphertext should change, and similarly, if we change one bit of the ciphertext, then approximately one half of the plaintext bits should change. Since a bit can have only two states, when they are all re-evaluated and changed from one seemingly random position to another, half of the bits will have changed state. *Diffusion = Transposition or Permutation* DES abcd --> dacb #### Difference between them | № | CONFUSION | DIFFUSION | ---- | -------- | -------- | | 1. | Confusion is a cryptographic technique which is used to create faint cipher texts. | While diffusion is used to create cryptic plain texts. | | 2. | This technique is possible through substitution algorithm. | While it is possible through transportation algorithm. | | 3. | In confusion, if one bit within the secret’s modified, most or all bits within the cipher text also will be modified. | While in diffusion, if one image within the plain text is modified, many or all image within the cipher text also will be modified | | 4. | In confusion, vagueness is increased in resultant. | While in diffusion, redundancy is increased in resultant. | | 5. | Both stream cipher and block cipher uses confusion. | Only block cipher uses diffusion. | | 6. | The relation between the cipher text and the key is masked by confusion. | While The relation between the cipher text and the plain text is masked by diffusion. |

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully