keiser
    • 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
    • Engagement control
    • 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 Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control 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
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # Examples and Additional Resources ### Crypto Cryptography is the form of communicating with someone in the presence of a third party and making sure that no one other than the reciever can understand the message sent. You can encrypt your data using many ciphers, like Caesar cipher(which is basically making A=N, B=O ... Z=M ie. Rotation by 13 characters), or any rotation by `x` values called ROT `x` cipher. There are more advanced ciphers like [Vigenre Cipher](https://pages.mtu.edu/~shene/NSF-4/Tutorial/VIG/Vig-Base.html) etc. But the major issue with these ciphers are that they can mostly be decrypted using entropy analysis. There are many tools online which could help you decode them too. So using Key based encryption is a better alternative compared to these. A method used to encrypt data is by using One Time Pad. This is cryptographically the strongest way to encrypt a message. But it comes with its own set of issues. 1. You cannot reuse the pad 2. Transfer of pad to the reciever to decrypt the message is an issue. Suppose you have a message. What you do is XOR the message, with a key of the same length, called a pad and the result is your encrypted message. In other words, for encrypted message c, `c = m ⊕ pad`, where m is the message to be sent. Now, if you XOR both sides with the pad, you get `c ⊕ pad = (m ⊕ pad) ⊕ pad`. Now, because of associativity and the properties that `A ⊕ A = 0` and `m ⊕ 0 = m`, we get `c ⊕ pad = m` This is the way to decrypt the ciphertext – just xor the cipher This is amazing when you want to encrypt a single message with a hidden pad. Reason? Because if I just gave you the encrypted message 010, you wouldn’t be able to say anything about the system. The maximum you could see is that the length of the pad is 3 – but each of the 23 possibilities you get for the pad are equally likely and give a unique result when you XOR with the encrypted message. That means you can’t guess anything more about the original message than this, because of the results you get are all equally likely to occur. But this doesn’t work so well when you try using a pad with more than one message. If you encrypted 2 messages m1 and m2 with the same pad k, then you would get `c1 = m1 ⊕ k and c2 = m2 ⊕ k` as the result. What we can do now is XOR these two results to get this- `c1 ⊕ c2 = (m1 ⊕ k) ⊕ (m2 ⊕ k)` Applying associativity and commutativity of XOR gives us `(m1 ⊕ m2) ⊕ (k ⊕ k) = (m1 ⊕ m2) ⊕ 0 = m1 ⊕ m2` So the XOR of the encrypted messages is the XOR of the original messages. And so we now have the XOR of the original messages. How does that help us? Check out an example explained neatly here - https://crypto.stackexchange.com/questions/33673/many-time-pad-attack-xor This attack is called as Many Time Pad attack. There are more sophisticated algorithms for encrypting messages like RSA, AES etc. which you will be introduced to you in various CTF challenges. Googling on vulnerabilities in a given crypto system and frequently getting updated with recently released papers would help you in a long way in solving Crypto challenges. With inputs from Hemanth Chitti ### Forensics There are a few basic commands, tools, concepts you need to get comfortable with to begin with forensic challenges. - [file](https://linux.die.net/man/1/file) (Command) - Helps in determining the file type by looking at the magic numbers/file signature of a given file. - [ghex](https://wiki.gnome.org/Apps/Ghex) (Tool) - In order to manipulate the hex of a given file you might need this. You could very well use [HexEdit-Online](https://hexed.it/). - [File Signatures](https://www.garykessler.net/library/file_sigs.html) (Concept) - These are bytes within a file which are used to identify the format of the file. - [strings](https://linux.die.net/man/1/strings) (Command) - Displays all the printable characters in a file which are atleast 4 characters long. BTW have you ever tried opening an image file(PNG/JPEG) in a text editor. If not do give it a try. Next, try running strings on that file. - [foremost](https://tools.kali.org/forensics/foremost) (Tool): A super popular tool used in forensic industry, for file carving. It is generally used to carve out [polyglot files](https://medium.com/swlh/polyglot-files-a-hackers-best-friend-850bf812dd8a#:~:text=Polyglots%2C%20in%20a%20security%20context,GIF%20and%20a%20RAR%20file.&text=Polyglot%20files%20are%20often%20used%20to%20bypass%20protection%20based%20on%20file%20types.), on the basis of file headers and signatures in the hex of a polyglot file. [This](https://trailofbits.github.io/ctf/forensics/) is an amazing link summarizing on common forensic techniques and probably might be of some help to you. ### Reversing We all love `C`, don't we? :laughing: So let's figure out we could exploit this piece of code ```C #include <stdio.h> #include <string.h> int main(){ char s[100]; int flag = 5; scanf("%s",s); if(strcmp(s, "4_cr4zy_p455w0rd") == 0) printf("Success!! Flag is ZenseCTF{%d}",flag); else printf("Nope! Try again"); return 0; } ``` Here's what we do on command line to generate an executable named `haxx` ``` └──╼ $gcc haxx.c -o haxx └──╼ $./haxx lol Nope! Try again ``` This is what we do traditionally. Let's figure out the password variable. After generating the executable `haxx`, we would then use a command called `ltrace`. Read about _ltrace_ over [here](https://linux.die.net/man/1/ltrace). Then enter any random string and you are then greeted with this output. ``` prohacker@ubuntu:~/$ ltrace ./haxx __isoc99_scanf(0x55bbfe9de008, 0x7ffe04584ef0, 0x7ffe04585058, 0x7f3dd5161718lol ) = 0 strcmp("", "4_cr4zy_p455w0rd") = -52 printf("Nope! Try again") = 15 Nope! Try again+++ exited (status 0) +++ ``` Basically it _traces_ through execution. And what it shows is the comparison between our input and password, revealing the password to someone. Another simple method to find out the string `4_cr4zy_p455w0rd` is to run the command `strings` over the executable `haxx`. This method is not specific to a `C` executable, `strings` is basically used to check for all the readable strings in a given file by removing all the unreadable characters. `strings haxx` You will be shown various function names and libraries used, with these strings in between. ``` Enter your flag %s 4_cr4zy_p433w0rd Success!! Flag is ZenseCTF{%d} Nope! Try again ``` So that is not a safe way to do a password checking. To avoid this, it is better to hash the passwords and then you could use it for comparision. With Inputs from Kartik Sama ### Steganography We all know that all the stuff that we store digitally is nothing but just a set of 0's and 1's. Most of the readers might be familiar of the concept of Least Significant Bit(LSB) and Most Significant Bit(MSB). Well using this can we hide anything? Yes, we can very well hide stuff. Imagine, we have an image. How could we think of hiding some data in this image? Using the LSB's we can obviously hide the data. We know that an image is made up of pixels arranged in the form of a matrix. And each pixel consists of a tuple of 3 channels: Red[R], Green[G] and Blue[B], and each channel has values between 0 to 255, where (0,0,0) means black and (255, 255, 255) means white. Varying the values of R,G,B we can get many combinations. Imagine there is a pixel which is black ie. (255,255,255). Now lets try hiding a simple 3-bit message string `100` in this pixel. Let this be `a` 255 when converted to binary is `1111111`. Let this be `b` Now the LSB in our example is the rightmost bit. We now replace the LSB of this Red binary string with the first bit in the message binary ie. 1 and hence our new binary value for the Red channel still remains `1111111`. Doing the same for Blue and Green channels would give us `1111110` and `1111110` respectively. Hence our updated pixel value is (255,254,254) https://www.color-hex.com/color/fffefe Check this link out to see how (255,254,254) looks. Does it vary much from (255,255,255). No right? You might wonder, why are we doing it on LSB and not on any other bits. The answer is simple, the change in the pixel color will be vast. For suppose let's consider the previous example and try hiding the characters in the MSB of the pixel stream. We have 1111111, 0111111, 0111111 then our pixel tuple becomes (255,31,31) which almost looks like a shade of red. See the drastic amount of change we had? Here is a comparision of the output of the data that we hid using LSB method and MSB method respectively in the pixel ![](https://i.imgur.com/rpznxDh.jpg) So, why is the drastic change undesirable? Imagine if there is a drastic change on the remaining pixels in the image, it would tamper the image and it will obviously give out the idea that the image has some hidden data in it. We spare you the burden of reading through more code. But this is the entire concept behind hiding data in an image. This is a very well researched field called as Steganography. And the method we have discussed over here is called as LSB Steganography. Read up on it, if you are interested. There are many tools available to crack and assist in decoding these types of stego systems like [zsteg](https://github.com/zed-0xff/zsteg), [stylesuxx web tool](https://stylesuxx.github.io/steganography/) and [Forensically](https://29a.ch/photo-forensics/#error-level-analysis) Forensics also has many other types of challenges like Packet Capture analysis, Memory Forensics etc. ### Web Local File Inclusion(LFI): Here are some links to get you familiar with LFI type vulnerabilities - [A tutorial](https://www.youtube.com/watch?v=O7-qHZFxjgk&t=170) on how to exploit LFI vulnerabilities - [A detailed explanation](https://www.acunetix.com/blog/articles/local-file-inclusion-lfi/) on what is an LFI attack. - [Testing methods](https://owasp.org/www-project-web-security-testing-guide/latest/4-Web_Application_Security_Testing/07-Input_Validation_Testing/11.1-Testing_for_Local_File_Inclusion) for LFI With Inputs from Ruturaj Mohite #### Sockets and Stuff We have some socket based challenges that talk over TCP(nothing new), and you could connect to them as a client using netcat. I thought it would be better if I inform about this, so that you all might be prepared about it beforehand. Here are some good documentations/tutorials in helping you understand about them. http://netcat.sourceforge.net/ https://ubidots.com/blog/how-to-simulate-a-tcpudp-client-using-netcat/#:~:text=Netcat%20is%20a%20featured%20networking,to%20a%20server%20and%20back. https://null-byte.wonderhowto.com/how-to/hack-like-pro-use-netcat-swiss-army-knife-hacking-tools-0148657/ https://realpython.com/python-sockets/ https://docs.python.org/3/library/socket.html Incase you find socket module in python frustrating to use, you could alternatively use pwntools library. Here is the documentation on how to connect to sockets using pwntools https://docs.pwntools.com/en/stable/tubes/sockets.html

    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