This repository has been archived by the owner on Jan 28, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ffc3ccf
commit de6730d
Showing
7 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,6 @@ | |
|
||
# Dependency directories (remove the comment below to include it) | ||
# vendor/ | ||
|
||
# Generated image | ||
nhb.out.png |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# HackDalton: Secret Agent | ||
|
||
## Problem: | ||
|
||
Agent, the fate of the world rests on you. Terrorists have taken control of a nuclear arsenal and now have control of a stockpile of nuclear weapons. They have locked themselves in the arsenal with a password, and when entered wrong or broken into, the nuclear missiles will automatically be launched and strike capital cities around the world. The terrorists are communicating the password between each other using [this](./nhb.out.png) image. The world is doomed unless you can crack the code, special agent. | ||
|
||
## Hints | ||
1. Look into least-significant-bit encoding. | ||
2. Check out [this](https://github.com/auyer/steganography) library. | ||
|
||
Look at the writeup [here](./WRITEUP.md). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# HackDalton: Secret Agent (Writeup) | ||
|
||
> Warning! There are spoilers ahead | ||
The image is encoded with least significant bit encoding (LSB), a form of [steganography](https://en.wikipedia.org/wiki/Steganography) | ||
|
||
From the wikipedia page for steganography: | ||
> For example, a 24-bit bitmap uses 8 bits to represent each of the three color values (red, green, and blue) of each pixel. The blue alone has 28 different levels of blue intensity. The difference between 11111111 and 11111110 in the value for blue intensity is likely to be undetectable by the human eye. Therefore, the least significant bit can be used more or less undetectably for something else other than color information. If that is repeated for the green and the red elements of each pixel as well, it is possible to encode one letter of ASCII text for every three pixels. | ||
A script to encode and decode images can be found at [main.go](./main.go). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module github.com/HackDalton/secret-agent | ||
|
||
go 1.13 | ||
|
||
require github.com/auyer/steganography v1.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
github.com/auyer/steganography v1.0.0 h1:0jty6tzmLff01Oe1Nz197XcutYV+LhgUhySCbfNQUrI= | ||
github.com/auyer/steganography v1.0.0/go.mod h1:Q2qN+f1ixaXnKTCT4xkSDCZ/5NiOpUeTgOCLwQdJD+A= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package main | ||
|
||
import ( | ||
"bufio" | ||
"bytes" | ||
"fmt" | ||
"image/png" | ||
"os" | ||
|
||
"github.com/auyer/steganography" | ||
) | ||
|
||
func check(err error) { | ||
if err != nil { | ||
panic(err) | ||
} | ||
} | ||
|
||
func main() { | ||
inFile, err := os.Open("nhb.in.png") // opening file | ||
check(err) | ||
reader := bufio.NewReader(inFile) // buffer reader | ||
img, err := png.Decode(reader) // decoding to golang's image.Image | ||
check(err) | ||
|
||
w := new(bytes.Buffer) // buffer that will recieve the results | ||
err = steganography.Encode(w, img, []byte("hackDalton{w3lc0m3_t0_l4ngl3y_kgLQq-1mHU}")) // Encode the message into the image | ||
check(err) | ||
outFile, err := os.Create("nhb.out.png") // create file | ||
check(err) | ||
_, err = w.WriteTo(outFile) // write buffer to it | ||
check(err) | ||
err = outFile.Close() | ||
check(err) | ||
|
||
fmt.Println(decodeFile("nhb.out.png")) | ||
} | ||
|
||
func decodeFile(file string) string { | ||
inFile, err := os.Open(file) // opening file | ||
check(err) | ||
defer inFile.Close() | ||
|
||
reader := bufio.NewReader(inFile) // buffer reader | ||
img, err := png.Decode(reader) // decoding to golang's image.Image | ||
check(err) | ||
|
||
sizeOfMessage := steganography.GetMessageSizeFromImage(img) // retrieving message size to decode in the next line | ||
|
||
msg := steganography.Decode(sizeOfMessage, img) // decoding the message from the file | ||
return string(msg) | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.