Quantum Gates and Circuits
Thilan Dissanayaka Quantum Computing June 05, 2020

Quantum Gates and Circuits

In article 1, we learned what qubits are. In article 2, we learned the math — vectors, matrices, tensor products. Now we build things.

A quantum algorithm is expressed as a quantum circuit — a sequence of gates applied to qubits, read left to right, ending with measurements. If you’ve seen classical logic circuits (AND, OR, NOT gates wired together), quantum circuits follow the same visual language — but the gates do very different things.

By the end of this article, you’ll be able to read any quantum circuit diagram, understand what each gate does, and build a complete quantum teleportation protocol from scratch.

Reading Quantum Circuits

A quantum circuit has three elements: qubit wires, gates, and measurements.

q0: ──[H]──●──────[M]
            │
q1: ────────⊕──[H]─[M]
  • Horizontal lines are qubit wires — time flows left to right
  • Boxes are single-qubit gates ($H$, $X$, $Z$, etc.)
  • Vertical lines with symbols are multi-qubit gates ($\bullet$ = control, $\oplus$ = target for CNOT)
  • [M] is measurement

This circuit: apply $H$ to q0, then CNOT (q0 controls q1), then $H$ to q1, then measure both.

Key rules:

  • Gates on the same vertical position happen simultaneously
  • Gates from left to right happen sequentially
  • Each wire starts in $|0\rangle$ unless stated otherwise
  • Measurement is always last (in standard circuits)

The Single-Qubit Gate Catalog

We introduced these matrices in article 2. Now let’s see them as circuit elements — what they do, when you use them, and how they combine.

Identity (I)

\[I = \begin{pmatrix} 1 & 0 \\ 0 & 1 \end{pmatrix}\]
q: ──[I]── = q: ──────

Does nothing. Used in math (tensor products) when you want to “do nothing to this qubit” while operating on another.

Pauli-X (NOT / Bit Flip)

\[X = \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix}\]
q: ──[X]──
\[X|0\rangle = |1\rangle, \quad X|1\rangle = |0\rangle\]

The quantum NOT gate. Flips $|0\rangle \leftrightarrow |1\rangle$. On the Bloch sphere, it’s a 180-degree rotation around the X-axis.

When you use it: Initialize qubits to $|1\rangle$ (start with $|0\rangle$, apply $X$). Also used inside controlled gates.

Pauli-Y

\[Y = \begin{pmatrix} 0 & -i \\ i & 0 \end{pmatrix}\]
q: ──[Y]──
\[Y|0\rangle = i|1\rangle, \quad Y|1\rangle = -i|0\rangle\]

Combines a bit flip and a phase flip. 180-degree rotation around the Y-axis. Less common in basic algorithms but essential for completeness.

Pauli-Z (Phase Flip)

\[Z = \begin{pmatrix} 1 & 0 \\ 0 & -1 \end{pmatrix}\]
q: ──[Z]──
\[Z|0\rangle = |0\rangle, \quad Z|1\rangle = -|1\rangle\]

Leaves $|0\rangle$ alone, flips the sign (phase) of $|1\rangle$. Doesn’t change measurement probabilities — but the phase matters for interference.

When you use it: Phase kickback in algorithms, error correction, after Hadamard to create $|-\rangle$.

Hadamard (H)

\[H = \frac{1}{\sqrt{2}}\begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix}\]
q: ──[H]──
\[H|0\rangle = |+\rangle = \frac{|0\rangle + |1\rangle}{\sqrt{2}}, \quad H|1\rangle = |-\rangle = \frac{|0\rangle - |1\rangle}{\sqrt{2}}\]

The most important single-qubit gate. Creates superposition from basis states and undoes superposition back to basis states ($H^2 = I$).

When you use it: At the start of almost every quantum algorithm (create superposition), and at the end (convert phases into measurable probabilities). It’s the bridge between the computational basis ($|0\rangle$, $|1\rangle$) and the superposition basis ($|+\rangle$, $|-\rangle$).

S Gate (Phase Gate / $\sqrt{Z}$)

\[S = \begin{pmatrix} 1 & 0 \\ 0 & i \end{pmatrix}\]
q: ──[S]──
\[S|0\rangle = |0\rangle, \quad S|1\rangle = i|1\rangle\]

Adds a 90-degree phase to $|1\rangle$. Note that $S^2 = Z$ — applying $S$ twice gives a $Z$ gate.

T Gate ($\pi/8$ Gate / $\sqrt{S}$)

