Why Cowrie sucks (and how to beat them).
by House - Thursday July 27, 2023 at 06:04 PM
#1
Cowrie is a medium to high interaction honeypot mainly used for monitoring SSH and Telnet mass bruteforce scans. It's based on Kippo which is an even shittier open source honeypot and because of this, most of the issues I will be talking about here are also found in Kippo.

Despite being pretty trash, Cowrie is still the gold standard for honeypots and because of this, many different developers have tried to find ways of avoiding them. In 2016-2017 when more people started getting into IoT botnets, many security researchers were getting there Cowrie instances absolutely raped by Mirai/Ziggy/Bashlite clones that were all garbage and were pretty much the same reskinned code every time, and even the people who were making interesting and innovative botnets were not doing anything to prevent scanning or running their actual bins on the honeypot (which would let researchers reverse and publish about your malware) besides sometimes blocking out certain ranges. After realizing how bad Cowrie is, I decided to write this to give away some tricks when working with Cowrie and hopefully convince you that they are garbage too.

I am going to mention many parts of the source code for Cowrie, and it is open source and can be found here:
https://github.com/cowrie/cowrie

To start, many security researchers do not even try to customize their own honeypot instances. For example, if you /honeyfs/proc in the source code, this is what the default configuration for the /proc directory will be. It would be more work to generate these on each new instance, but I believe that having these here and for many to not even take the time and change these leads to many cases when you can simply compare this with what you're seeing on a machine to determine if it is a Cowrie honeypot.

View on Cowrie honeypot:
root@svr04:/proc# cat meminfo MemTotal:        4054744 kB MemFree:          997740 kB Buffers:          40276 kB Cached:          1801864 kB SwapCached:        17656 kB Active:          879260 kB Inactive:        1549432 kB Active(anon):    286488 kB Inactive(anon):  351652 kB Active(file):    592772 kB Inactive(file):  1197780 kB Unevictable:        2168 kB Mlocked:            2168 kB SwapTotal:      2097148 kB SwapFree:        2026516 kB Dirty:              240 kB Writeback:            0 kB AnonPages:        574040 kB Mapped:            56220 kB Shmem:            49908 kB Slab:            490824 kB SReclaimable:    444928 kB SUnreclaim:        45896 kB KernelStack:        3280 kB PageTables:        18352 kB NFS_Unstable:          0 kB Bounce:                0 kB WritebackTmp:          0 kB CommitLimit:    4124520 kB Committed_AS:    2625420 kB VmallocTotal:  34359738367 kB VmallocUsed:      363260 kB VmallocChunk:  34359366372 kB HardwareCorrupted:    0 kB AnonHugePages:        0 kB HugePages_Total:      0 HugePages_Free:        0 HugePages_Rsvd:        0 HugePages_Surp:        0 Hugepagesize:      2048 kB DirectMap4k:      273984 kB DirectMap2M:    3911680 kB root@svr04:/proc#

Another thing that that you will notice is the hostname. In older Cowrie instances that have been running and not been updated for long periods of time (>3 years), the hostname will actually be "LocalHost". But after they realized this was being abused, they changed this to be "svr04" as you can see above. In fact, you will see this continuous pattern of bad behaviors from the developers of exchanging one bad idea for another. For example, Cowrie used to have the default user "richard" in /honeyfs/etc/passwd. This, once again, began getting abused, and instead of simply removing this strange default user the simply renamed him to "phil".

root@svr04:/etc# cat passwd root:x:0:0:root:/root:/bin/bash daemon:x:1:1:daemon:/usr/sbin:/bin/sh bin:x:2:2:bin:/bin:/bin/sh sys:x:3:3:sys:/dev:/bin/sh sync:x:4:65534:sync:/bin:/bin/sync games:x:5:60:games:/usr/games:/bin/sh man:x:6:12:man:/var/cache/man:/bin/sh lp:x:7:7:lp:/var/spool/lpd:/bin/sh mail:x:8:8:mail:/var/mail:/bin/sh news:x:9:9:news:/var/spool/news:/bin/sh uucp:x:10:10:uucp:/var/spool/uucp:/bin/sh proxy:x:13:13:proxy:/bin:/bin/sh www-data:x:33:33:www-data:/var/www:/bin/sh backup:x:34:34:backup:/var/backups:/bin/sh list:x:38:38:Mailing List Manager:/var/list:/bin/sh irc:x:39:39:ircd:/var/run/ircd:/bin/sh gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/bin/sh nobody:x:65534:65534:nobody:/nonexistent:/bin/sh libuuid:x:100:101::/var/lib/libuuid:/bin/sh sshd:x:101:65534::/var/run/sshd:/usr/sbin/nologin phil:x:1000:1000:Phil California,,,:/home/phil:/bin/bash root@svr04:/etc#

