Lecture 2 - MiTB Attack and Trojan Horse
Man-in-the-Browser Attack (MITB)
- The Man-in-the-Browser attack is the same approach as Man-in-the-middle attack, but in this case a Trojan Horse is used to intercept and manipulate calls between the browser and its security mechanisms or libraries on-the-fly.
- The most common objective of this attack is to cause financial fraud by manipulating transactions of Internet Banking systems, even when other authentication factors are in use.
- Points of effect:
- Browser Helper Objects – dynamically-loaded libraries loaded by Internet Explorer upon startup
- Extensions – the equivalent to Browser Helper Objects for Firefox Browser
- API-Hooking – this is the technique used by Man-in-the-Browser to perform its Man-in-the-Middle between the executable application (EXE) and its libraries (DLL)
- Technique for intercepting calls before the actual executing is done
- Normal
- Exe → DLL/API → OS — API Call
- API Hooking
- Exe – Hooking (intercept the call first) → DLL/API → OS
- If it’s malicious hook, then
- Javascript – By using a malicious Ajax worm
🧠 Analogy: Imagine a bank teller window with a hidden earpiece feeding fake instructions to the teller — the customer (browser) and the bank (server) both think they're talking directly to each other, but a hidden middleman is quietly changing what's said in between.
AJAX Background
- AJAX allows a web page to communicate with a server in the background and dynamically update parts of the page without requiring a full-page reload.
- Modern approach =
fetch(),XMLHttpRequest - Fetch API, libraries such as Axios, or frameworks such as React/Vue/Angular
How AJAX Works

Steps:
- An event occurs in a web page (the page is loaded, a button is clicked)
- An
XMLHttpRequestobject is created by JavaScript - The
XMLHttpRequestobject sends a request to a web server - The server processes the request
- The server sends a response back to the web page
- The response is read by JavaScript
- Proper action (like page update) is performed by JavaScript
🧠 Analogy: It's like sending a waiter (XMLHttpRequest) to the kitchen (server) to place an order without you (the page) having to get up and walk there yourself — the waiter comes back with the food (data) and quietly places it on your table (updates the page) without disrupting the rest of the dinner (full page reload).
Table 1: Differences Between Ajax Worm and Traditional Worm
Title
Virus = need file
Worm = can do self-replicate
| Differences in Characters | Traditional Worm | Ajax Worm |
|---|---|---|
| Running Position | Web server | Client Browser |
| Transmitting method | Spontaneous Search | Integration of Spontaneous Search and Passive Search |
| Platform-dependence | Running on the Operating System and Application Software of Web Server | Depending on the Type and Edition of Browser |
| Functional Limitation | Configuration of Server | Strategy of Customer Browser |
| Programming Language | Perl, PHP and other server-side script | JavaScript |
| Using Leak | Web Server Application Software Leak | Web Pages Input Detection Leak |
How Man-in-the-Browser Attacks Are Executed
- Phase 1: Malware insertion
- The trojan horse gets inserted in the device's operating system when the user:
- downloads a corrupted software
- visits any malicious site
- opens or downloads malicious email attachments
- plugs corrupted external devices such as USB drives/CDs on their computers/tablets/mobile phones
- The trojan automatically installs a malicious extension in the web browser without the user's knowledge.
- Whenever the user restarts the browser, the extension gets activated.
- The trojan horse gets inserted in the device's operating system when the user:
- Phase 2: Transaction Interruption
- When the user clicks Submit or any other authorization button, the malicious script modifies the transaction details. For example, changing the transaction amount, bank numbers, physical address, product, etc. and sends the modified information to the website's server.
- Phase 3: Response Modification
- The corrupted browser modifies the output display e.g. receipts that match the details of the users' original transaction.
🧠 Analogy: It's like a corrupt translator standing between you and a foreign bank clerk. You say "send 10,000 to my friend", and then tells you "done, $10 sent!" — showing you a fake receipt while quietly pocketing the difference.
Man-in-the-Browser Attack Diagram