\[T = \begin{pmatrix} 1 & 0 \\ 0 & e^{i\pi/4} \end{pmatrix}\]
q: ──[T]──
\[T|0\rangle = |0\rangle, \quad T|1\rangle = e^{i\pi/4}|1\rangle\]

Adds a 45-degree phase. $T^2 = S$, $T^4 = Z$. The $T$ gate is crucial because ${H, T, \text{CNOT}}$ forms a universal gate set — more on this later.

Rotation Gates

For arbitrary rotations around each axis:

\[R_x(\theta) = \begin{pmatrix} \cos\frac{\theta}{2} & -i\sin\frac{\theta}{2} \\ -i\sin\frac{\theta}{2} & \cos\frac{\theta}{2} \end{pmatrix}\] \[R_y(\theta) = \begin{pmatrix} \cos\frac{\theta}{2} & -\sin\frac{\theta}{2} \\ \sin\frac{\theta}{2} & \cos\frac{\theta}{2} \end{pmatrix}\] \[R_z(\theta) = \begin{pmatrix} e^{-i\theta/2} & 0 \\ 0 & e^{i\theta/2} \end{pmatrix}\]

These parametric gates let you rotate a qubit by any angle on the Bloch sphere. All the named gates are special cases:

Gate Equivalent Rotation
$X$ $R_x(\pi)$ (up to global phase)
$Y$ $R_y(\pi)$
$Z$ $R_z(\pi)$
$S$ $R_z(\pi/2)$
$T$ $R_z(\pi/4)$
$H$ $R_y(\pi/2) \cdot R_z(\pi)$ (up to global phase)

Summary — Single Qubit Gates

Identity:   |ψ⟩ → |ψ⟩           (do nothing)
Pauli-X:    |0⟩ ↔ |1⟩           (bit flip)
Pauli-Z:    |1⟩ → -|1⟩          (phase flip)
Hadamard:   |0⟩ → |+⟩, |1⟩ → |-⟩  (superposition)
S:          |1⟩ → i|1⟩          (90° phase)
T:          |1⟩ → e^(iπ/4)|1⟩   (45° phase)

Multi-Qubit Gates

Single-qubit gates can’t create entanglement — you need gates that act on multiple qubits.

CNOT (Controlled-NOT / CX)

q0: ──●──    (control)
      │
q1: ──⊕──    (target)
\[\text{CNOT} = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \end{pmatrix}\]

If the control qubit is $|1\rangle$, flip the target. Otherwise, do nothing.

Input Output
$|00\rangle$ $|00\rangle$
$|01\rangle$ $|01\rangle$
$|10\rangle$ $|11\rangle$
$|11\rangle$ $|10\rangle$

The CNOT is the workhorse of quantum computing. It creates entanglement, implements classical logic (it’s a reversible XOR), and appears in virtually every quantum circuit.

Key insight: CNOT + H is all you need for entanglement. This was the Bell state recipe from article 2.

CZ (Controlled-Z)

q0: ──●──    (control)
      │
q1: ──●──    (target — drawn as ● because CZ is symmetric)
\[\text{CZ} = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & -1 \end{pmatrix}\]

Applies a phase of $-1$ to $|11\rangle$, leaves everything else unchanged. CZ is symmetric — it doesn’t matter which qubit is “control” and which is “target.”

Relationship to CNOT:

\[\text{CZ} = (I \otimes H) \cdot \text{CNOT} \cdot (I \otimes H)\]

A CNOT sandwiched between Hadamards on the target is a CZ.

SWAP

q0: ──×──
      │
q1: ──×──
\[\text{SWAP} = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \end{pmatrix}\]

Swaps the states of two qubits: $|01\rangle \leftrightarrow |10\rangle$.

SWAP can be decomposed into three CNOTs:

q0: ──●──⊕──●──
      │  │  │
q1: ──⊕──●──⊕──

This is important because many quantum hardware architectures don’t have a native SWAP gate — they implement it with CNOTs.

Toffoli (CCNOT / CCX)

q0: ──●──    (control 1)
      │
q1: ──●──    (control 2)
      │
q2: ──⊕──    (target)

The Toffoli gate flips the target if and only if both controls are $|1\rangle$. It’s an 8×8 matrix that acts on 3 qubits.

\[\text{CCNOT}|110\rangle = |111\rangle, \quad \text{CCNOT}|111\rangle = |110\rangle\]

All other basis states are unchanged.

