Day 3 of 1060 minShell WalkerHands-on lab

Day 3: Spotting AI-Generated Images

Taught by Mr Elite Updated

By the end of today you can

  • Check an image for visual tells and rate how strong each one is
  • Run error level analysis and a noise residual check with a short Python script
  • Treat detector scores as leads and explain why they give false positives
  • Reveal near-invisible hidden text and trailing data in an image

Warm-up

Answer from memory first, then tap to check. Recalling yesterday is what makes it stick.

Why is a clean EXIF block not proof that a photo is genuine?

Metadata is a set of claims inside the file and is trivial to forge, copy or strip, so presence and absence are both inconclusive.

Which command shows the real file type regardless of the extension?

file, or xxd to read the header bytes directly.

Someone sends you a photo of a 'burned out warehouse' that is spreading on social media. The EXIF is empty, the hands look slightly odd, and an online detector says 87 percent AI. Your manager wants a yes or no by lunch.

Today I teach you to stop asking for a yes or no from one signal. You will collect several small signals, rate how much each one is worth, and write down a confidence level you can defend. We also look at a second question that matters just as much: what is hiding inside the image.

One signal never decides

On Day 2 you learned that metadata is a claim, not a fact. Image analysis works the same way. Every technique today produces a signal, and every signal can be wrong. Your job is to collect several, rate each one, and see whether they agree.

I use four ratings. Strong means hard to fake or explain away. Moderate means suggestive and needs support. Weak means it happens in genuine images all the time. None means you looked and found nothing, which is not the same as proving the image is real.

Artefact
A flaw or trace left behind by how an image was made or processed.
False positive
A tool says 'fake' about a genuine image.
False negative
A tool says 'genuine' about a fake image.

Visual tells: look before you run anything

Open the image at full size and zoom in. Do this on your working copy, never the original. Generators are better than they were, but they still slip in four places.

Quick check

A sign in the background has slightly garbled letters, but everything else looks consistent. How should you rate this signal on its own?

Watch me do it: ELA and noise residual

Error level analysis (ELA) re-saves a JPEG at a known quality and shows how much each area changed. Regions that were edited or pasted in often respond differently from the rest. A noise residual subtracts a blurred copy to expose the fine grain a camera sensor leaves. Everything here runs on a file on your own machine.

bash
mkdir -p work && cp ~/Pictures/photo.jpg work/photo.jpg
sha256sum ~/Pictures/photo.jpg work/photo.jpg
Work on a copy and confirm both hashes match, the Day 1 routine. Two identical lines means the copy is faithful.
python
import io, os, sys
import numpy as np
from PIL import Image, ImageChops, ImageFilter

path = sys.argv[1]
img = Image.open(path).convert("RGB")

buf = io.BytesIO()
img.save(buf, "JPEG", quality=90)
buf.seek(0)
resaved = Image.open(buf).convert("RGB")
diff = np.asarray(ImageChops.difference(img, resaved)).astype(float)
print("ELA mean", round(diff.mean(), 2), "max", diff.max())
scale = 255.0 / max(diff.max(), 1)
out = Image.fromarray((diff * scale).astype("uint8"))
out.save(path + ".ela.png")

blur = img.filter(ImageFilter.GaussianBlur(2))
res = np.asarray(img).astype(float) - np.asarray(blur).astype(float)
print("Noise std", round(res.std(), 2))
noise = np.clip(np.abs(res) * 8, 0, 255).astype("uint8")
Image.fromarray(noise).save(path + ".noise.png")
Re-saves at quality 90, measures the difference (ELA), then subtracts a blurred copy to show sensor-style noise. Outputs are saved next to the input.

What just happened: the script amplified tiny differences so your eyes can compare regions. A bright edge around a face, or one smooth patch in a grainy photo, is worth a note. But screenshots, heavy filters and repeated re-uploads also create odd ELA, so I rate ELA as weak to moderate. Fully generated images often show unusually smooth, even noise, which is another moderate signal at best.

Quick check

ELA shows a bright outline around a person in a photo that has been shared on messaging apps several times. What is the sensible reading?

Detector tools and their false positives

Online AI-image detectors give you a percentage. It feels scientific, but it is a classifier's guess trained on particular generators. A new model, a screenshot, a resize or a heavy filter can fool it in either direction.