Key steps shown:
- User downloads malware infecting workstation
- The malicious malware infects the workstation browser
- User access bank website requesting a transaction
- The malware records the transaction request and modifies it
- Money and receipt are transferred to the hacker
- The malware changes the transaction receipt to the user requested transaction to remain hidden
- Man-in-the-browser is a form of man-in-the-middle attack where an attacker is able to insert himself into the communications channel between two trusting parties by compromising a Web browser used by one of the parties, for the purpose of eavesdropping, data theft and/or session tampering.
What Are Some Examples on Man in the Browser Attacks?
- There are many examples for man-in-the-browser malware and attack campaigns targeting online banking and other internet services. Infamous names of malware used include: Zeus, Spyeye, Bugat, Carberp, Silon, Tatanga, and more.
Preventing MITB
- Use out-of-band authentication such as SMS
- Out-of-band is not a direct authentication
- Use Security Software
- Recognize Trojan behaviors
- Avoid malicious websites
- Avoid phishing emails

Can Man in the Browser Happen on a Mobile Device?
Man-in-the-Mobile (MitMo) Attack
- MitMo (also known as "Man-in-the-Mobile") is a cyber threat that targets mobile devices, intercepting and altering communications between a mobile device and the services the user interacts with.
- MitMo poses a significant threat to mobile security, combining elements from man-in-the-middle (MitM) attacks with mobile malware.
- It presents a serious challenge for out-of-band authentication systems, as the malware can spy on SMS OTPs or voice calls and relay them back to the hackers.
- Only an offline approach with challenge-response and transaction data signing can defeat this new manifestation of a classic Man-in-the-Middle attack.
- One-time passwords and out-of-band authentication are easily defeated by malware loaded onto mobile phones.
- The increase in mobile fraud is commensurate with the increase in performing online authentication and transactions on mobile platforms.
🧠 Analogy: Think of MitMo like a fake mail carrier who intercepts your PIN letter from the bank before it reaches your mailbox, reads it, then delivers it late — by which point they've already used the PIN to rob you.
How Does MitMo Work?