Why it matters: The Toffoli gate is a universal classical gate — any classical boolean function can be built from Toffoli gates alone. Since it’s also a valid quantum gate (it’s unitary), this means quantum computers can do everything classical computers can — and more.

Fredkin (CSWAP)

q0: ──●──    (control)
      │
q1: ──×──    (target 1)
      │
q2: ──×──    (target 2)

Swaps targets if the control is $|1\rangle$. Less commonly used but appears in some algorithms.

Controlled Gates — The General Pattern

Any single-qubit gate $U$ can be made into a controlled version:

q0: ──●──       (control)
      │
q1: ──[U]──     (target)

If the control is $|0\rangle$, do nothing. If the control is $|1\rangle$, apply $U$ to the target.

The matrix is:

\[\text{C-}U = \begin{pmatrix} I & 0 \\ 0 & U \end{pmatrix} = |0\rangle\langle 0| \otimes I + |1\rangle\langle 1| \otimes U\]

This pattern generalizes to:

  • Controlled-Z (CZ): control + Z on target
  • Controlled-S (CS): control + S on target
  • Controlled-H (CH): control + H on target
  • Controlled-Ry(θ): control + rotation on target

Multi-controlled gates (two or more controls) work the same way — apply $U$ to the target only when all controls are $|1\rangle$.

Building Useful Circuits

Let’s build some circuits from these gates and trace through them.

Circuit 1: GHZ State (3-Qubit Entanglement)

The GHZ (Greenberger-Horne-Zeilinger) state extends the Bell state to 3 qubits:

\[|\text{GHZ}\rangle = \frac{1}{\sqrt{2}}(|000\rangle + |111\rangle)\]

All three qubits are perfectly correlated — measure any one as 0, and all are 0. Measure any one as 1, and all are 1.

q0: ──[H]──●──────
            │
q1: ────────⊕──●──
               │
q2: ───────────⊕──

Step 1: $H$ on q0

\[|\psi_1\rangle = \frac{1}{\sqrt{2}}(|0\rangle + |1\rangle) \otimes |0\rangle \otimes |0\rangle = \frac{1}{\sqrt{2}}(|000\rangle + |100\rangle)\]

Step 2: CNOT (q0 → q1)

\[|\psi_2\rangle = \frac{1}{\sqrt{2}}(|000\rangle + |110\rangle)\]

(When q0=1, q1 flips from 0 to 1)

Step 3: CNOT (q1 → q2)

\[|\psi_3\rangle = \frac{1}{\sqrt{2}}(|000\rangle + |111\rangle) = |\text{GHZ}\rangle\]

(When q1=1, q2 flips from 0 to 1)

Three gates. Three entangled qubits. Extend the CNOT chain to $n$ qubits for an $n$-qubit GHZ state.

Circuit 2: Quantum Superdense Coding

Send 2 classical bits using 1 qubit (if you pre-share an entangled pair).

Setup: Alice and Bob share a Bell pair $\frac{1}{\sqrt{2}}(|00\rangle + |11\rangle)$. Alice has qubit 0, Bob has qubit 1.

Encoding: Alice applies a gate to her qubit based on the 2-bit message she wants to send:

Message Alice’s Gate Resulting State
00 $I$ (nothing) $\frac{1}{\sqrt{2}}(|00\rangle + |11\rangle)$
01 $X$ $\frac{1}{\sqrt{2}}(|10\rangle + |01\rangle)$
10 $Z$ $\frac{1}{\sqrt{2}}(|00\rangle - |11\rangle)$
11 $ZX$ (or $iY$) $\frac{1}{\sqrt{2}}(-|10\rangle + |01\rangle)$

All four states are the four Bell states — they’re orthogonal, so Bob can distinguish them perfectly.

Decoding: Alice sends her qubit to Bob. Bob applies CNOT then H and measures:

q0: ──[encode]──────●──[H]──[M]
                    │
q1: ────────────────⊕───────[M]

Bob’s measurement gives him Alice’s 2-bit message. Two classical bits transmitted using one qubit — but only because the entangled pair was shared in advance.

Circuit 3: Quantum Teleportation

This is the crown jewel of basic quantum circuits. Alice has a qubit in an unknown state $|\psi\rangle = \alpha|0\rangle + \beta|1\rangle$ and wants to transmit it to Bob. She can’t clone it (no-cloning theorem). She can’t measure it and send the result (measurement destroys the state). But with a shared Bell pair and 2 classical bits, she can teleport it.

                        Alice                          Bob
                ┌─────────────────────────┐    ┌─────────────────┐
