{"id":11523,"date":"2026-03-22T04:04:04","date_gmt":"2026-03-22T04:04:04","guid":{"rendered":"https:\/\/serisec.com\/index.php\/2026\/03\/22\/32816\/"},"modified":"2026-03-22T04:04:04","modified_gmt":"2026-03-22T04:04:04","slug":"32816","status":"publish","type":"post","link":"https:\/\/serisec.com\/index.php\/2026\/03\/22\/32816\/","title":{"rendered":"GSocket Backdoor Delivered Through Bash Script, (Fri, Mar 20th)"},"content":{"rendered":"<p>    GSocket Backdoor Delivered Through Bash Script, (Fri, Mar 20th)<br \/>\n \t<BR><br \/>\n<BR><\/BR><br \/>\n    <!-- no image --><br \/>\n \t<BR><br \/>\n<BR><\/BR><\/p>\n<div>\n<p>Yesterday, I discovered a malicious Bash script that installs a GSocket backdoor on the victim\u2019s computer. I don\u2019t know the source of the script not how it is delivered to the victim.<\/p>\n<p>GSocket[<a href=\"https:\/\/www.gsocket.io\/\">1<\/a>] is a networking tool, but also a relay infrastructure, that enables direct, peer-to-peer\u2013style communication between systems using a shared secret instead of IP addresses or open ports. It works by having both sides connect outbound to a global relay network. Tools like gs-netcat can provide remote shells, file transfer, or tunneling and bypass classic security controls. The script that I found uses a copy of gs-netcat but the way it implements persistence and anti-forensic techniques deserves a review.<\/p>\n<p>A few weeks ago, I found a sample that used GSocket connectivity as a C2 channel. It makes me curious and I started to hunt for more samples. Bingo! The new one that I found (SHA256:6ce69f0a0db6c5e1479d2b05fb361846957f5ad8170f5e43c7d66928a43f3286[<a href=\"https:\/\/www.virustotal.com\/gui\/file\/6ce69f0a0db6c5e1479d2b05fb361846957f5ad8170f5e43c7d66928a43f3286\/telemetry\">2<\/a>]) has been detected by only 17 antivirus solutions on VT. The script is not obfuscated and even has comments so I think that it was uploaded on VT for &#8220;testing&#8221; purposes by the developper (just a guess)<\/p>\n<p>Let\u2019s have a look at the techniques used.\u00a0When you execute it in a sandbox, you see this:<\/p>\n<p><img data-recalc-dims=\"1\" decoding=\"async\" alt=\"\" src=\"https:\/\/i0.wp.com\/isc.sans.edu\/diaryimages\/images\/isc-20260219-1.png?ssl=1\" style=\"width: 802px; height: 264px;\"><\/p>\n<p>Note the identification of the tool (&#8220;G-Socket Bypass Stealth&#8221;) and the reference to &#8220;@bboscat&#8221;[<a href=\"https:\/\/zone-xsec.com\/archive\/attacker\/%40bboscat\">3<\/a>]<\/p>\n<p>A GSocket client is downloaded, started and is talking to the following IP:<\/p>\n<p><img data-recalc-dims=\"1\" decoding=\"async\" alt=\"\" src=\"https:\/\/i0.wp.com\/isc.sans.edu\/diaryimages\/images\/isc-20260319-2.png?ssl=1\" style=\"width: 800px; height: 84px;\"><\/p>\n<p>The malware implements persistence through different well-known techniques on Linux. First, a cron job is created:<\/p>\n<p><img data-recalc-dims=\"1\" decoding=\"async\" alt=\"\" src=\"https:\/\/i0.wp.com\/isc.sans.edu\/diaryimages\/images\/isc-20260319-3.png?ssl=1\" style=\"width: 1200px; height: 248px;\"><\/p>\n<p>Every top-hour, the disguised gs-netcat will be killed (if running) and restarted. To improve persistence, the same code is added to the victim&#8217;s .profile:<\/p>\n<p><img data-recalc-dims=\"1\" decoding=\"async\" alt=\"\" src=\"https:\/\/i0.wp.com\/isc.sans.edu\/diaryimages\/images\/isc-20260319-4.png?ssl=1\" style=\"width: 1200px; height: 78px;\"><\/p>\n<p>The malware itself is copied in .ssh\/putty and the GSocket shared secret stored in a fake SSH key file:<\/p>\n<p><img data-recalc-dims=\"1\" decoding=\"async\" alt=\"\" src=\"https:\/\/i0.wp.com\/isc.sans.edu\/diaryimages\/images\/isc-20260319-5.png?ssl=1\" style=\"width: 1200px; height: 133px;\"><\/p>\n<p>The ELF file id_rsa (SHA256: d94f75a70b5cabaf786ac57177ed841732e62bdcc9a29e06e5b41d9be567bcfa) is the gs-netcat tool downloaded directly from the G-Socket CDN.<\/p>\n<p>Ok, let\u2019s have a look at an interesting anti-forensic technique implemented in the Bash script. File operations are not simply performed using classic commands like cp, rm, mv, etc. They are embedded in \u201chelper\u201d functions with a timestamp tracking\/restoration system so the malware can later hide filesystem changes. Here is an example with a function that will create a file:<\/p>\n<pre style=\"background: rgb(238, 238, 238); border: 1px solid rgb(204, 204, 204); padding: 5px 10px;\">\nmk_file()\n{\n  local fn\n  local oldest\n  local pdir\n  local pdir_added\n  fn=\"$1\"\n  local exists\n\n  # DEBUGF \"${CC}MK_FILE($fn)${CN}\"\n  pdir=\"$(dirname \"$fn\")\"\n  [[ -e \"$fn\" ]] &amp;&amp; exists=1\n\n  ts_is_marked \"$pdir\" || {\n    # HERE: Parent not tracked\n    _ts_add \"$pdir\" \"&lt;NOT BY XMKDIR&gt;\"\n    pdir_added=1\n  }\n\n  ts_is_marked \"$fn\" || {\n    # HERE: Not yet tracked\n    _ts_get_ts \"$fn\"\n    # Do not add creation fails.\n    touch \"$fn\" 2&gt;\/dev\/null || {\n      # HERE: Permission denied\n      [[ -n \"$pdir_added\" ]] &amp;&amp; {\n        # Remove pdir if it was added above\n        # Bash &lt;5.0 does not support arr[-1]\n        # Quote (\") to silence shellcheck\n        unset \"_ts_ts_a[${#_ts_ts_a[@]}-1]\"\n        unset \"_ts_fn_a[${#_ts_fn_a[@]}-1]\"\n        unset \"_ts_mkdir_fn_a[${#_ts_mkdir_fn_a[@]}-1]\"\n      }\n      return 69 # False\n    }\n    [[ -z $exists ]] &amp;&amp; chmod 600 \"$fn\"\n    _ts_ts_a+=(\"$_ts_ts\")\n    _ts_fn_a+=(\"$fn\");\n    _ts_mkdir_fn_a+=(\"&lt;NOT BY XMKDIR&gt;\")\n    return\n  }\n\n  touch \"$fn\" 2&gt;\/dev\/null || return\n  [[ -z $exists ]] &amp;&amp; chmod 600 \"$fn\"\n  true\n}<\/pre>\n<p>Here are also two interesting function:<\/p>\n<pre style=\"background: rgb(238, 238, 238); border: 1px solid rgb(204, 204, 204); padding: 5px 10px;\">\n# Restore timestamp of files\nts_restore()\n{\n  local fn\n  local n\n  local ts\n\n  [[ ${#_ts_fn_a[@]} -ne ${#_ts_ts_a[@]} ]] &amp;&amp; { echo &gt;&amp;2 \"Ooops\"; return; }\n\n  n=0\n  while :; do\n    [[ $n -eq \"${#_ts_fn_a[@]}\" ]] &amp;&amp; break\n    ts=\"${_ts_ts_a[$n]}\"\n    fn=\"${_ts_fn_a[$n]}\"\n    # DEBUGF \"RESTORE-TS ${fn} ${ts}\"\n    ((n++))\n\n    _ts_fix \"$fn\" \"$ts\"\n  done\n  unset _ts_fn_a\n  unset _ts_ts_a\n\n  n=0\n  while :; do\n    [[ $n -eq \"${#_ts_systemd_ts_a[@]}\" ]] &amp;&amp; break\n    ts=\"${_ts_systemd_ts_a[$n]}\"\n    fn=\"${_ts_systemd_fn_a[$n]}\"\n    # DEBUGF \"RESTORE-LAST-TS ${fn} ${ts}\"\n    ((n++))\n\n    _ts_fix \"$fn\" \"$ts\" \"symlink\"\n  done\n  unset _ts_systemd_fn_a\n  unset _ts_systemd_ts_a\n}\n\nts_is_marked()\n{\n  local fn\n  local a\n  fn=\"$1\"\n\n  for a in \"${_ts_fn_a[@]}\"; do\n    [[ \"$a\" = \"$fn\" ]] &amp;&amp; return 0 # True\n  done\n\n  return 1 # False\n}<\/pre>\n<p>ts_is_marked() checks whether a file\/directory is already registered for timestamp restoration, preventing duplicate tracking and ensuring the script\u2019s anti-forensic timestamp manipulation works correctly. I asked ChatGPT to generate a graph that explains this technique:<\/p>\n<p><img data-recalc-dims=\"1\" decoding=\"async\" alt=\"\" src=\"https:\/\/i0.wp.com\/isc.sans.edu\/diaryimages\/images\/84b29eb7dcfbaa3f1e2d0d8004e1fdc7a23bf5c85f226e52611c22e5530be9de.png?ssl=1\" style=\"width: 600px; height: 900px;\"><\/p>\n<p>Finally,\u00a0because it\u2019s fully based on Bash, the script will infect all UNIX flavors, MacOS included:<\/p>\n<pre style=\"background: rgb(238, 238, 238); border: 1px solid rgb(204, 204, 204); padding: 5px 10px;\">\n[[ -z \"$OSTYPE\" ]] &amp;&amp; {\n  local osname\n  osname=\"$(uname -s)\"\n  if [[ \"$osname\" == *FreeBSD* ]]; then\n    OSTYPE=\"FreeBSD\"\n  elif [[ \"$osname\" == *Darwin* ]]; then\n    OSTYPE=\"darwin22.0\"\n  elif [[ \"$osname\" == *OpenBSD* ]]; then\n    OSTYPE=\"openbsd7.3\"\n  elif [[ \"$osname\" == *Linux* ]]; then\n    OSTYPE=\"linux-gnu\"\n  fi\n}<\/pre>\n<p>[1] <a href=\"https:\/\/www.gsocket.io\/\">https:\/\/www.gsocket.io<\/a><br \/>\n[2]\u00a0<a href=\"https:\/\/www.virustotal.com\/gui\/file\/6ce69f0a0db6c5e1479d2b05fb361846957f5ad8170f5e43c7d66928a43f3286\/telemetry\">https:\/\/www.virustotal.com\/gui\/file\/6ce69f0a0db6c5e1479d2b05fb361846957f5ad8170f5e43c7d66928a43f3286\/telemetry<br \/>\n\u200b\u200b\u200b\u200b\u200b\u200b\u200b<\/a>[3]\u00a0<a href=\"https:\/\/zone-xsec.com\/archive\/attacker\/%40bboscat\">https:\/\/zone-xsec.com\/archive\/attacker\/%40bboscat<\/a><\/p>\n<p>Xavier Mertens (@xme)<br \/>\nXameco<br \/>\nSenior ISC Handler &#8211; Freelance Cyber Security Consultant<br \/>\n<a href=\"https:\/\/keybase.io\/xme\/key.asc\">PGP Key<\/a><\/p>\n<p> (c) SANS Internet Storm Center. https:\/\/isc.sans.edu Creative Commons Attribution-Noncommercial 3.0 United States License.<\/p><\/div>\n<p> \t<BR><br \/>\n <BR><\/BR><\/p>\n<p> \t<BR><br \/>\n<BR><\/BR><br \/>\n<a href=\"https:\/\/isc.sans.edu\/diary\/rss\/32816\">Go to isc.sans.edu<\/a><br \/>\n \t<BR><br \/>\n <BR><\/BR><\/p>\n","protected":false},"excerpt":{"rendered":"<p>GSocket Backdoor Delivered Through Bash Script, (Fri, Mar 20th) Yesterday, I discovered a malicious Bash script that installs a GSocket backdoor on the victim\u2019s computer. I don\u2019t know the source of the script not how it is delivered to the victim. GSocket[1] is a networking tool, but also a relay infrastructure, that enables direct, peer-to-peer\u2013style [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[56],"tags":[69],"class_list":["post-11523","post","type-post","status-publish","format-standard","hentry","category-isc-sans-edu","tag-isc-sans-edu"],"_links":{"self":[{"href":"https:\/\/serisec.com\/index.php\/wp-json\/wp\/v2\/posts\/11523"}],"collection":[{"href":"https:\/\/serisec.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/serisec.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/serisec.com\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/serisec.com\/index.php\/wp-json\/wp\/v2\/comments?post=11523"}],"version-history":[{"count":0,"href":"https:\/\/serisec.com\/index.php\/wp-json\/wp\/v2\/posts\/11523\/revisions"}],"wp:attachment":[{"href":"https:\/\/serisec.com\/index.php\/wp-json\/wp\/v2\/media?parent=11523"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/serisec.com\/index.php\/wp-json\/wp\/v2\/categories?post=11523"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/serisec.com\/index.php\/wp-json\/wp\/v2\/tags?post=11523"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}