- MitMo attacks can take many forms and are constantly evolving.
- A common scenario is that a desktop component of the malware requests the victim's phone number and sends an SMS link to their mobile device to download a "security application."
- Users then click on the SMS link to install the fake application and enter an activation code provided by the malware.
- Once installed, the mobile malware captures all SMS traffic, including transaction authorization codes sent by the bank to the victim.
- It forwards them to the threat actors, enabling the hackers to initiate fraudulent transactions and intercept the security codes needed to authorize them.
Consequences (of MitMo)
- Intercepting Communication: MitMo attacks involve intercepting communications between mobile devices and networks they connect to, with attackers positioning themselves between these entities to eavesdrop on traffic between them.
- Identity Theft: When attackers gain access to a device's communication stream, they may capture sensitive data transmitted by it, such as usernames and passwords sent from devices and authentication tokens or credentials, which could later be used for identity theft or unauthorized account access. This data could then be misused against its rightful owners and lead to identity theft or unauthoritarian account access for further fraud or misuse by individuals seeking unauthorized entry.
- Transaction Manipulation: MitMo attacks can use their abilities to manipulate transactions through social engineering techniques. For instance, when initiating financial transactions online, an attacker could modify transaction details or divert funds directly into their accounts by altering recipient info or redirecting funds through fraudulent channels.
- Malicious Payloads: MitMo attacks frequently involve injecting malicious payloads onto the target device and intercepting and altering communication, including malware, spyware, or keyloggers that can give attackers control of it or collect user data or monitor user activities. These payloads allow hackers to control devices remotely, steal information, or monitor users' activities.
- Phishing attacks: MitMo attacks often use phishing techniques to persuade users to divulge sensitive data voluntarily. Attackers may craft convincing fake login screens or webpages that mimic legitimate services, prompting unknowing people to enter their credentials.
- Advanced techniques: MitMo attacks constantly evolve, and attackers use sophisticated strategies to avoid detection and bypass security measures. Such methods could include SSL stripping, certificate spoofing, or DNS spoofing to manipulate communication channels further and make their attacks harder to detect.
SSL stripping, try to downgrade HTTPS to HTTP.
Preventing MitMo Attack
1. Stronger Authentication Mechanisms
- App-based OTP / TOTP
- Replace SMS OTP with Time-based One-Time Passwords (TOTP) via secure authenticator apps (Google Authenticator, Microsoft Authenticator).
- Resistant to SMS interception.
- Push-based Authentication
- Use push notifications requiring in-app confirmation (e.g., Okta Verify, Duo Push).
- Tied to device cryptographic keys, preventing simple OTP relay.
- FIDO2/WebAuthn
- Hardware security keys or platform authenticators (YubiKey, biometric hardware).
- Eliminates OTP-based weaknesses entirely.
🧠 Analogy: SMS OTP is like shouting your password across the room where anyone can eavesdrop; FIDO2/hardware keys are like a physical key that only fits one specific lock — nobody can "overhear" and copy it.
2. Mobile Device & App Security
- Runtime Application Self-Protection (RASP)
- App actively monitors itself for hooking, debugging, or code injection attempts.
- Blocks execution when malicious behavior is detected.
- Mobile Threat Defense (MTD)
- Deploy MTD solutions (e.g., Zimperium, Lookout, Microsoft Defender for Endpoint) to detect SMS interception, privilege abuse, and malicious APKs.
- App Permission Control
- Enforce least privilege: banking app checks for dangerous permissions (
READ_SMS,RECEIVE_SMS). - Block usage on rooted/jailbroken devices.
- Enforce least privilege: banking app checks for dangerous permissions (
3. Secure OTP Delivery and Validation
- Encrypted OTP Channels – Deliver OTPs inside the mobile banking app over an encrypted TLS channel rather than via SMS.
- OTP Binding – Bind OTP to transaction metadata (amount, account number, timestamp) so it cannot be reused for other transactions.
- Short OTP Lifetime & One-Time Use – Expire OTPs in seconds (30–60 sec) to limit exploitation time.
4. Network & Transaction Layer Protections
- Transaction Signing
- Use HMAC or digital signatures from a secure enclave in the mobile device to sign the transaction.
- Prevents attackers from using an OTP for altered transactions.
- Secure Element (SE) / Trusted Execution Environment (TEE)
- Store sensitive keys and execute OTP generation inside isolated hardware.
🧠 Analogy: Transaction signing is like sealing a letter with a unique wax stamp that only your ring can make — even if someone intercepts the letter, they can't forge a new one claiming to be from you.
Can SSL Channel Prevent MitMo?
Answer: No
SSL Stripping
- SSL stripping attacks (also known as SSL downgrade or HTTP downgrade attacks) are a type of cyber attack in which hackers downgrade a web connection from the more secure HTTPS to the less secure HTTP.
- When users visit a website, they first connect with the HTTP version before getting rerouted to the HTTPS version. In SSL stripping attacks, hackers jump in this window to act as a man in the middle and prevent users from ever connecting with the HTTPS version of the site.
- SSL stripping attacks occur when a hacker intervenes in the connection between a user and a website. The hacker sits in the middle of the connection, connecting themselves to the HTTPS version of the site and connecting the user to the HTTP version of the site.
🧠 Analogy: Imagine you're trying to enter a secure vault (HTTPS), but someone quietly swaps the vault door for a flimsy wooden one (HTTP) right before you walk in — you think you're safe, but the "guard" (attacker) is standing right there watching everything you do.
SSL Stripping Diagram

- An attacker intercepts the transition from HTTP to HTTPS.
How Can You Protect Against SSL Stripping Attacks?
- Enable SSL sitewide for your own website
- It's common to enable SSL on any web pages that require users to input information, which is a good start. But the best practice is to enable SSL across your entire website.
- Implement HSTS policy on company computers
- HSTS stands for HTTP Strict Transport Security and creates a policy that says the browser shouldn't open a page that does not have a HTTPS connection and should redirect users from the HTTP version of the site to the HTTPS version of the site when possible.
- Enable secure cookies for all company users
- All of the cookies their browsers use will have secure attributes and can only be sent over secure HTTPS connections.
QR Phishing (Quishing)
QR Phishing
- It tricks victims into scanning a malicious QR code that links to a fake website or downloads malware.
- The QR codes often appear trustworthy, posted on flyers, advertisements, or products by bad actors impersonating legitimate businesses.

QR Code Phishing (Quishing) Flow

Steps shown:
- Attacker sends spam that contains a QR code.
- Internet user receives spam...
- ...and scans the QR code with their smartphone.
- The QR code leads to a phishing page created by the attacker.
- There the user has to enter personal data (e.g. passwords), which...
- ...the attacker then captures.
🧠 Analogy: A QR code is like an address written in a code only your phone can "read" — you can't tell just by looking at it whether it leads to your friend's house or a trap, so scanning blindly is like walking through a door without knowing what's on the other side.
What Is a Trojan Horse Virus?

- Type of malware disguised as a legitimate program.
- Delivered via social engineering to hide malicious code.
- Common entry points: Email attachments, free downloads.
- Goal: Gain unauthorized access, steal data, spy, or install more malware.
🧠 Analogy: Just like the mythical wooden horse that looked like a gift but hid soldiers inside, a Trojan Horse virus looks like a harmless app (a game, a tool, a PDF) but secretly carries malicious code inside it.
How Trojans Work
- Cannot self-replicate; requires user to install/execute file.
- Delivered via malicious emails, fake software, ads, or links.
- Malware may stay dormant or active based on triggers.
- Dormant = keep silent
- Installs silently, runs at startup, may create backdoor or join botnet.
Common Types of Trojans
- Backdoor Trojan – Remote control over device.
- Banker Trojan – Steals banking & payment credentials.
- DDoS Trojan – Launches service disruptions.
- Downloader Trojan – Installs more malware.
- Exploit Trojan – Targets known vulnerabilities.
- Fake AV Trojan – Extorts money via fake virus alerts.
- Game-Thief Trojan – Steals online gaming credentials.
- IM Trojan – Steals messaging platform logins.
- Infostealer Trojan – Hides/protects other malware.
- Ransom Trojan – Locks system or files until ransom paid.
- Rootkit Trojan – Hides malicious processes from detection.
- Spy Trojan – Keylogging, screenshots, spying.
Notable Trojan Example: SUNBURST
- 2020 SolarWinds Orion compromise.
- Trojanized SolarWinds DLL file.
- Dormant for 2 weeks before activation.
- Capabilities: Data transfer, remote execution, reconnaissance.
- Spread to major government & corporate networks.
Other Famous Trojan Attacks
- Rakhni Trojan – Ransomware & crypto-mining.
- Tiny Banker – Stole banking credentials (20+ U.S. banks).
- Zeus/Zbot – Toolkit for financial Trojans with keylogging.
Signs of a Trojan Infection
- Unexpected system setting changes.
- เราจะ detect ได้ยังไง ก็ hashing, monitor log ก็ได้
- Sudden performance slowdown.
- Strange programs/processes running.
- High network activity without reason.
- Disabled antivirus or firewall.
Protection Against Trojans
- Keep OS & software updated.
- Use reputable antivirus & run regular scans.
- Avoid suspicious links or attachments.
- Inspect URLs before visiting.
- Enable browser security extensions.
- Educate users on phishing & social engineering.
Practical Detection / Validation Process
1. Cryptographic Signature Integrity
- Verify the binary's Authenticode signature (Windows) or platform-specific equivalent.
- Check that the signature chain terminates in a trusted root CA in your OS trust store.
- Confirm hash integrity: the signed hash matches the binary content (no tampering).
2. Timestamp & Countersignature
- Ensure there's a trusted timestamp proving the file was signed while the certificate was valid.
- Detect binaries signed post-expiration or without countersignature, which may indicate forged or outdated signing.
3. Extended Key Usage (EKU) Verification
- Ensure the signing certificate has Code Signing () EKU.
- The Code Signing () EKU is an Extended Key Usage (EKU) object identifier in X.509 certificates that explicitly permits the certificate to be used for digitally signing software.
- Flag unexpected EKUs (e.g., server auth) used for signing executables.
4. Chain Health
- Continuously ingest revocation lists (CRL/OCSP) and check whether the signer's cert is revoked.
- Monitor for emerging abused issuers reported in threat intel feeds.
Analogy: Code signing is like a notarized signature on a legal document — checking the "chain of trust" is like tracing that notary's authority all the way back to the government that licensed them, and making sure their license hasn't expired or been revoked.
Hardware Trojan
- A hardware Trojan is a malicious modification of an integrated circuit (IC) or hardware design that's intentionally inserted into the manufacturing or design process to alter the device's normal functionality, cause failures, or create hidden backdoors for an attacker.
- It's essentially the hardware-world equivalent of a software Trojan — hidden, malicious, and often dormant until triggered.
Analogy: It's like a factory secretly building a hidden compartment into a safe during manufacturing — the safe works perfectly normally, but there's a secret way in that only the factory (attacker) knows about.
Key Characteristics
| Aspect | Description |
|---|---|
| Insertion point | Can occur at design phase (RTL/VHDL/Verilog), fabrication (foundry), or post-fabrication (e.g., chip reprogramming). |
| Payload | Malicious logic that alters functionality, leaks data, disables security, or degrades performance. |
| Trigger | Activated by specific conditions, such as certain input patterns, counters reaching a value, time/date, or external signals. |
| Stealth | Designed to avoid detection by normal functional testing; may stay dormant under typical use. |
Types of Hardware Trojans
A. Based on Effect
- Functional Trojans – Change intended operations of the circuit.
- E.g., modify encryption logic to output predictable keys.
- Parametric Trojans – Alter physical parameters.
- E.g., change transistor threshold voltages to cause timing failures or shorten lifespan.
B. Based on Activation
- Always-On – Active immediately after deployment; easier to detect during testing.
- Triggered – Activated only under rare, specific conditions; harder to detect.
- Trigger types: internal counters, special input sequences, environmental conditions (temperature, voltage).
- Example: a Trojan that is triggered when the circuit reaches a defined temperature. This Trojan can be activated remotely by sending a large number of network requests to the target device, artificially raising its temperature.
Hardware Trojan Architectures Diagram

Triggers-based (Skipped)
- Combinatorial method consists purely of combinational logic. Therefore, the corresponding payload is only active while the trigger condition is maintained.
- Sequential-based is a sense of state or incorporate such signals from the host design.
- Counter based or timebomb triggers
- Finite state machine (FSM) triggers (the FSM transitions from one state to another when some set of signal values is observed.)
Payload Architectures
- Modifying microprocessor instructions, disabling a receiver, and leaking a cryptographic key, respectively.
- Similar to the trigger, the payload architecture can be made of combinational or sequential gates.
Combinatorial Method
- t-flip payload. This is implemented with an XOR gate that has one input from the trigger and one input from the targeted node. When the Trojan is triggered, the value of the targeted node is inverted.
- Leakage. Replaces one signal in the design with another to cause functional failure or leak a design asset.
Sequential Method
- These payloads can increase the time it takes to observe the Trojan effect, and allow for more complex functions. Especially been employed to leak data off-chip.
- MOLES payload uses a linear feedback shift register (LFSR) configured to generate a maximal length sequence used as a pseudo-random number generator (PRNG). Select bits of this LFSR are XORed with the data to be leaked. The outputs of the XOR gates are passed through a capacitive load.
🧠 Analogy: The t-flip payload is like a light switch that only flips when a secret signal (trigger) is sent — otherwise it behaves completely normally, making it invisible during normal testing.
Examples (Hardware Trojan)
- Backdoor in a CPU allowing privileged instructions to bypass authentication.
- Malicious modification in encryption accelerator that leaks keys through side channels.
- Extra logic in a networking ASIC that opens a covert communication channel.
- Covert = unwelcomed channel, try to send hidden infromation (leakage) to the outsider
- Delay-based Trojan that causes timing violations at critical workloads.
Risks & Impacts
- Confidentiality breach – Extraction of cryptographic keys or sensitive data.
- Integrity compromise – Altered computations, incorrect outputs.
- Availability disruption – Intentional failures or performance degradation.
- Long-term control – Persistent access for attackers even after software is updated.
Verification Flow of Semiconductor IP Design

Detection & Prevention (Hardware Trojans)
A. Detection
- Functional Testing – Applying a wide range of test vectors to detect unexpected outputs.
- Side-Channel Analysis – Measuring power consumption, electromagnetic emissions, or timing to detect anomalies.
- Reverse Engineering – Physical inspection of IC layouts (destructive and expensive).
- Run-time Monitoring – Embedded sensors to detect abnormal circuit behavior.
B. Prevention
- Design-time Verification – Formal verification, code reviews, logic equivalence checks.
- Split Manufacturing – Fabrication split across facilities so no single entity sees the full design.
- Trusted Foundries – Using vetted, secure manufacturing facilities.
- Hardware Root of Trust – Embed immutable trusted elements for authentication and validation.
🧠 Analogy: Split manufacturing is like having different chefs each prepare one ingredient of a secret recipe without knowing the full dish — no single chef can steal or sabotage the whole recipe because none of them sees it in its entirety.