q0 (|ψ⟩):  ────●──[H]──[M]──── c0 ═══════════════════╗
                │                                       ║
q1 (Bell):  ────⊕────────[M]──── c1 ═════════════╗     ║
                                                   ║     ║
q2 (Bell):  ──────────────────────────────[X^c1]──[Z^c0]── |ψ⟩ !
                                                  
Legend: ═══ classical bits, ─── quantum wire

Let me trace through this step by step.

Initial state: q0 is $|\psi\rangle = \alpha|0\rangle + \beta|1\rangle$. q1 and q2 are a Bell pair.

\[|\Psi_0\rangle = (\alpha|0\rangle + \beta|1\rangle) \otimes \frac{1}{\sqrt{2}}(|00\rangle + |11\rangle)\]

Expanding:

\[|\Psi_0\rangle = \frac{1}{\sqrt{2}}[\alpha|0\rangle(|00\rangle + |11\rangle) + \beta|1\rangle(|00\rangle + |11\rangle)]\] \[= \frac{1}{\sqrt{2}}[\alpha|000\rangle + \alpha|011\rangle + \beta|100\rangle + \beta|111\rangle]\]

Step 1: CNOT (q0 → q1)

\[|\Psi_1\rangle = \frac{1}{\sqrt{2}}[\alpha|000\rangle + \alpha|011\rangle + \beta|110\rangle + \beta|101\rangle]\]

Step 2: H on q0

Apply $H$ to the first qubit of each term. Recall $H|0\rangle = \frac{|0\rangle + |1\rangle}{\sqrt{2}}$ and $H|1\rangle = \frac{|0\rangle - |1\rangle}{\sqrt{2}}$:

\[|\Psi_2\rangle = \frac{1}{2}[\alpha(|0\rangle + |1\rangle)|00\rangle + \alpha(|0\rangle + |1\rangle)|11\rangle + \beta(|0\rangle - |1\rangle)|10\rangle + \beta(|0\rangle - |1\rangle)|01\rangle]\]

Now regroup by q0q1 (Alice’s measurement outcome):

\[|\Psi_2\rangle = \frac{1}{2}[|00\rangle(\alpha|0\rangle + \beta|1\rangle) + |01\rangle(\alpha|1\rangle + \beta|0\rangle) + |10\rangle(\alpha|0\rangle - \beta|1\rangle) + |11\rangle(\alpha|1\rangle - \beta|0\rangle)]\]

Look at q2 (Bob’s qubit) for each measurement outcome:

Alice measures Bob’s q2 state Gate Bob applies Result
$|00\rangle$ $\alpha|0\rangle + \beta|1\rangle$ Nothing ($I$) $|\psi\rangle$
$|01\rangle$ $\alpha|1\rangle + \beta|0\rangle$ $X$ (bit flip) $|\psi\rangle$
$|10\rangle$ $\alpha|0\rangle - \beta|1\rangle$ $Z$ (phase flip) $|\psi\rangle$
$|11\rangle$ $\alpha|1\rangle - \beta|0\rangle$ $ZX$ (both) $|\psi\rangle$

Step 3: Alice measures q0 and q1, getting two classical bits. She sends these to Bob.

Step 4: Bob applies corrections based on Alice’s bits:

  • If c1 = 1: apply $X$ to q2
  • If c0 = 1: apply $Z$ to q2

Result: Bob’s qubit is now in state $|\psi\rangle = \alpha|0\rangle + \beta|1\rangle$ — the exact state Alice started with.

The original qubit’s state was teleported from Alice to Bob. Alice’s qubit is now collapsed (she measured it). No cloning occurred. The quantum information moved — it wasn’t copied.

Key points:

  • No faster-than-light communication — Alice still needs to send 2 classical bits to Bob. Without those bits, Bob’s qubit looks completely random.
  • The entangled pair is consumed — after teleportation, the Bell pair is destroyed. You need a fresh pair for each teleportation.
  • The state is transferred, not the qubit — The physical qubit stays with Alice. The quantum information moves to Bob’s qubit.

Universal Gate Sets

A universal gate set is a finite set of gates from which any quantum computation can be constructed (to arbitrary precision).

The most important universal sets:

Gate Set Notes
${H, T, \text{CNOT}}$ Standard universal set. Any unitary can be approximated.
${H, S, T, \text{CNOT}}$ Same as above ($S = T^2$, so $S$ is redundant but convenient)
${R_y(\theta), R_z(\theta), \text{CNOT}}$ Continuous rotations + entangling gate
${\text{Toffoli}, H}$ Toffoli is classically universal; add H for quantum

Why universality matters: It means quantum hardware only needs to implement a small set of physical operations. Any algorithm — Shor’s, Grover’s, quantum simulation — can be decomposed into these basic gates.

The Solovay-Kitaev theorem guarantees that any single-qubit gate can be approximated to precision $\epsilon$ using $O(\log^c(1/\epsilon))$ gates from a universal set. So even though $T$ only rotates by 45 degrees, you can build any rotation angle by combining enough $H$ and $T$ gates.

Clifford Gates vs Non-Clifford

The Clifford group consists of gates generated by ${H, S, \text{CNOT}}$. Clifford circuits can be efficiently simulated on a classical computer (Gottesman-Knill theorem). So Clifford gates alone don’t give quantum advantage.

The $T$ gate is non-Clifford. Adding it to the Clifford set makes the gate set universal and classically intractable. The $T$ gate is what gives quantum computing its power — and it’s also the most expensive gate to implement in error-corrected quantum computing.

Circuit Identities — Useful Equivalences

These identities show up constantly. Knowing them lets you simplify and transform circuits.

$HXH = Z$ and $HZH = X$

Hadamard converts between the X and Z bases:

──[H]──[X]──[H]── = ──[Z]──
──[H]──[Z]──[H]── = ──[X]──

$HH = I$

Hadamard is its own inverse:

──[H]──[H]── = ──────

CNOT direction reversal

Surround with Hadamards to flip the control and target:

q0: ──●──     =     q0: ──[H]──⊕──[H]──
      │                        │
q1: ──⊕──           q1: ──[H]──●──[H]──

$XX = YY = ZZ = I$

All Pauli gates are their own inverse:

──[X]──[X]── = ──────
──[Z]──[Z]── = ──────

Measurement

Measurement is the final operation. It collapses the qubit’s superposition into a definite classical value.

Computational Basis Measurement (Z-basis)

The standard measurement. Projects onto $|0\rangle$ or $|1\rangle$:

q: ──[M]── c   (qubit collapses, result stored in classical bit c)
\[P(0) = |\alpha|^2, \quad P(1) = |\beta|^2\]

After measurement, the qubit is in the measured state — the superposition is destroyed.

Measuring in Other Bases

To measure in the X-basis ($|+\rangle$, $|-\rangle$), apply $H$ before measuring in the Z-basis:

q: ──[H]──[M]──    (X-basis measurement)

To measure in the Y-basis, apply $S^\dagger$ then $H$ before measuring.

This is because $H$ transforms between the Z-basis and X-basis. Measuring $H|\psi\rangle$ in the Z-basis is equivalent to measuring $|\psi\rangle$ in the X-basis.

Partial Measurement

In a multi-qubit system, you can measure just one qubit. This collapses only that qubit and updates the probabilities of the remaining qubits accordingly.

If $|\psi\rangle = \frac{1}{\sqrt{2}}(|00\rangle + |11\rangle)$ and we measure q0:

  • If we get 0 (probability 50%): state collapses to $|00\rangle$. q1 is definitely $|0\rangle$.
  • If we get 1 (probability 50%): state collapses to $|11\rangle$. q1 is definitely $|1\rangle$.

This is entanglement in action — measuring one qubit instantly determines the other.

From Circuits to Algorithms

Every quantum algorithm follows the same pattern:

1. Initialize: |00...0⟩ (all qubits start at |0⟩)
          ↓
2. Create superposition: Apply H gates
          ↓
3. Encode the problem: Apply problem-specific gates (oracles, controlled rotations)
          ↓
4. Amplify correct answers: Use interference (constructive for right answers, destructive for wrong)
          ↓
5. Measure: Read out the result

In Grover’s algorithm:

  • Step 2: $H^{\otimes n}$ creates equal superposition of all $2^n$ inputs
  • Step 3: The “oracle” flips the phase of the correct answer
  • Step 4: The “diffusion operator” amplifies the flipped amplitude
  • Steps 3-4 repeat $\sim\sqrt{N}$ times
  • Step 5: Measurement yields the correct answer with high probability

In Shor’s algorithm:

  • Step 2: $H^{\otimes n}$ on the input register
  • Step 3: Controlled modular exponentiation encodes the period
  • Step 4: Quantum Fourier Transform extracts the period via interference
  • Step 5: Measurement + classical post-processing gives the factors