The last example of simply a stupid default configuration is when running 'ps aux'. Based off of everything I have said before, you can most likely guess where the issues lie in this one.

root@svr04:/# ps aux USER        PID  %CPU      %MEM      VSZ      RSS      TTY    STAT  START root        1    0.0        0.89      180281344 4587520  ?      Ss    Jul22 root        2    0.0        0.0        0        0        ?      S<    Jul22 root        3    0.0        0.0        0        0        ?      S<    Jul22 root        5    0.0        0.0        0        0        ?      D<    Jul22 root        7    0.0        0.0        0        0        ?      Ss    Jul22 root        8    0.0        0.0        0        0        ?      Ss+  Jul22 root        9    0.0        0.0        0        0        ?      Ss+  Jul22 root        10    0.0        0.0        0        0        ?      S<    Jul22 root        11    0.0        0.0        0        0        ?      D<    Jul22 root        12    0.0        0.0        0        0        ?      Ss+  Jul22 root        13    0.0        0.0        0        0        ?      Ss    Jul22 root        15    0.0        0.0        0        0        ?      D<    Jul22 root        16    0.0        0.0        0        0        ?      D<    Jul22 root        17    0.0        0.0        0        0        ?      S<    Jul22 root        18    0.0        0.0        0        0        ?      Ss    Jul22 root        19    0.0        0.0        0        0        ?      D<    Jul22 root        20    0.0        0.0        0        0        ?      S<    Jul22 root        21    0.0        0.0        0        0        ?      S<    Jul22 root        22    0.0        0.0        0        0        ?      S<    Jul22 root        23    0.0        0.0        0        0        ?      S<    Jul22 root        24    0.0        0.0        0        0        ?      D<    Jul22 root        25    0.0        0.0        0        0        ?      Ss+  Jul22 root        27    0.0        0.0        0        0        ?      Ss    Jul22 root        28    0.0        0.0        0        0        ?      S<    Jul22 root        29    0.0        0.0        0        0        ?      S<    Jul22 root        35    0.0        0.0        0        0        ?      S<    Jul22 root        37    0.0        0.0        0        0        ?      S<    Jul22 root        38    0.0        0.0        0        0        ?      D<    Jul22 root        39    0.0        0.0        0        0        ?      D<    Jul22 root        74    0.0        0.0        0        0        ?      Ss    Jul22 root        75    0.0        0.0        0        0        ?      Ss+  Jul22 root        78    0.0        0.0        0        0        ?      S<    Jul22 root        79    0.0        0.0        0        0        ?      Ss+  Jul22 root        80    0.0        0.0        0        0        ?      Ss    Jul22 root        83    0.0        0.0        0        0        ?      Ss    Jul22 root        88    0.0        0.0        0        0        ?      D<    Jul22 root        103  0.0        0.0        0        0        ?      D<    Jul22 root        104  0.0        0.0        0        0        ?      Ss+  Jul22 root        135  0.0        0.0        0        0        ?      Ss+  Jul22 root        141  0.0        0.43      41754624  2211840  ?      Ss    Jul22 root        150  0.0        1.12      38326272  5820416  ?      S<    Jul22 root        360  0.0        0.35      37969920  1789952  ?      Ss    Jul22 statd        382  0.0        0.34      38174720  1748992  ?      Ss+  Jul22 root        387  0.0        0.0        0        0        ?      D<    Jul22 root        392  0.0        0.0        0        0        ?      Ss    Jul22 root        407  0.0        0.0        23916544  12288    ?      Ss    Jul22 root        413  0.0        0.31      19480576  1597440  ?      Ss    Jul22 root        414  0.0        0.51      28135424  2641920  ?      Ss    Jul22 root        417  0.0        0.34      20332544  1757184  ?      Ss+  Jul22 messagebus  419  0.0        0.51      43245568  2646016  ?      Ss+  Jul22 root        425  0.0        0.4        264880128 2088960  ?      D<    Jul22 root        427  0.0        0.31      4358144  1585152  ?      Ss    Jul22 root        442  0.0        0.33      14761984  1708032  tty1    Ss    Jul22 root        448  0.0        0.59      56508416  3067904  ?      D<    Jul22 Debian-exim  682  0.0        0.42      54530048  2154496  ?      D<    Jul22 root        697  0.0        0.11      26009600  589824    ?      Ss    Jul22 root        8574  0.0        0.0        0        0        ?      Ss+  Jul22 root        8611  0.0        0.0        0        0        ?      D<    Jul22 root        8743  0.0        0.21      307101696 1064960  ?      Ss    Jul22 root        9030  0.0        0.47      26009600  2424832  ?      Ss+  Jul22 root        21704 0.0        0.29      4440064  1507328  ?      D<    Jul22 mysql        22049 0.0        9.28      137470771248103424  ?      S<    Jul22 ejabberd    25061 0.0        0.05      27955200  233472    ?      Ss    Jul23 root        25065 0.0        0.0        0        0        ?      Ss+  Jul23 ejabberd    25095 0.0        8.87      968404992 45989888  ?      Ss    Jul23 root        25970 0.0        0.0        0        0        ?      D<    Jul23 root        26418 0.0        0.6        93380608  3092480  ?      Ss+  Jul23 www-data    26419 0.0        0.73      93704192  3760128  ?      Ss+  Jul23 www-data    26420 0.0        0.73      93704192  3760128  ?      D<    Jul23 www-data    26421 0.0        0.73      93704192  3760128  ?      Ss+  Jul23 www-data    26422 0.0        0.73      93704192  3760128  ?      D<    Jul23 root        28001 0.0        0.0        0        0        ?      Ss    Jul23 root        28002 0.0        0.0        0        0        ?      Ss    Jul23 root        4651  0.0        0.1        5416      1024      ?      Ss    Jul22 root        4656  0.0        0.1        5416      1024      pts/0  Ss    06:30 root        4658  0.0        0.1        2435      929      pts/0  Ss    06:30 root@svr04:/#