Use a detector like a witness who has not seen the whole scene. Record the tool name, the date, the score, and that you ran it on a copy. Never upload sensitive or confidential evidence to a public web tool. Check your organisation's rules first.

Checking an image for hidden content

Images can carry things you cannot see: text in near-white on white, data appended after the end of the file, or odd strings in metadata. This matters for fraud and, as you will see in the lab, for AI systems that read images.

bash
exiftool -warning -a -G1 work/photo.jpg
strings -n 12 work/photo.jpg | head -n 20
First line lists any parser warnings, including trailing data. Second prints text runs of 12 or more characters.
python
import sys
import numpy as np
from PIL import Image

img = Image.open(sys.argv[1]).convert("L")
a = np.asarray(img).astype(float)
low = 235
stretched = (np.clip(a, low, 255) - low) * (255 / (255 - low))
Image.fromarray(stretched.astype("uint8")).save(sys.argv[1] + ".reveal.png")
print("saved", sys.argv[1] + ".reveal.png")
Converts to greyscale and stretches values between 235 and 255 across the full range, so faint light-on-light text stands out.

Your lab: text a human cannot see

The lab below shows why hidden content matters. Approach it as a defender learning the risk. You will work only inside the SecurityElites lab, never against a real system.

Your turn

AI Visual Prompt Injection

ReceiptLens is a practice app that reads receipt images and writes a summary for a human approver. A vision model reads every pixel, including text a person would never notice. We use it now because it flips today's question: instead of hunting for hidden content in a suspect image, you see how hidden content can steer an automated reader.

Open the lab in a new tab

What to try

What to notice

  • Whether the summary reflects text you cannot see when viewing the image normally
  • How little contrast difference the model needs to read text
  • Which of today's checks (reveal stretch, strings, metadata) would have caught your hidden line

If it did not work

Treating a detector score as a verdict

Record it as one moderate signal with tool, date and version, then look for agreeing or conflicting evidence.

Running ELA on a screenshot or heavily shared image and reading the result literally

Note the image's history first. If it has been recompressed many times, rate ELA as weak.

Analysing the original file

Hash it, copy it, and work only on the copy, as you did on Day 1 and Day 2.

Writing 'no signals found, so it is real'

Write 'no signals found, confidence in authenticity limited'. Absence of artefacts proves little.

Recap

  • Every image signal is a lead, rated strong, moderate, weak or none
  • Visual tells are useful but modern generators are improving on hands and text
  • ELA and noise residuals highlight inconsistencies, but compression creates false alarms
  • Detector scores are classifier guesses, so record them and never rely on them alone
  • Check images for hidden text and trailing data, because machine readers see what people miss
  • Confidence statements should be stated and justified, not implied

Cheat sheet

python3 ela.py img.jpg
Writes ELA and noise residual PNGs and prints summary numbers
python3 reveal.py img.png
Stretches near-white values to expose faint hidden text
exiftool -warning -a -G1 file
Shows parser warnings such as trailing data
strings -n 12 file
Prints readable text runs of 12 or more characters
Rating scale
Strong, moderate, weak, none
False positive / negative
Genuine flagged as fake / fake passed as genuine

Before the next day

Mission: Five-image signal table

Examine five images, some genuine and some generated, and record the signals and a confidence rating for each. This is the core of Day 4, so keep your notes tidy. Use only images you own, generated with a free tool yourself, or that are clearly licensed for use.

About 35 min

You are done when: A markdown file with one table row per image: hash, signals found with ratings, overall confidence, and the final answer-key result.

Want more? Take one genuine photo, resize and re-save it three times, and note how ELA and detector scores change.

Quiz

4 questions. Your score is saved with your progress.

1. Three weak signals point towards generation and one strong signal points towards genuine. What is the best conclusion?

2. Why can ELA flag a genuine image?

3. A detector gives an image 12 percent AI. What does this tell you?

4. Why does hidden near-white text in a receipt image matter for defenders?

Finish the day

Mark the day complete to save your progress.

Next: Day 4 is an apply-it day: you will triage a set of suspect images using the Day 1 to 3 methods in one workflow. Today's signal table is the format you will reuse. Coming soon.

Tell someone you are doing this:WhatsAppXLinkedIn

Your notes

Private to this device. Write what you want to remember from today.