We’ll implement both in article 5.

Practical — Qiskit Preview

Here’s how the circuits we’ve discussed look in IBM’s Qiskit (Python). Full hands-on coverage comes in article 8, but a preview:

from qiskit import QuantumCircuit

# Bell state
bell = QuantumCircuit(2)
bell.h(0)
bell.cx(0, 1)
bell.measure_all()

print(bell.draw())
     ┌───┐     ┌─┐
q_0: ┤ H ├──■──┤M├───
     └───┘┌─┴─┐└╥┘┌─┐
q_1: ─────┤ X ├─╫─┤M├
          └───┘ ║ └╥┘
c: 2/═══════════╩══╩═
                0  1
# GHZ state
ghz = QuantumCircuit(3)
ghz.h(0)
ghz.cx(0, 1)
ghz.cx(1, 2)
ghz.measure_all()

# Teleportation
teleport = QuantumCircuit(3, 2)
# Create Bell pair (q1, q2)
teleport.h(1)
teleport.cx(1, 2)
# Alice's operations
teleport.cx(0, 1)
teleport.h(0)
# Measure Alice's qubits
teleport.measure(0, 0)
teleport.measure(1, 1)
# Bob's corrections (classically controlled)
teleport.x(2).c_if(1, 1)  # if c1=1, apply X
teleport.z(2).c_if(0, 1)  # if c0=1, apply Z

What’s Next

We now have the complete toolkit for building quantum circuits — single-qubit gates, multi-qubit gates, controlled operations, measurement, and the universal gate set. We’ve built entanglement (Bell states, GHZ), communication protocols (superdense coding, teleportation), and seen the pattern behind every quantum algorithm.

Next up: Entanglement and Teleportation — a deeper dive into the physics and applications of quantum entanglement, including Bell’s theorem, the EPR paradox, and quantum key distribution.

After that, we’ll implement the algorithms that break cryptography.

Thanks for reading!

ALSO READ
Blockchain 0x000 – Understanding the Fundamentals
May 21, 2020 Web3 Development

Imagine a world where strangers can exchange money, share data, or execute agreements without ever needing to trust a central authority. No banks, no intermediaries, no single point of failure yet...

Identity and Access Management (IAM)
May 11, 2020 Identity & Access Management

Who are you — and what are you allowed to do? That's the fundamental question every secure system must answer. And it's exactly what Identity and Access Management (IAM) is built to solve.

How I built a web based CPU Simulator
May 07, 2020 Pet Projects

As someone passionate about computer engineering, reverse engineering, and system internals, I've always been fascinated by what happens "under the hood" of a computer. This curiosity led me to...

Writing a Shell Code for Linux
Apr 21, 2020 Exploit Development

Shellcode is a small piece of machine code used as the payload in exploit development. In this post, we write Linux shellcode from scratch — starting with a simple exit, building up to spawning a shell, and explaining every decision along the way.

Exploiting a Stack Buffer Overflow on Windows
Apr 12, 2020 Exploit Development

In a previous tutorial we discusses how we can exploit a buffer overflow vulnerability on a Linux machine. I wen through all theories in depth and explained each step. Now today we are going to jump...

Access Control Models
Apr 08, 2020 Identity & Access Management

Access control is one of the most fundamental concepts in security. Every time you set file permissions, assign user roles, or restrict access to a resource, you're implementing some form of access control. But not all access control is created equal...

Exploiting a  Stack Buffer Overflow  on Linux
Apr 01, 2020 Exploit Development

Have you ever wondered how attackers gain control over remote servers? How do they just run some exploit and compromise a computer? If we dive into the actual context, there is no magic happening....

Basic concepts of Cryptography
Mar 01, 2020 Cryptography

Ever notice that little padlock icon in your browser's address bar? That's cryptography working silently in the background, protecting everything you do online. Whether you're sending an email,...

Common Web Application Attacks
Feb 05, 2020 Application Security

Web applications are one of the most targeted surfaces by attackers. This is primarily because they are accessible over the internet, making them exposed and potentially vulnerable. Since these...

Remote Code Execution (RCE)
Jan 02, 2020 Application Security

Remote Code Execution (RCE) is the holy grail of application security vulnerabilities. It allows an attacker to execute arbitrary code on a remote server — and the consequences are as bad as it sounds. In this post, we'll go deep into RCE across multiple languages, including PHP, Java, Python, and Node.js.