There are countless more examples I could use, such as how their bash interpreter sucks or how every file in /bin/ is the same:

root@svr04:/bin# ls bash          busybox        cat            chgrp          chmod          chown          chvt          cp            cpio          dash          date          dd            df            dir            dmesg          dnsdomainname  domainname    dumpkeys      echo          egrep          enable        false          fgconsole      fgrep          findmnt        grep          gunzip        gzexe          gzip          head          hostname      ip            kbd_mode      kill          kmod          ln            loadkeys      login          ls            lsblk          lsmod          mkdir          mknod          mktemp        more          mount          mountpoint    mt            mt-gnu        mv            nano          nc            nc.traditional netcat        netstat        nisdomainname  open          openvt        pidof          ping          ping6          ps            pwd            rbash          readlink      rm            rmdir          rnano          run-parts      sed            setfont        setupcon      sh            sh.distrib    sleep          ss            stty          su            sync          tail          tailf          tar            tempfile      touch          true          umount        uname          uncompress    unicode_start  vdir          which          ypdomainname  zcat          zcmp          zdiff          zegrep        zfgrep        zforce        zgrep          zless          zmore          znew          root@svr04:/bin# cat busybox ELF>x@@?@8@@@yy ?.shstrtab.text                               x@xy root@svr04:/bin# cat nano ELF>x@@?@8@@@yy ?.shstrtab.text                               x@xy root@svr04:/bin# cat mkdir ELF>x@@?@8@@@yy ?.shstrtab.text                               x@xy root@svr04:/bin# cat gzip ELF>x@@?@8@@@yy ?.shstrtab.text                               x@xy root@svr04:/bin# cat chmod ELF>x@@?@8@@@yy ?.shstrtab.text                               x@xy root@svr04:/bin# cat uname ELF>x@@?@8@@@yy ?.shstrtab.text                               x@xy root@svr04:/bin#

However, I assume most people are mainly interested in weaponizing these issues, and there are two main ways for people simply trying to perform mass scans. I call these two different methods remote detection and local detection. You can pretty much assume what they mean based on how I named them.

Remote detection happens mainly at infection time before the payload is dropped, and is done through the Telnet or SSH session. This is really what is preferred as it avoids dropping any actual binary onto the disk. In this method, simply use shell commands over SSH or Telnet to check the returns of specific commands or different indicators in the filesystem. If these exist, then you can avoid ever sending a first stage payload at all.

Local detection mainly relies on a two-step dropper, where the first stage is dropped and is used to scan the filesystem and determine if the host it is on is a honeypot or not. Unlike remote detection which is harder to see occur, there have been some cases of botnets using this two-step dropper system, but this is most likely because remote detection does not leave binary evidence.

I strongly suggest if this interests you to go break Cowrie more. I know it may seem rude to rip into an open source project like Cowrie, but for it to be the best is sad.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Tools AI, And Premium Prompts, Jailbreak kamis086 23 4,953 01-23-2026, 10:08 AM
Last Post: f3rr3tz
  OCR Automation Software | Classify thousands of PASSPORTS and IDs locally. E-137 5 677 04-07-2025, 09:53 PM
Last Post: Vroodo
  SDT - Simple Data Tool | Sort, extract emails and more xyndez 2 350 03-31-2025, 11:56 PM
Last Post: motherfucker
  Email bulk software - Simple and powerful sheol 9 905 03-21-2025, 11:53 PM
Last Post: Reyanoa
  The Hacker Machine 3 - A search engine for hackers and crackers hacknotifierplus 0 523 10-29-2024, 05:18 PM
Last Post: hacknotifierplus



 Users browsing this thread: 1 Guest(s)