• This repository has been archived on 22/Mar/2022
  • Stars
    star
    664
  • Rank 67,903 (Top 2 %)
  • Language
    C
  • License
    GNU General Publi...
  • Created over 4 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Avast JavaScript Interactive Shell

Avast Antivirus JavaScript Interpreter

NOTE: On 03/11/2020 Avast announced they had decided to disable this interpreter globally!

The main Avast antivirus process is called AvastSvc.exe, which runs as SYSTEM.

AvastSvc.exe

That service loads the low level antivirus engine, and analyzes untrusted data received from sources like the filesystem minifilter or intercepted network traffic.

Despite being highly privileged and processing untrusted input by design, it is unsandboxed and has poor mitigation coverage. Any vulnerabilities in this process are critical, and easily accessible to remote attackers.

So.. maybe not great that it includes a custom JavaScript interpreter....???? 🙃

screenshot

This repository contains an interactive shell that lets you test the interpreter on Linux for vulnerability research.

Building

Here's how to try it out, first install the dependencies.

Ubuntu

$ sudo apt install libreadline-dev:i386 libc6-dev-i386 gcc-multilib

Fedora

$ sudo yum install readline-devel.i686 glibc-devel.i686 libgcc.i686

Now you can clone this repository.

$ git clone https://github.com/taviso/avscript.git
$ cd avscript
$ git submodule update --init --recursive

If everything looks good, build it and avscript should be ready.

$ make

Notes

Reproducing Vulnerabilities on Windows

For performance reasons, Avast do not interpret every JavaScript file they encounter, they use a heuristic to determine if it's necessary. I've found that appending the file javascript.txt included in this repository is enough to always trigger the heuristic.

For example, if you have found a vulnerability and want to reproduce it on Windows, you would first do this:

$ cat yourtestcase.js javascript.txt > ReproForWindows.js

Now verify that it still does what you expect, e.g.

$ ./avscript ReproForWindows.js
main(): File ReproForWindows.js` loaded, about to initialize interpreter...
Segmentation fault (core dumped)

Then verify the crash reproduced on Windows.

Protected Process

The Avast service is a protected process, which means debugging it from userspace is tricky. If you have kd configured, you can simply undo this and then debugging in userspace works fine.

A quick and easy solution that works on 32-bit is to do this (note that PatchGuard won't permit this on x64, but you can do something similar with breakpoint commands).

screenshot

There is also a setting under "Troubleshooting" called "Enable Self-Defense" that should be disabled. I believe this setting disables hooking OpenProcess() in the SSDT, where they normally blacklist their own process.

You may need to temporarily disable "shields" in the Avast UI while you attach so that filesystem operations don't deadlock while the service is suspended.

Debugging

Avast does not publish any symbols for their engine, but debugging with IDA or gdb is still possible. There are some notes on debugging Windows code from Linux in the loadlibrary documentation.

If you want to use IDA, I would recommend using the gdbserver backend.

Simply use something like this, you might need to install the gdbserver package first:

$ gdbserver 0.0.0.0:23946 ./avscript

This works surprisingly well, even pseudocode breakpoints work.

IDA screenshot

Vulnerabilities

If you find a vulnerability, it is likely critical and wormable.

🔥 Please report it urgently. 🔥

More Repositories

1

loadlibrary

Porting Windows Dynamic Link Libraries to Linux
C
4,330
star
2

ctypes.sh

A foreign function interface for bash.
C
2,060
star
3

ctftool

Interactive CTF Exploration Tool
C
1,636
star
4

123elf

A native port of Lotus 1-2-3 to Linux.
C
1,171
star
5

wpunix

WordPerfect for UNIX Character Terminals
C
615
star
6

rbndr

Simple DNS Rebinding Service
C
613
star
7

hotcorner

Tiny Hot Corners for Windows 10
C
380
star
8

nntpit

minimalist reddit2nntp gateway
C
231
star
9

rarvmtools

Minimal RarVM Toolchain
C
228
star
10

cefdebug

Minimal code to connect to a CEF debugger.
C
193
star
11

lotusdrv

Lotus 1-2-3 R4D Display Driver for DOSEMU
C
147
star
12

kiewtai

A port of Kaitai to the Hiew hex editor
C
144
star
13

sharapi

Simpsons: Hit & Run JavaScript API
JavaScript
112
star
14

swisstable

Access Abseil Swiss Tables from C
C
103
star
15

dbusmap

This is a simple utility for enumerating D-Bus endpoints, an nmap for D-Bus.
C
76
star
16

scanlimits

Tool to examine the behaviour of setuid binaries under constrained limits.
C
62
star
17

katamascii

An ascii-art physics puzzle, roll around your terminal collecting ascii-art objects!
C
43
star
18

timex

A hello world for the timex m851
C
31
star
19

minirun

Run commands with hidden console.
C
30
star
20

iknowthis

iknowthis Linux SystemCall Fuzzer
C
20
star
21

hiewdocs

Documentation and notes on using the Hiew editor.
HTML
17
star
22

mpgravity

MicroPlanet Gravity
C++
14
star
23

nssecurity

Netscape Plugin Security
C
8
star
24

defermap

Add a server mode to X11 clients
C
7
star
25

hiewkey

Keyboard helper for Hiew
C
4
star
26

wpdfilter

Enable Windows to Index WordPerfect UNIX Documents
C++
3
star
27

ncpro

Commandline Interface to NoteCase Pro
Shell
1
star
28

stfjson

Convert Lotus Agenda STF files to JSON
C
1
star