<s>
A	O
web	O
shell	O
is	O
a	O
shell-like	B-Operating_System
interface	I-Operating_System
that	O
enables	O
a	O
web	B-Application
server	I-Application
to	O
be	O
remotely	O
accessed	O
,	O
often	O
for	O
the	O
purposes	O
of	O
cyberattacks	O
.	O
</s>
<s>
A	O
web	O
shell	O
is	O
unique	O
in	O
that	O
a	O
web	B-Application
browser	I-Application
is	O
used	O
to	O
interact	O
with	O
it	O
.	O
</s>
<s>
Web	O
shells	O
are	O
most	O
commonly	O
written	O
in	O
the	O
PHP	B-Application
programming	I-Application
language	I-Application
due	O
to	O
the	O
widespread	O
usage	O
of	O
PHP	B-Application
for	O
web	B-Application
applications	I-Application
.	O
</s>
<s>
However	O
,	O
Active	B-General_Concept
Server	I-General_Concept
Pages	I-General_Concept
,	O
ASP.NET	B-Application
,	O
Python	B-Language
,	O
Perl	B-Language
,	O
Ruby	B-Language
,	O
and	O
Unix	B-Application
shell	I-Application
scripts	O
are	O
also	O
used	O
,	O
although	O
these	O
languages	O
are	O
less	O
commonly	O
used	O
.	O
</s>
<s>
These	O
vulnerabilities	O
are	O
often	O
present	O
in	O
applications	O
that	O
are	O
run	O
on	O
a	O
web	B-Application
server	I-Application
.	O
</s>
<s>
An	O
attacker	O
can	O
use	O
a	O
web	O
shell	O
to	O
issue	O
shell	O
commands	O
,	O
perform	O
privilege	O
escalation	O
on	O
the	O
web	B-Application
server	I-Application
,	O
and	O
the	O
ability	O
to	O
upload	B-Application
,	O
delete	O
,	O
download	B-Application
,	O
and	O
execute	B-General_Concept
files	O
to	O
and	O
from	O
the	O
web	B-Application
server	I-Application
.	O
</s>
<s>
To	O
use	O
as	O
command	O
and	O
control	O
base	O
,	O
for	O
example	O
as	O
a	O
bot	O
in	O
a	O
botnet	B-Architecture
system	O
or	O
in	O
way	O
to	O
compromise	O
the	O
security	O
of	O
additional	O
external	O
networks	O
.	O
</s>
<s>
Web	O
shells	O
are	O
installed	O
through	O
vulnerabilities	O
in	O
web	B-Application
application	I-Application
or	O
weak	O
server	O
security	O
configuration	O
including	O
the	O
following	O
:	O
</s>
<s>
SQL	B-Language
injection	I-Language
;	O
</s>
<s>
web	B-Application
server	I-Application
software	O
such	O
as	O
NGINX	B-Operating_System
or	O
content	B-Protocol
management	I-Protocol
system	I-Protocol
applications	O
such	O
as	O
WordPress	B-Application
)	O
;	O
</s>
<s>
File	O
processing	O
and	O
uploading	B-Application
vulnerabilities	O
,	O
which	O
can	O
be	O
mitigated	O
by	O
e.g.	O
</s>
<s>
limiting	O
the	O
file	O
types	O
that	O
can	O
be	O
uploaded	B-Application
;	O
</s>
<s>
Remote	B-Protocol
file	I-Protocol
inclusion	I-Protocol
(	O
RFI	O
)	O
and	O
local	O
file	O
inclusion	O
(	O
LFI	O
)	O
vulnerabilities	O
;	O
</s>
<s>
An	O
attacker	O
may	O
also	O
modify	O
(	O
spoof	O
)	O
the	O
Content-Type	O
header	O
to	O
be	O
sent	O
by	O
the	O
attacker	O
in	O
a	O
file	B-Application
upload	I-Application
to	O
bypass	O
improper	O
file	O
validation	O
(	O
validation	O
using	O
MIME	O
type	O
sent	O
by	O
the	O
client	O
)	O
,	O
which	O
will	O
result	O
in	O
a	O
successful	O
upload	B-Application
of	O
the	O
attacker	O
's	O
shell	O
.	O
</s>
<s>
The	O
following	O
is	O
a	O
simple	O
example	O
of	O
a	O
web	O
shell	O
written	O
in	O
PHP	B-Application
that	O
executes	O
and	O
outputs	O
the	O
result	O
of	O
a	O
shell	O
command	O
:	O
</s>
<s>
Assuming	O
the	O
filename	O
is	O
example.php	O
,	O
an	O
example	O
that	O
would	O
output	O
the	O
contents	O
of	O
the	O
/etc/passwd	O
file	O
is	O
shown	O
below	O
:	O
</s>
<s>
The	O
above	O
request	O
will	O
take	O
the	O
value	O
of	O
the	O
x	O
parameter	O
of	O
the	O
query	B-Protocol
string	I-Protocol
,	O
sending	O
the	O
following	O
shell	O
command	O
:	O
</s>
<s>
This	O
could	O
have	O
been	O
prevented	O
if	O
the	O
shell	O
functions	O
of	O
PHP	B-Application
were	O
disabled	O
so	O
that	O
arbitrary	O
shell	O
commands	O
cannot	O
be	O
executed	O
from	O
PHP	B-Application
.	O
</s>
<s>
A	O
web	O
shell	O
is	O
usually	O
installed	O
by	O
taking	O
advantage	O
of	O
vulnerabilities	O
present	O
in	O
the	O
web	B-Application
server	I-Application
's	O
software	O
.	O
</s>
<s>
That	O
is	O
why	O
removal	O
of	O
these	O
vulnerabilities	O
is	O
important	O
to	O
avoid	O
the	O
potential	O
risk	O
of	O
a	O
compromised	O
web	B-Application
server	I-Application
.	O
</s>
<s>
Web	O
shells	O
can	O
be	O
easily	O
modified	O
,	O
so	O
it	O
's	O
not	O
easy	O
to	O
detect	O
web	O
shells	O
and	O
antivirus	B-Application
software	I-Application
are	O
often	O
not	O
able	O
to	O
detect	O
web	O
shells	O
.	O
</s>
<s>
The	O
following	O
are	O
common	O
indicators	O
that	O
a	O
web	O
shell	O
is	O
present	O
on	O
a	O
web	B-Application
server	I-Application
:	O
</s>
<s>
Abnormal	O
high	O
web	B-Application
server	I-Application
usage	O
(	O
due	O
to	O
heavy	O
downloading	B-Application
and	O
uploading	B-Application
by	O
the	O
attacker	O
)	O
;	O
</s>
<s>
Unknown	O
files	O
in	O
a	O
web	B-Application
server	I-Application
;	O
</s>
<s>
a	O
PNG	O
file	O
requesting	O
with	O
POST	B-Protocol
parameters	O
)	O
.	O
</s>
<s>
Dubious	O
logins	O
from	O
DMZ	B-General_Concept
servers	O
to	O
internal	O
sub-nets	O
and	O
vice	O
versa	O
.	O
</s>
<s>
Web	O
shells	O
may	O
also	O
contain	O
a	O
login	O
form	O
,	O
which	O
is	O
often	O
disguised	O
as	O
an	O
error	B-Protocol
page	I-Protocol
.	O
</s>
<s>
Using	O
web	O
shells	O
,	O
adversaries	O
can	O
modify	O
the	O
.htaccess	B-Protocol
file	O
(	O
on	O
servers	O
running	O
the	O
Apache	B-Application
HTTP	I-Application
Server	I-Application
software	O
)	O
on	O
web	B-Application
servers	I-Application
to	O
redirect	O
search	B-Application
engine	I-Application
requests	O
to	O
the	O
web	O
page	O
with	O
malware	O
or	O
spam	O
.	O
</s>
<s>
Often	O
web	O
shells	O
detect	O
the	O
user-agent	B-Protocol
and	O
the	O
content	O
presented	O
to	O
the	O
search	B-Application
engine	I-Application
spider	I-Application
is	O
different	O
from	O
that	O
presented	O
to	O
the	O
user	O
's	O
browser	B-Application
.	O
</s>
<s>
To	O
find	O
a	O
web	O
shell	O
a	O
user-agent	B-Protocol
change	O
of	O
the	O
crawler	O
bot	O
is	O
usually	O
required	O
.	O
</s>
<s>
Analyzing	O
the	O
web	B-Application
server	I-Application
's	O
log	O
could	O
specify	O
the	O
exact	O
location	O
of	O
the	O
web	O
shell	O
.	O
</s>
<s>
Legitimate	O
users/visitor	O
usually	O
have	O
different	O
user-agents	B-Protocol
and	O
referers	B-Protocol
,	O
on	O
the	O
other	O
hand	O
,	O
a	O
web	O
shell	O
is	O
usually	O
only	O
visited	O
by	O
the	O
attacker	O
,	O
therefore	O
have	O
very	O
few	O
variants	O
of	O
user-agent	B-Protocol
strings	O
.	O
</s>
