Compare commits
65 commits
Author | SHA1 | Date | |
---|---|---|---|
|
82caba2f37 | ||
|
e73021f2f3 | ||
|
6b5862fba1 | ||
|
50fba1b2f1 | ||
|
15de28e37b | ||
|
d3a93f8081 | ||
|
39b42fb6e4 | ||
|
1510811a68 | ||
|
e7ba13e13d | ||
|
0edee2c12c | ||
|
ae78622a58 | ||
|
81695461b4 | ||
|
5c5c01ed10 | ||
|
08d6a40b85 | ||
|
456303fce5 | ||
|
5c7fb5cde2 | ||
|
05b2d3630c | ||
|
d0d8c58882 | ||
|
d4bd77ca45 | ||
|
8e28bb4c2a | ||
|
f408467088 | ||
|
e6c25e84bc | ||
|
cbac76e579 | ||
|
6e475e9686 | ||
|
af162e282a | ||
|
78bed3070b | ||
|
863a8d91c7 | ||
|
628d41f32c | ||
|
e05c6d8178 | ||
|
fb262fb521 | ||
|
1558412cee | ||
|
0f1e9ba31c | ||
|
d34d5db9d9 | ||
|
048cecd2e7 | ||
|
c8b6a3eddb | ||
|
25425bad31 | ||
|
30e293d602 | ||
|
ee57908b49 | ||
|
b778806356 | ||
|
8fd68e147c | ||
|
2034ae1ee5 | ||
|
490cfa0344 | ||
|
f17bc266f8 | ||
|
790d578cc2 | ||
|
0c8c295c1a | ||
|
141e641238 | ||
|
2c93404bd0 | ||
|
4911d0d39c | ||
|
d8ef7dad3c | ||
|
dd9f1f01d1 | ||
|
1a8010f2c9 | ||
|
8a68194da2 | ||
|
e026df75b0 | ||
|
4aa0eb97e4 | ||
|
aaa00551bf | ||
|
106bc0aa85 | ||
|
f67073d33e | ||
|
c87588613a | ||
|
e30c33d323 | ||
|
973f1527bd | ||
|
cde2e92378 | ||
|
7dd9d4300c | ||
|
b58542eb99 | ||
|
8d3c5cdc3d | ||
|
09e790bb27 |
1
.gitignore
vendored
Normal file → Executable file
|
@ -9,6 +9,7 @@ aclocal.m4
|
|||
autom4te.cache
|
||||
certificate.pem
|
||||
compile
|
||||
config.cache
|
||||
config.guess
|
||||
config.h
|
||||
config.h.in
|
||||
|
|
0
AUTHORS
Normal file → Executable file
0
CHANGELOG.md
Normal file → Executable file
0
COPYING
Normal file → Executable file
0
GPL-2
Normal file → Executable file
2
INSTALL.Debian
Normal file → Executable file
|
@ -41,7 +41,7 @@ you point your browser to the site.
|
|||
|
||||
At the very least, you need a file called "certificate.pem" that includes
|
||||
both the private key and the public certificate in PEM (i.e. ASCII) format.
|
||||
Additionally, you should create files for each of the publically visible
|
||||
Additionally, you should create files for each of the publicly visible
|
||||
hostnames that your machine has. These are named "certificate-${FQDN}.pem".
|
||||
You probably also want "certificate-localhost.pem".
|
||||
|
||||
|
|
9
Makefile.am
Normal file → Executable file
|
@ -242,7 +242,8 @@ shellinaboxd.1: ${top_srcdir}/shellinabox/shellinaboxd.man.in \
|
|||
|
||||
clean-local: clean-demo
|
||||
-rm -rf shellinaboxd.1 \
|
||||
shellinaboxd.ps
|
||||
shellinaboxd.ps \
|
||||
shellinaboxd.pdf
|
||||
-rm -rf debian/shellinabox \
|
||||
debian/shellinabox*.debhelper* \
|
||||
debian/shellinabox.substvars \
|
||||
|
@ -364,3 +365,9 @@ clean-demo:
|
|||
"(int)sizeof($${sym}Start);"; \
|
||||
} >"$@"
|
||||
|
||||
shellinaboxd.ps: shellinaboxd.1
|
||||
groff -man -T ps $^ >$@
|
||||
|
||||
shellinaboxd.pdf: shellinaboxd.ps
|
||||
ps2pdf $^ $@
|
||||
|
||||
|
|
0
NEWS
Normal file → Executable file
0
README
Normal file → Executable file
0
README.Fedora
Normal file → Executable file
59
README.md
Normal file → Executable file
|
@ -6,16 +6,16 @@ shellinabox
|
|||
[](https://gitter.im/shellinabox/shellinabox?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
|
||||
|
||||
This is unofficial fork of project **Shell In A Box**. Fork was created because
|
||||
original project is not maintained anymore and we cannot contact original
|
||||
This is an unofficial fork of the project **Shell In A Box**. The fork was created because
|
||||
the original project was not maintained anymore and we cannot contact the original
|
||||
repository owners.
|
||||
|
||||
Our aim is to continue with maintanince of shellinabox project. For list of
|
||||
recent changes please see [CHANGELOG.md](/CHANGELOG.md).
|
||||
Our aim is to continue with maintenance of the shellinabox project. For a list of
|
||||
recent changes, please see [CHANGELOG.md](/CHANGELOG.md).
|
||||
|
||||
If you have any questions, issues or patches, please fell free to submit pull
|
||||
request or report an issue. You can also drop an email to original project
|
||||
[issue #261](https://code.google.com/p/shellinabox/issues/detail?id=261) discusion
|
||||
If you have any questions, issues, or patches, please feel free to submit a pull
|
||||
request or report an issue. You can also drop an email to the original project
|
||||
[issue #261](https://code.google.com/p/shellinabox/issues/detail?id=261) discussion
|
||||
from where this fork started.
|
||||
|
||||
|
||||
|
@ -27,7 +27,7 @@ tools to a web based terminal emulator. This emulator is accessible to any
|
|||
JavaScript and CSS enabled web browser and does not require any additional
|
||||
browser plugins.
|
||||
|
||||

|
||||

|
||||
|
||||
More information:
|
||||
|
||||
|
@ -42,34 +42,17 @@ Build
|
|||
For building **shellinabox** from source on Debian or RHEL based systems use commands
|
||||
listed below. This will create executable file `shellinaboxd` in project directory.
|
||||
|
||||
1. Install dependencies
|
||||
1. Clone the autotools
|
||||
|
||||
```
|
||||
apt-get install git libssl-dev libpam0g-dev zlib1g-dev dh-autoreconf
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```
|
||||
yum install git openssl-devel pam-devel zlib-devel autoconf automake libtool
|
||||
wget https://raw.githubusercontent.com/simono41/shellinabox/master/auto.sh
|
||||
```
|
||||
|
||||
2. Clone source files and move to project directory
|
||||
3. Run autotools
|
||||
|
||||
```
|
||||
git clone https://github.com/shellinabox/shellinabox.git && cd shellinabox
|
||||
```
|
||||
|
||||
3. Run autotools in project directory
|
||||
|
||||
```
|
||||
autoreconf -i
|
||||
```
|
||||
|
||||
4. Run configure and make in project directory
|
||||
|
||||
```
|
||||
./configure && make
|
||||
chmod +x auto.sh
|
||||
./auto.sh
|
||||
```
|
||||
|
||||
#### Debian package
|
||||
|
@ -103,5 +86,19 @@ created from our sources. In new issue report please include following things:
|
|||
* Version of shellinabox
|
||||
* Steps to reproduce the problem
|
||||
|
||||
Also feel free to post any questions or comments in [shellianbox chat room](https://gitter.im/shellinabox/shellinabox)
|
||||
Also feel free to post any questions or comments in [shellinabox chat room](https://gitter.im/shellinabox/shellinabox)
|
||||
on Gitter.
|
||||
|
||||
|
||||
Known Issues
|
||||
------------
|
||||
|
||||
* The openssl package is required for HTTP/SSL support.
|
||||
Shell-in-a-box may be used without SSL such that the login session
|
||||
is not encrypted. To enable automatic creation of self-signed
|
||||
certificates or to use a generated certificate, install openssl.
|
||||
|
||||
* On Debian Jessie, the default openssl package does not include the
|
||||
utilities necessary for Shell-in-a-box to generate self-signed
|
||||
certificates. Upgrade openssl to install a version of the tools
|
||||
that support certificate creation.
|
||||
|
|
0
TODO
Normal file → Executable file
56
auto.sh
Executable file
|
@ -0,0 +1,56 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -ex
|
||||
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
echo "This script must be run as root" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
echo "Als root Angemeldet"
|
||||
|
||||
if [ -f /usr/bin/apt ]; then
|
||||
apt update
|
||||
|
||||
apt install git libssl-dev libpam0g-dev zlib1g-dev dh-autoreconf
|
||||
fi
|
||||
|
||||
if [ -f /usr/bin/pacman ]; then
|
||||
pacman -Sy git openssl autoconf automake make gcc
|
||||
fi
|
||||
|
||||
cd /opt/
|
||||
|
||||
git clone https://github.com/simono41/shellinabox.git
|
||||
|
||||
cd shellinabox
|
||||
|
||||
autoreconf -i
|
||||
|
||||
./configure && make
|
||||
|
||||
cp shellinabox.service /etc/systemd/system/
|
||||
|
||||
systemctl daemon-reload
|
||||
|
||||
systemctl enable shellinabox.service
|
||||
|
||||
# adduser
|
||||
|
||||
echo adduser webssh
|
||||
|
||||
useradd webssh
|
||||
|
||||
mkdir /home/webssh
|
||||
|
||||
cp shellinabox_sshwrapper.sh /home/webssh/
|
||||
|
||||
chmod 770 -R /home/webssh/
|
||||
|
||||
chown -cR webssh:webssh /home/webssh/
|
||||
|
||||
passwd webssh <<EOT
|
||||
webssh
|
||||
webssh
|
||||
EOT
|
||||
|
||||
systemctl start shellinabox.service &
|
35
configure.ac
Normal file → Executable file
|
@ -2,7 +2,7 @@ AC_PREREQ(2.57)
|
|||
|
||||
dnl This is one of the locations where the authoritative version
|
||||
dnl number is stored. The other is in the debian/changelog.
|
||||
AC_INIT(shellinabox, 2.18, markus@shellinabox.com)
|
||||
AC_INIT(shellinabox, 2.20, markus@shellinabox.com)
|
||||
if test -e .git; then
|
||||
VCS_REVISION=" (revision `cd $srcdir && git log -1 --format=format:%h`)"
|
||||
else
|
||||
|
@ -32,7 +32,7 @@ AC_SUBST(AR_FLAGS, [cr])
|
|||
|
||||
dnl Check for header files that do not exist on all platforms
|
||||
AC_CHECK_HEADERS([libutil.h pthread.h pty.h strings.h syslog.h sys/prctl.h \
|
||||
sys/uio.h util.h utmp.h utmpx.h])
|
||||
sys/uio.h util.h])
|
||||
|
||||
dnl Most systems require linking against libutil.so in order to get login_tty()
|
||||
AC_CHECK_FUNCS(login_tty, [],
|
||||
|
@ -75,15 +75,6 @@ AC_TRY_LINK([#include <math.h>],
|
|||
[AC_DEFINE(HAVE_ISNAN, 1,
|
||||
Define to 1 if you have support for isnan)])
|
||||
|
||||
dnl Even if utmpx.h exists, not all systems have support for updwtmpx()
|
||||
AC_TRY_LINK([#include <utmp.h>],
|
||||
[updwtmp(0, 0);],
|
||||
[AC_DEFINE(HAVE_UPDWTMP, 1,
|
||||
Define to 1 if you have support for updwtmp)])
|
||||
AC_TRY_LINK([#include <utmpx.h>],
|
||||
[updwtmpx(0, 0);],
|
||||
[AC_DEFINE(HAVE_UPDWTMPX, 1,
|
||||
Define to 1 if you have support for updwtmpx)])
|
||||
|
||||
dnl Check if the compiler supports aliasing of symbols
|
||||
AC_TRY_LINK([void x(void) { };
|
||||
|
@ -147,6 +138,28 @@ AC_ARG_ENABLE(runtime-loading,
|
|||
these libraries into the binary, thus making them a
|
||||
hard dependency, then disable runtime-loading.])
|
||||
|
||||
dnl This is feature is not suported in some standard C libs. So users can use
|
||||
dnl this switch to avoid compile and runtime problems. Note that utmp must
|
||||
dnl disabled on systems with musl libc.
|
||||
AC_ARG_ENABLE(utmp,
|
||||
[ --disable-utmp Disable support for login records. Note
|
||||
that for systems with musl libc utmp must
|
||||
be disabled.])
|
||||
|
||||
if test "x$enable_utmp" != xno; then
|
||||
AC_CHECK_HEADERS([utmp.h utmpx.h])
|
||||
|
||||
dnl Even if utmpx.h exists, not all systems have support for updwtmpx()
|
||||
AC_TRY_LINK([#include <utmp.h>],
|
||||
[updwtmp(0, 0);],
|
||||
[AC_DEFINE(HAVE_UPDWTMP, 1,
|
||||
Define to 1 if you have support for updwtmp)])
|
||||
AC_TRY_LINK([#include <utmpx.h>],
|
||||
[updwtmpx(0, 0);],
|
||||
[AC_DEFINE(HAVE_UPDWTMPX, 1,
|
||||
Define to 1 if you have support for updwtmpx)])
|
||||
fi
|
||||
|
||||
dnl Only test for OpenSSL headers, if not explicitly disabled
|
||||
if test "x$enable_ssl" != xno; then
|
||||
AC_CHECK_HEADERS([openssl/bio.h openssl/err.h openssl/ssl.h])
|
||||
|
|
0
contrib/README-siab.rb
Normal file → Executable file
0
contrib/siab.rb
Normal file → Executable file
0
debian/README.available
vendored
Normal file → Executable file
0
debian/README.enabled
vendored
Normal file → Executable file
0
debian/README.source
vendored
Normal file → Executable file
47
debian/changelog
vendored
Normal file → Executable file
|
@ -1,3 +1,50 @@
|
|||
shellinabox (2.20) unstable; urgency=medium
|
||||
|
||||
* Fixed issue #222, LOGIN service
|
||||
* Fixed issue #360, ignore escape sequences to fix dir listing
|
||||
* Fix for function key presses
|
||||
* Adjusting scale on IE
|
||||
* New option to disable peer check (#364)
|
||||
* Add option for custom SSH port
|
||||
* Support for APL characters
|
||||
* PDF documentation
|
||||
* Fix for BSD build
|
||||
* New ready event support
|
||||
* OpenSSL 1.1 fixes (Closes: #828542)
|
||||
* May build with MUSL library
|
||||
* Documentation added that SSL support is optional and requires
|
||||
installation of openssl on Debian. (Closes: #839067)
|
||||
* Jessie requires explicit installation of openssl because the default
|
||||
package does not include the necessary utilities to support creation
|
||||
of certificates. (Closes: #839066)
|
||||
|
||||
-- Marc Singer <elf@debian.org> Wed, 09 Nov 2016 09:52:24 -0800
|
||||
|
||||
shellinabox (2.19) unstable; urgency=high
|
||||
|
||||
* Added support for middle-click paste, #350.
|
||||
* Improved iOS support, #354.
|
||||
* New logic to enable soft keyboard icon, #119, #321, #354.
|
||||
* Disable HTTP fallback using the URL /plain. Consequently disables
|
||||
automatic upgrades from HTTP to HTTPS, #355. (CVE-2015-8400).
|
||||
|
||||
-- Marc Singer <elf@debian.org> Sat, 05 Dec 2015 10:24:12 -0800
|
||||
|
||||
shellinabox (2.18) unstable; urgency=low
|
||||
|
||||
* Fixed reverse vide rendering, #341.
|
||||
* Using stdout for version information, #344.
|
||||
* Added CGI session key in HTTP response.
|
||||
* Child process cleanup, #103.
|
||||
* Merged #340.
|
||||
* Autoconf updates.
|
||||
* Disabled utmp logging.
|
||||
* Merge #338, killing children with HUP.
|
||||
* Fixed handling of large HTTP requests.
|
||||
* Enhanced logging clarity with prefix.
|
||||
|
||||
-- Marc Singer <elf@debian.org> Sat, 10 Oct 2015 10:53:38 -0700
|
||||
|
||||
shellinabox (2.17) unstable; urgency=medium
|
||||
|
||||
* Generally, SSL updates.
|
||||
|
|
0
debian/compat
vendored
Normal file → Executable file
6
debian/control
vendored
Normal file → Executable file
|
@ -16,5 +16,7 @@ Suggests: openssl
|
|||
Description: publish command line shell through AJAX interface
|
||||
Shellinabox can export arbitrary command line programs to any JavaScript
|
||||
enabled web browser. By default, it prompts for username and password
|
||||
and then exports a SSL/TLS encrypted login shell. Shellinabox provides
|
||||
a VT100 compatible terminal emulator that runs within any modern browser.
|
||||
and then exports a login shell. Shellinabox provides a VT100
|
||||
compatible terminal emulator that runs within any modern
|
||||
browser. Support for HTTPS protocol (SSL/TLS encryption) is optional
|
||||
and requires installation of openssl.
|
||||
|
|
0
debian/copyright
vendored
Normal file → Executable file
0
debian/docs
vendored
Normal file → Executable file
0
debian/shellinabox.default
vendored
Normal file → Executable file
0
debian/shellinabox.dirs
vendored
Normal file → Executable file
0
debian/shellinabox.examples
vendored
Normal file → Executable file
0
debian/shellinabox.lintian-overrides
vendored
Normal file → Executable file
0
debian/shellinabox.preinst
vendored
Normal file → Executable file
0
debian/shellinabox.prerm
vendored
Normal file → Executable file
0
debian/source/format
vendored
Normal file → Executable file
0
debian/source/include-binaries
vendored
Normal file → Executable file
0
debian/source/options
vendored
Normal file → Executable file
0
demo/demo.html
Normal file → Executable file
0
demo/demo.jspp
Normal file → Executable file
0
demo/demo.xml
Normal file → Executable file
0
demo/keyboard.html
Normal file → Executable file
0
etc-pam.d-shellinabox-example
Normal file → Executable file
0
libhttp/hashmap.c
Normal file → Executable file
0
libhttp/hashmap.h
Normal file → Executable file
2
libhttp/http.h
Normal file → Executable file
|
@ -102,7 +102,7 @@ short serverConnectionSetEvents(Server *server, ServerConnection *connection,
|
|||
void serverExitLoop(Server *server, int exitAll);
|
||||
void serverLoop(Server *server);
|
||||
int serverSupportsSSL();
|
||||
void serverEnableSSL(Server *server, int flag);
|
||||
void serverSetupSSL(Server *server, int enable, int force);
|
||||
void serverSetCertificate(Server *server, const char *filename,
|
||||
int autoGenerateMissing);
|
||||
void serverSetCertificateFd(Server *server, int fd);
|
||||
|
|
9
libhttp/httpconnection.c
Normal file → Executable file
|
@ -430,7 +430,7 @@ void destroyHttpConnection(struct HttpConnection *http) {
|
|||
http->peerName ? http->peerName : "???", http->peerPort);
|
||||
}
|
||||
httpShutdown(http, http->closed ? SHUT_WR : SHUT_RDWR);
|
||||
dcheck(!close(http->fd));
|
||||
dcheck(!close(http->fd) || errno != EBADF);
|
||||
free(http->peerName);
|
||||
free(http->url);
|
||||
free(http->method);
|
||||
|
@ -1480,6 +1480,13 @@ int httpHandleConnection(struct ServerConnection *connection, void *http_,
|
|||
*events |= POLLIN;
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if (http->ssl && http->ssl->enabled && http->ssl->force) {
|
||||
debug("[http] Non-SSL connections not allowed!");
|
||||
httpCloseRead(http);
|
||||
bytes = 0;
|
||||
eof = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
0
libhttp/httpconnection.h
Normal file → Executable file
0
libhttp/libhttp.sym
Normal file → Executable file
7
libhttp/server.c
Normal file → Executable file
|
@ -670,11 +670,12 @@ void serverLoop(struct Server *server) {
|
|||
server->looping = loopDepth - 1;
|
||||
}
|
||||
|
||||
void serverEnableSSL(struct Server *server, int flag) {
|
||||
if (flag) {
|
||||
void serverSetupSSL(struct Server *server, int enable, int force) {
|
||||
if (enable) {
|
||||
check(serverSupportsSSL());
|
||||
}
|
||||
sslEnable(&server->ssl, flag);
|
||||
sslEnable(&server->ssl, enable);
|
||||
sslForce(&server->ssl, force);
|
||||
}
|
||||
|
||||
void serverSetCertificate(struct Server *server, const char *filename,
|
||||
|
|
2
libhttp/server.h
Normal file → Executable file
|
@ -118,7 +118,7 @@ short serverConnectionSetEvents(struct Server *server,
|
|||
short events);
|
||||
void serverExitLoop(struct Server *server, int exitAll);
|
||||
void serverLoop(struct Server *server);
|
||||
void serverEnableSSL(struct Server *server, int flag);
|
||||
void serverSetupSSL(struct Server *server, int enable, int force);
|
||||
void serverSetCertificate(struct Server *server, const char *filename,
|
||||
int autoGenerateMissing);
|
||||
void serverSetCertificateFd(struct Server *server, int fd);
|
||||
|
|
50
libhttp/ssl.c
Normal file → Executable file
|
@ -100,6 +100,7 @@ BIO_METHOD * (*BIO_f_buffer)(void);
|
|||
void (*BIO_free_all)(BIO *);
|
||||
BIO * (*BIO_new)(BIO_METHOD *);
|
||||
BIO * (*BIO_new_socket)(int, int);
|
||||
BIO * (*BIO_next)(BIO *);
|
||||
BIO * (*BIO_pop)(BIO *);
|
||||
BIO * (*BIO_push)(BIO *, BIO *);
|
||||
#if defined(HAVE_OPENSSL_EC)
|
||||
|
@ -167,6 +168,7 @@ struct SSLSupport *newSSL(void) {
|
|||
|
||||
void initSSL(struct SSLSupport *ssl) {
|
||||
ssl->enabled = serverSupportsSSL();
|
||||
ssl->force = 0;
|
||||
ssl->sslContext = NULL;
|
||||
ssl->sniCertificatePattern = NULL;
|
||||
ssl->generateMissing = 0;
|
||||
|
@ -279,6 +281,7 @@ static void loadSSL(void) {
|
|||
{ { &BIO_free_all }, "BIO_free_all" },
|
||||
{ { &BIO_new }, "BIO_new" },
|
||||
{ { &BIO_new_socket }, "BIO_new_socket" },
|
||||
{ { &BIO_next }, "BIO_next" },
|
||||
{ { &BIO_pop }, "BIO_pop" },
|
||||
{ { &BIO_push }, "BIO_push" },
|
||||
{ { &ERR_clear_error }, "ERR_clear_error" },
|
||||
|
@ -410,7 +413,7 @@ static void sslGenerateCertificate(const char *certificate,
|
|||
if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) {
|
||||
warn("[ssl] Failed to generate self-signed certificate \"%s\"!", certificate);
|
||||
} else {
|
||||
info("[ssl] Certificate succesfully generated.");
|
||||
info("[ssl] Certificate successfully generated.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -674,7 +677,7 @@ static SSL_CTX *sslMakeContext(void) {
|
|||
|
||||
SSL_CTX_set_info_callback(context, sslInfoCallback);
|
||||
|
||||
debug("[ssl] Server context succesfully initialized...");
|
||||
debug("[ssl] Server context successfully initialized...");
|
||||
return context;
|
||||
}
|
||||
#endif
|
||||
|
@ -894,6 +897,12 @@ int sslEnable(struct SSLSupport *ssl, int enabled) {
|
|||
return old;
|
||||
}
|
||||
|
||||
int sslForce(struct SSLSupport *ssl, int force) {
|
||||
int old = ssl->force;
|
||||
ssl->force = force;
|
||||
return old;
|
||||
}
|
||||
|
||||
void sslBlockSigPipe(void) {
|
||||
sigset_t set;
|
||||
sigemptyset(&set);
|
||||
|
@ -1006,6 +1015,14 @@ int sslPromoteToSSL(struct SSLSupport *ssl, SSL **sslHndl, int fd,
|
|||
#endif
|
||||
}
|
||||
|
||||
BIO *sslGetNextBIO(BIO *b) {
|
||||
#if OPENSSL_VERSION_NUMBER <= 0x10100000L
|
||||
return b->next_bio;
|
||||
#else
|
||||
return BIO_next(b);
|
||||
#endif
|
||||
}
|
||||
|
||||
void sslFreeHndl(SSL **sslHndl) {
|
||||
#if defined(HAVE_OPENSSL)
|
||||
if (*sslHndl) {
|
||||
|
@ -1013,24 +1030,23 @@ void sslFreeHndl(SSL **sslHndl) {
|
|||
// BIOs. This is particularly a problem if an SSL connection has two
|
||||
// different BIOs for the read and the write end, with one being a stacked
|
||||
// derivative of the other. Unfortunately, this is exactly the scenario
|
||||
// that we set up.
|
||||
// that we set up with call to "BIO_push(readBIO, writeBIO)" in function
|
||||
// "sslPromoteToSSL()".
|
||||
// As a work-around, we un-stack the BIOs prior to freeing the SSL
|
||||
// connection.
|
||||
debug("[ssl] Freeing SSL handle.");
|
||||
ERR_clear_error();
|
||||
BIO *writeBIO, *readBIO;
|
||||
check(writeBIO = SSL_get_wbio(*sslHndl));
|
||||
check(readBIO = SSL_get_rbio(*sslHndl));
|
||||
if (writeBIO != readBIO) {
|
||||
if (readBIO->next_bio == writeBIO) {
|
||||
// OK, that's exactly the bug we are looking for. We know how to
|
||||
// fix it.
|
||||
if (sslGetNextBIO(readBIO) == writeBIO) {
|
||||
// OK, that's exactly the bug we are looking for. We know that
|
||||
// writeBIO needs to be removed from readBIO chain.
|
||||
debug("[ssl] Removing stacked write BIO!");
|
||||
check(BIO_pop(readBIO) == writeBIO);
|
||||
check(readBIO->references == 1);
|
||||
check(writeBIO->references == 1);
|
||||
check(!readBIO->next_bio);
|
||||
check(!writeBIO->prev_bio);
|
||||
} else if (readBIO->next_bio == writeBIO->next_bio &&
|
||||
writeBIO->next_bio->prev_bio == writeBIO) {
|
||||
check(!sslGetNextBIO(readBIO));
|
||||
} else if (sslGetNextBIO(readBIO) == sslGetNextBIO(writeBIO)) {
|
||||
// Things get even more confused, if the SSL handshake is aborted
|
||||
// prematurely.
|
||||
// OpenSSL appears to internally stack a BIO onto the read end that
|
||||
|
@ -1039,15 +1055,13 @@ void sslFreeHndl(SSL **sslHndl) {
|
|||
// reading and one for writing). In this case, not only is the
|
||||
// reference count wrong, but the chain of next_bio/prev_bio pairs
|
||||
// is corrupted, too.
|
||||
warn("[ssl] Removing stacked socket BIO!");
|
||||
BIO *sockBIO;
|
||||
check(sockBIO = BIO_pop(readBIO));
|
||||
check(sockBIO == BIO_pop(writeBIO));
|
||||
check(readBIO->references == 1);
|
||||
check(writeBIO->references == 1);
|
||||
check(sockBIO->references == 1);
|
||||
check(!readBIO->next_bio);
|
||||
check(!writeBIO->next_bio);
|
||||
check(!sockBIO->prev_bio);
|
||||
check(!sslGetNextBIO(readBIO));
|
||||
check(!sslGetNextBIO(writeBIO));
|
||||
check(!sslGetNextBIO(sockBIO));
|
||||
BIO_free_all(sockBIO);
|
||||
} else {
|
||||
// We do not know, how to fix this situation. Something must have
|
||||
|
|
4
libhttp/ssl.h
Normal file → Executable file
|
@ -82,6 +82,7 @@ extern BIO_METHOD *(*x_BIO_f_buffer)(void);
|
|||
extern void (*x_BIO_free_all)(BIO *);
|
||||
extern BIO *(*x_BIO_new)(BIO_METHOD *);
|
||||
extern BIO *(*x_BIO_new_socket)(int, int);
|
||||
extern BIO *(*x_BIO_next)(BIO *);
|
||||
extern BIO *(*x_BIO_pop)(BIO *);
|
||||
extern BIO *(*x_BIO_push)(BIO *, BIO *);
|
||||
#if defined(HAVE_OPENSSL_EC)
|
||||
|
@ -131,6 +132,7 @@ extern void *(*x_SSL_COMP_get_compression_methods)(void);
|
|||
#define BIO_free_all x_BIO_free_all
|
||||
#define BIO_new x_BIO_new
|
||||
#define BIO_new_socket x_BIO_new_socket
|
||||
#define BIO_next x_BIO_next
|
||||
#define BIO_pop x_BIO_pop
|
||||
#define BIO_push x_BIO_push
|
||||
#define EC_KEY_free x_EC_KEY_free
|
||||
|
@ -198,6 +200,7 @@ extern void *(*x_SSL_COMP_get_compression_methods)(void);
|
|||
|
||||
struct SSLSupport {
|
||||
int enabled;
|
||||
int force;
|
||||
SSL_CTX *sslContext;
|
||||
char *sniCertificatePattern;
|
||||
int generateMissing;
|
||||
|
@ -214,6 +217,7 @@ void sslSetCertificate(struct SSLSupport *ssl, const char *filename,
|
|||
int autoGenerateMissing);
|
||||
void sslSetCertificateFd(struct SSLSupport *ssl, int fd);
|
||||
int sslEnable(struct SSLSupport *ssl, int enabled);
|
||||
int sslForce(struct SSLSupport *ssl, int force);
|
||||
void sslBlockSigPipe();
|
||||
int sslUnblockSigPipe();
|
||||
int sslPromoteToSSL(struct SSLSupport *ssl, SSL **sslHndl, int fd,
|
||||
|
|
0
libhttp/trie.c
Normal file → Executable file
0
libhttp/trie.h
Normal file → Executable file
0
libhttp/url.c
Normal file → Executable file
0
libhttp/url.h
Normal file → Executable file
12
logging/logging.c
Normal file → Executable file
|
@ -100,7 +100,11 @@ void error(const char *fmt, ...) {
|
|||
va_start(ap, fmt);
|
||||
debugMsg(MSG_ERROR, fmt, ap);
|
||||
#ifdef HAVE_SYSLOG_H
|
||||
vsyslog(LOG_ERR, fmt, ap);
|
||||
va_list apSyslog;
|
||||
va_copy(apSyslog, ap);
|
||||
va_start(apSyslog, fmt);
|
||||
vsyslog(LOG_ERR, fmt, apSyslog);
|
||||
va_end(apSyslog);
|
||||
#endif
|
||||
va_end(ap);
|
||||
}
|
||||
|
@ -117,7 +121,11 @@ void fatal(const char *fmt, ...) {
|
|||
va_start(ap, fmt);
|
||||
debugMsg(MSG_QUIET, fmt, ap);
|
||||
#ifdef HAVE_SYSLOG_H
|
||||
vsyslog(LOG_CRIT, fmt, ap);
|
||||
va_list apSyslog;
|
||||
va_copy(apSyslog, ap);
|
||||
va_start(apSyslog, fmt);
|
||||
vsyslog(LOG_CRIT, fmt, apSyslog);
|
||||
va_end(apSyslog);
|
||||
syslog(LOG_CRIT, "[server] Aborting...");
|
||||
#endif
|
||||
va_end(ap);
|
||||
|
|
0
logging/logging.h
Normal file → Executable file
0
m4/.gitignore
vendored
Normal file → Executable file
23
misc/embedded.html
Normal file → Executable file
|
@ -14,7 +14,7 @@
|
|||
|
||||
For communication with Shell In A Box we need to set '-m' (messages-origin)
|
||||
command line option with appropriate messages origin. Origin should be set to
|
||||
URL of parent (this) window. If origin is set to '*' Shell In A Box won't checki
|
||||
URL of parent (this) window. If origin is set to '*' Shell In A Box won't check
|
||||
origin on received messages. This is usually unsafe option.
|
||||
|
||||
Command line example:
|
||||
|
@ -25,7 +25,7 @@
|
|||
# Client Side
|
||||
#
|
||||
|
||||
Shell In A Box accepts messages formated as JSON strings with 'type' and 'data'
|
||||
Shell In A Box accepts messages formatted as JSON strings with 'type' and 'data'
|
||||
fields. Messages with same format can be passed back to parent (this) window.
|
||||
|
||||
Message example:
|
||||
|
@ -59,6 +59,9 @@
|
|||
|
||||
Following types of messages can be received from shellinabox:
|
||||
|
||||
* ready
|
||||
signals that shellinabox is ready to send and receive messages
|
||||
|
||||
* output
|
||||
data field contains terminal output
|
||||
|
||||
|
@ -140,10 +143,6 @@
|
|||
var output = document.getElementById("output");
|
||||
var session = document.getElementById("session");
|
||||
|
||||
// Add url to our iframe. We do this, only that variable 'url' can be used
|
||||
// throughout the whole code where needed.
|
||||
iframe.src = url;
|
||||
|
||||
document.getElementById("execute").addEventListener("click", function() {
|
||||
// Send input to shellinabox
|
||||
var message = JSON.stringify({
|
||||
|
@ -209,6 +208,15 @@
|
|||
// Handle response according to response type
|
||||
var decoded = JSON.parse(message.data);
|
||||
switch (decoded.type) {
|
||||
case "ready":
|
||||
// Shellinabox is ready to communicate and we will enable console output
|
||||
// by default.
|
||||
var message = JSON.stringify({
|
||||
type : 'output',
|
||||
data : 'enable'
|
||||
});
|
||||
iframe.contentWindow.postMessage(message, url);
|
||||
break;
|
||||
case "output" :
|
||||
// Append new output
|
||||
output.innerHTML = output.innerHTML + decoded.data;
|
||||
|
@ -220,6 +228,9 @@
|
|||
}
|
||||
}, false);
|
||||
|
||||
// Add url to our iframe after the event listener is installed.
|
||||
iframe.src = url;
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
|
BIN
misc/preview.gif
Executable file
After Width: | Height: | Size: 930 KiB |
0
misc/preview.png
Normal file → Executable file
Before Width: | Height: | Size: 79 KiB After Width: | Height: | Size: 79 KiB |
22
sgit
Executable file
|
@ -0,0 +1,22 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -ex
|
||||
|
||||
if [[ "--help" == "${1}" ]]; then
|
||||
echo "bash ./sgit user.email commit"
|
||||
fi
|
||||
|
||||
if [[ -z "${2}" ]]; then
|
||||
echo "Bitte email und commit angeben!!!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
git config --global user.email "${1}"
|
||||
git config --global user.name "${1}"
|
||||
git status
|
||||
git pull
|
||||
git add --all
|
||||
git commit --all -m "${2}"
|
||||
git show
|
||||
git push
|
||||
git status
|
9
shellinabox.service
Executable file
|
@ -0,0 +1,9 @@
|
|||
[Unit]
|
||||
Description=shellinabox
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/opt/shellinabox/shellinaboxd -t --service=/:webssh:webssh:HOME:'/home/webssh/shellinabox_sshwrapper.sh'
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
0
shellinabox/beep.wav
Normal file → Executable file
16
shellinabox/black-on-white.css
Normal file → Executable file
|
@ -0,0 +1,16 @@
|
|||
#vt100 .ansiDefR {
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
#vt100 .bgAnsiDefR {
|
||||
background-color: #000000;
|
||||
}
|
||||
|
||||
#vt100 #scrollable.inverted .ansiDefR {
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
#vt100 #scrollable.inverted .bgAnsiDefR {
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
0
shellinabox/cgi_root.html
Normal file → Executable file
2
shellinabox/color.css
Normal file → Executable file
|
@ -2,6 +2,7 @@
|
|||
|
||||
/* SYSTEM colors */
|
||||
#vt100 .ansiDef { }
|
||||
#vt100 .ansiDefR { }
|
||||
|
||||
#vt100 .ansi0 { color: #000000; }
|
||||
#vt100 .ansi1 { color: #cd0000; }
|
||||
|
@ -264,6 +265,7 @@
|
|||
|
||||
/* SYSTEM colors */
|
||||
#vt100 .bgAnsiDef { }
|
||||
#vt100 .bgAnsiDefR { }
|
||||
|
||||
#vt100 .bgAnsi0 { background-color: #000000; }
|
||||
#vt100 .bgAnsi1 { background-color: #cd0000; }
|
||||
|
|
0
shellinabox/enabled.gif
Normal file → Executable file
Before Width: | Height: | Size: 847 B After Width: | Height: | Size: 847 B |
0
shellinabox/externalfile.c
Normal file → Executable file
0
shellinabox/externalfile.h
Normal file → Executable file
0
shellinabox/favicon.ico
Normal file → Executable file
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
0
shellinabox/keyboard-layout.html
Normal file → Executable file
0
shellinabox/keyboard.png
Normal file → Executable file
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
1
shellinabox/launcher.c
Normal file → Executable file
|
@ -63,6 +63,7 @@
|
|||
#include <sys/socket.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/ttydefaults.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/utsname.h>
|
||||
|
|
0
shellinabox/launcher.h
Normal file → Executable file
0
shellinabox/monochrome.css
Normal file → Executable file
0
shellinabox/print-styles.css
Normal file → Executable file
0
shellinabox/privileges.c
Normal file → Executable file
0
shellinabox/privileges.h
Normal file → Executable file
0
shellinabox/root_page.html
Normal file → Executable file
41
shellinabox/service.c
Normal file → Executable file
|
@ -121,18 +121,29 @@ void initService(struct Service *service, const char *arg) {
|
|||
service->group = NULL;
|
||||
check(service->cwd = strdup("/"));
|
||||
char *host;
|
||||
char *sshPort;
|
||||
check(host = strdup("localhost"));
|
||||
check(sshPort = strdup("22"));
|
||||
|
||||
if ((ptr = strchr(arg, ':')) != NULL) {
|
||||
check(ptr = strdup(ptr + 1));
|
||||
char *end;
|
||||
if ((end = strchr(ptr, ':')) != NULL) {
|
||||
*end = '\000';
|
||||
}
|
||||
ptr = ptr + 1;
|
||||
if (*ptr) {
|
||||
free(host);
|
||||
host = ptr;
|
||||
} else {
|
||||
free(ptr);
|
||||
char *tmp = strchr(ptr, ':');
|
||||
if (tmp == NULL) {
|
||||
// If the second ":" is not found, keep as host whatever is after first ":".
|
||||
free(host);
|
||||
check(host = strdup(ptr));
|
||||
} else {
|
||||
// If we find a second ":", keep as a host whatever is in between first ":"
|
||||
// and second ":" and as sshPort whatever is after second ":".
|
||||
int size = (tmp - ptr + 1);
|
||||
free(host);
|
||||
free(sshPort);
|
||||
check(host = malloc(size));
|
||||
memset(host, 0, size);
|
||||
memcpy(host, ptr, size - 1);
|
||||
check(sshPort = strdup(tmp + 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -148,6 +159,15 @@ void initService(struct Service *service, const char *arg) {
|
|||
}
|
||||
}
|
||||
|
||||
// Don't allow manipulation of the SSH command line through "creative" use
|
||||
// of the port.
|
||||
for (char *h = sshPort; *h; h++) {
|
||||
char ch = *h;
|
||||
if (!(ch >= '0' && ch <= '9')) {
|
||||
fatal("[config] Invalid port \"%s\" in service definition!", sshPort);
|
||||
}
|
||||
}
|
||||
|
||||
service->cmdline = stringPrintf(NULL,
|
||||
"ssh -a -e none -i /dev/null -x -oChallengeResponseAuthentication=no "
|
||||
"-oCheckHostIP=no -oClearAllForwardings=yes -oCompression=no "
|
||||
|
@ -162,8 +182,9 @@ void initService(struct Service *service, const char *arg) {
|
|||
// feature, we cannot be sure that it is available on the
|
||||
// target server. Removing it for the sake of Centos.
|
||||
// "-oVisualHostKey=no"
|
||||
" -oLogLevel=FATAL %%s@%s", host);
|
||||
" -oLogLevel=FATAL -p%s %%s@%s",sshPort, host);
|
||||
free(host);
|
||||
free(sshPort);
|
||||
} else {
|
||||
service->useLogin = 0;
|
||||
|
||||
|
|
0
shellinabox/service.h
Normal file → Executable file
2
shellinabox/session.c
Normal file → Executable file
|
@ -116,9 +116,11 @@ void initSession(struct Session *session, const char *sessionKey,
|
|||
session->http = NULL;
|
||||
session->done = 0;
|
||||
session->pty = -1;
|
||||
session->ptyFirstRead = 1;
|
||||
session->width = 0;
|
||||
session->height = 0;
|
||||
session->buffered = NULL;
|
||||
session->useLogin = 0;
|
||||
session->len = 0;
|
||||
session->pid = 0;
|
||||
session->cleanup = 0;
|
||||
|
|
2
shellinabox/session.h
Normal file → Executable file
|
@ -58,9 +58,11 @@ struct Session {
|
|||
HttpConnection *http;
|
||||
int done;
|
||||
int pty;
|
||||
int ptyFirstRead;
|
||||
int width;
|
||||
int height;
|
||||
char *buffered;
|
||||
int useLogin;
|
||||
int len;
|
||||
pid_t pid;
|
||||
int cleanup;
|
||||
|
|
3
shellinabox/shell_in_a_box.jspp
Normal file → Executable file
|
@ -406,6 +406,9 @@ ShellInABox.prototype.messageInit = function() {
|
|||
}
|
||||
}
|
||||
|
||||
// After message mechanisms are in place "ready" message is sent to parent
|
||||
// window.
|
||||
parent.postMessage(JSON.stringify({type : 'ready', data : ''}), '*');
|
||||
};
|
||||
|
||||
ShellInABox.prototype.messageReceive = function (message) {
|
||||
|
|
61
shellinabox/shellinaboxd.c
Normal file → Executable file
|
@ -63,7 +63,7 @@
|
|||
#include <sys/stat.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef HAVE_SYS_PRCTL_H
|
||||
|
@ -110,8 +110,10 @@ static int portMax;
|
|||
static int localhostOnly = 0;
|
||||
static int noBeep = 0;
|
||||
static int numericHosts = 0;
|
||||
static int peerCheckEnabled = 1;
|
||||
static int enableSSL = 1;
|
||||
static int enableSSLMenu = 1;
|
||||
static int forceSSL = 1; // TODO enable http fallback with commandline option
|
||||
int enableUtmpLogging = 1;
|
||||
static char *messagesOrigin = NULL;
|
||||
static int linkifyURLs = 1;
|
||||
|
@ -290,6 +292,13 @@ static void sessionDone(void *arg) {
|
|||
completePendingRequest(session, "", 0, INT_MAX);
|
||||
}
|
||||
|
||||
static void delaySession(void) {
|
||||
struct timespec ts;
|
||||
ts.tv_sec = 0;
|
||||
ts.tv_nsec = 200 * 1000; // Delay for 0.2 ms
|
||||
nanosleep(&ts, NULL);
|
||||
}
|
||||
|
||||
static int handleSession(struct ServerConnection *connection, void *arg,
|
||||
short *events, short revents) {
|
||||
struct Session *session = (struct Session *)arg;
|
||||
|
@ -309,7 +318,7 @@ static int handleSession(struct ServerConnection *connection, void *arg,
|
|||
int timedOut = serverGetTimeout(connection) < 0;
|
||||
if (bytes || timedOut) {
|
||||
if (!session->http && timedOut) {
|
||||
debug("[server] Timeout. Closing session!");
|
||||
debug("[server] Timeout. Closing session %s!", session->sessionKey);
|
||||
session->cleanup = 1;
|
||||
return 0;
|
||||
}
|
||||
|
@ -323,8 +332,26 @@ static int handleSession(struct ServerConnection *connection, void *arg,
|
|||
*events = 0;
|
||||
}
|
||||
serverSetTimeout(connection, AJAX_TIMEOUT);
|
||||
session->ptyFirstRead = 0;
|
||||
return 1;
|
||||
} else {
|
||||
if (revents & POLLHUP) {
|
||||
if (session->useLogin && session->ptyFirstRead) {
|
||||
// Workaround for random "Session closed" issues related to /bin/login
|
||||
// closing and reopening our pty during initialization. This happens only
|
||||
// on some systems like Fedora for example.
|
||||
// Here we allow that our pty is closed by ignoring POLLHUP on first read.
|
||||
// Delay is also needed so that login process has some time to reopen pty.
|
||||
// Note that the issue may occur anyway but with workaround we reduce the
|
||||
// chances.
|
||||
debug("[server] POLLHUP received on login PTY first read!");
|
||||
session->ptyFirstRead = 0;
|
||||
delaySession();
|
||||
return 1;
|
||||
}
|
||||
debug("[server] POLLHUP received on PTY! Closing session %s!",
|
||||
session->sessionKey);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -367,7 +394,7 @@ static int dataHandler(HttpConnection *http, struct Service *service,
|
|||
}
|
||||
|
||||
// Sanity check
|
||||
if (!sessionIsNew && strcmp(session->peerName, httpGetPeerName(http))) {
|
||||
if (!sessionIsNew && peerCheckEnabled && strcmp(session->peerName, httpGetPeerName(http))) {
|
||||
error("[server] Peername changed from %s to %s",
|
||||
session->peerName, httpGetPeerName(http));
|
||||
httpSendReply(http, 400, "Bad Request", NO_MSG);
|
||||
|
@ -401,6 +428,7 @@ static int dataHandler(HttpConnection *http, struct Service *service,
|
|||
goto bad_new_session;
|
||||
}
|
||||
session->http = http;
|
||||
session->useLogin = service->useLogin;
|
||||
if (launchChild(service->id, session,
|
||||
rootURL && *rootURL ? rootURL : urlGetURL(url)) < 0) {
|
||||
abandonSession(session);
|
||||
|
@ -768,7 +796,7 @@ static void usage(void) {
|
|||
const char *user = getUserName(r_uid);
|
||||
const char *group = getGroupName(r_gid);
|
||||
|
||||
message("Usage: shellinaboxd [OPTIONS]...\n"
|
||||
printf("Usage: shellinaboxd [OPTIONS]...\n"
|
||||
"Starts an HTTP server that serves terminal emulators to AJAX "
|
||||
"enabled browsers.\n"
|
||||
"\n"
|
||||
|
@ -781,7 +809,7 @@ static void usage(void) {
|
|||
" -f, --static-file=URL:FILE serve static file from URL path\n"
|
||||
" -g, --group=GID switch to this group (default: %s)\n"
|
||||
" -h, --help print this message\n"
|
||||
" --linkify=[none|normal|agressive] default is \"normal\"\n"
|
||||
" --linkify=[none|normal|aggressive] default is \"normal\"\n"
|
||||
" --localhost-only only listen on 127.0.0.1\n"
|
||||
" --no-beep suppress all audio output\n"
|
||||
" -n, --numeric do not resolve hostnames\n"
|
||||
|
@ -797,6 +825,7 @@ static void usage(void) {
|
|||
" --user-css=STYLES defines user-selectable CSS options\n"
|
||||
" -v, --verbose enable logging messages\n"
|
||||
" --version prints version information\n"
|
||||
" --disable-peer-check disable peer check on a session\n"
|
||||
"\n"
|
||||
"Debug, quiet, and verbose are mutually exclusive.\n"
|
||||
"\n"
|
||||
|
@ -835,7 +864,8 @@ static void usage(void) {
|
|||
"\n"
|
||||
"OPTIONs that make up a GROUP are mutually exclusive. But "
|
||||
"individual GROUPs are\n"
|
||||
"independent of each other.\n",
|
||||
"independent of each other.\n"
|
||||
"\n",
|
||||
!serverSupportsSSL() ? "" :
|
||||
" -c, --cert=CERTDIR set certificate dir "
|
||||
"(default: $PWD)\n"
|
||||
|
@ -867,6 +897,7 @@ static void parseArgs(int argc, char * const argv[]) {
|
|||
int hasSSL = serverSupportsSSL();
|
||||
if (!hasSSL) {
|
||||
enableSSL = 0;
|
||||
forceSSL = 0;
|
||||
}
|
||||
int demonize = 0;
|
||||
int cgi = 0;
|
||||
|
@ -905,6 +936,7 @@ static void parseArgs(int argc, char * const argv[]) {
|
|||
{ "user-css", 1, 0, 0 },
|
||||
{ "verbose", 0, 0, 'v' },
|
||||
{ "version", 0, 0, 0 },
|
||||
{ "disable-peer-check", 0, 0, 0 },
|
||||
{ 0, 0, 0, 0 } };
|
||||
int idx = -1;
|
||||
int c = getopt_long(argc, argv, optstring, options, &idx);
|
||||
|
@ -1124,6 +1156,7 @@ static void parseArgs(int argc, char * const argv[]) {
|
|||
warn("[config] Ignoring disable-ssl option, as SSL support is unavailable.");
|
||||
}
|
||||
enableSSL = 0;
|
||||
forceSSL = 0;
|
||||
} else if (!idx--) {
|
||||
// Disable SSL Menu
|
||||
if (!hasSSL) {
|
||||
|
@ -1211,18 +1244,22 @@ static void parseArgs(int argc, char * const argv[]) {
|
|||
logSetLogLevel(verbosity);
|
||||
} else if (!idx--) {
|
||||
// Version
|
||||
message("ShellInABox version " VERSION VCS_REVISION);
|
||||
printf("ShellInABox version " VERSION VCS_REVISION "\n");
|
||||
exit(0);
|
||||
} else if (!idx--) {
|
||||
// disable-peer-check
|
||||
peerCheckEnabled = 0;
|
||||
}
|
||||
}
|
||||
if (optind != argc) {
|
||||
usage();
|
||||
fatal("[config] Failed to parse command line!");
|
||||
}
|
||||
char *buf = NULL;
|
||||
check(argc >= 1);
|
||||
|
||||
info("[server] Version " VERSION VCS_REVISION);
|
||||
for (int i = 0; i < argc; i++) {
|
||||
buf = stringPrintf(buf, " %s", argv[i]);
|
||||
buf = stringPrintf(buf, "%s ", argv[i]);
|
||||
}
|
||||
info("[server] Command line: %s", buf);
|
||||
free(buf);
|
||||
|
@ -1300,7 +1337,8 @@ static void removeLimits() {
|
|||
}
|
||||
|
||||
static void setUpSSL(Server *server) {
|
||||
serverEnableSSL(server, enableSSL);
|
||||
|
||||
serverSetupSSL(server, enableSSL, forceSSL);
|
||||
|
||||
// Enable SSL support (if available)
|
||||
if (enableSSL) {
|
||||
|
@ -1372,8 +1410,9 @@ int main(int argc, char * const argv[]) {
|
|||
check(port = serverGetListeningPort(server));
|
||||
printf("X-ShellInABox-Port: %d\r\n"
|
||||
"X-ShellInABox-Pid: %d\r\n"
|
||||
"X-ShellInABox-Session: %s\r\n"
|
||||
"Content-type: text/html; charset=utf-8\r\n\r\n",
|
||||
port, getpid());
|
||||
port, getpid(), cgiSessionKey);
|
||||
UNUSED(cgiRootSize);
|
||||
printfUnchecked(cgiRootStart, port, cgiSessionKey);
|
||||
fflush(stdout);
|
||||
|
|
2
shellinabox/shellinaboxd.man.in
Normal file → Executable file
|
@ -282,7 +282,7 @@ Display a brief usage message showing the valid command line parameters.
|
|||
.TP
|
||||
\fB--linkify\fP=[\fBnone\fP|\fBnormal\fP|\fBaggressive\fP]
|
||||
the daemon attempts to recognize URLs in the terminal output and makes them
|
||||
clickable. This is not neccessarily a fool-proof process and both false
|
||||
clickable. This is not necessarily a fool-proof process and both false
|
||||
negatives and false positives are possible. By default, only URLs starting
|
||||
with a well known protocol of
|
||||
.BR http:// ,\ https:// ,\ ftp:// ,\ or\ mailto:
|
||||
|
|
|
@ -243,9 +243,12 @@
|
|||
[else DEFINES_COLORS]
|
||||
/* SYSTEM colors */
|
||||
#vt100 .ansiDef { color: #000000; }
|
||||
#vt100 .ansiDefR { color: #ffffff; }
|
||||
|
||||
#vt100 #scrollable.inverted .ansiDef
|
||||
{ color: #ffffff; }
|
||||
#vt100 #scrollable.inverted .ansiDefR
|
||||
{ color: #000000; }
|
||||
|
||||
#vt100 .ansi0 { color: #000000; }
|
||||
#vt100 .ansi1 { color: #cd0000; }
|
||||
|
@ -508,9 +511,13 @@
|
|||
|
||||
/* SYSTEM colors */
|
||||
#vt100 .bgAnsiDef { background-color: #ffffff; }
|
||||
#vt100 .bgAnsiDefR
|
||||
{ background-color: #000000; }
|
||||
|
||||
#vt100 #scrollable.inverted .bgAnsiDef
|
||||
{ background-color: #000000; }
|
||||
#vt100 #scrollable.inverted .bgAnsiDefR
|
||||
{ background-color: #ffffff; }
|
||||
|
||||
#vt100 .bgAnsi0 { background-color: #000000; }
|
||||
#vt100 .bgAnsi1 { background-color: #cd0000; }
|
||||
|
|
0
shellinabox/usercss.c
Normal file → Executable file
0
shellinabox/usercss.h
Normal file → Executable file
|
@ -83,6 +83,7 @@
|
|||
#define EStitle 17
|
||||
#define ESss2 18
|
||||
#define ESss3 19
|
||||
#define ESVTEtitle 20
|
||||
|
||||
#define ATTR_DEFAULT 0x60F0
|
||||
#define ATTR_REVERSE 0x0100
|
||||
|
@ -297,6 +298,12 @@ VT100.prototype.getUserSettings = function() {
|
|||
this.disableAlt = true;
|
||||
}
|
||||
|
||||
// Enable soft keyboard icon on some clients by default.
|
||||
if (navigator.userAgent.match(/iPad|iPhone|iPod/i) != null ||
|
||||
navigator.userAgent.match(/PlayStation Vita|Kindle/i) != null) {
|
||||
this.softKeyboard = true;
|
||||
}
|
||||
|
||||
if (this.visualBell) {
|
||||
this.signature = Math.floor(16807*this.signature + 1) %
|
||||
((1 << 31) - 1);
|
||||
|
@ -1198,8 +1205,8 @@ VT100.prototype.resizer = function() {
|
|||
document.documentElement.clientHeight ||
|
||||
document.body.clientHeight))-1;
|
||||
|
||||
// Prevent ever growing consoles on iPad.
|
||||
if (navigator.userAgent.match(/iPad/i) != null) {
|
||||
// Prevent ever growing console on some iOS clients.
|
||||
if (navigator.userAgent.match(/iPad|iPhone|iPod/i) != null) {
|
||||
height -= 1;
|
||||
}
|
||||
|
||||
|
@ -1429,6 +1436,25 @@ VT100.prototype.mouseEvent = function(event, type) {
|
|||
return this.cancelEvent(event);
|
||||
}
|
||||
|
||||
// Simulate middle click pasting from inside of current window. Note that
|
||||
// pasting content from other programs will not work in this way, since we
|
||||
// don't have access to native clipboard.
|
||||
if ((event.which || event.button) == 2 && selection.length) {
|
||||
if (type == MOUSE_UP) {
|
||||
// Use timeout to prevent double paste on Chrome/Linux.
|
||||
setTimeout(function (vt100) {
|
||||
return function() {
|
||||
vt100.keysPressed(selection);
|
||||
vt100.input.focus();
|
||||
}
|
||||
}(this), 10);
|
||||
}
|
||||
if (type == MOUSE_DOWN) {
|
||||
// Prevent middle click scroll on Windows systems.
|
||||
return this.cancelEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.mouseReporting) {
|
||||
try {
|
||||
event.shiftKey = false;
|
||||
|
@ -1578,7 +1604,10 @@ VT100.prototype.updateWidth = function() {
|
|||
this.terminalWidth = Math.floor(this.console[this.currentScreen].offsetWidth/this.cursorWidth*this.scale);
|
||||
}
|
||||
} else {
|
||||
this.terminalWidth = Math.floor(this.console[this.currentScreen].offsetWidth/this.cursorWidth*this.scale);
|
||||
if ("ActiveXObject" in window)
|
||||
this.terminalWidth = Math.floor(this.console[this.currentScreen].offsetWidth/this.cursorWidth*this.scale*0.95);
|
||||
else
|
||||
this.terminalWidth = Math.floor(this.console[this.currentScreen].offsetWidth/this.cursorWidth*this.scale);
|
||||
}
|
||||
|
||||
return this.terminalWidth;
|
||||
|
@ -2815,7 +2844,7 @@ VT100.prototype.handleKey = function(event) {
|
|||
ch = part1 +
|
||||
((event.shiftKey ? 1 : 0) +
|
||||
(event.altKey|event.metaKey ? 2 : 0) +
|
||||
(event.ctrlKey ? 4 : 0)) +
|
||||
(event.ctrlKey ? 4 : 0) + 1) +
|
||||
part2;
|
||||
} else if (ch.length == 1 && (event.altKey || event.metaKey)
|
||||
&& !this.disableAlt) {
|
||||
|
@ -2885,9 +2914,9 @@ VT100.prototype.fixEvent = function(event) {
|
|||
// Some browsers fail to translate keys, if both shift and alt/meta is
|
||||
// pressed at the same time. We try to translate those cases, but that
|
||||
// only works for US keyboard layouts.
|
||||
var u = undefined;
|
||||
var s = undefined;
|
||||
if (event.shiftKey) {
|
||||
var u = undefined;
|
||||
var s = undefined;
|
||||
switch (this.lastNormalKeyDownEvent.keyCode) {
|
||||
case 39: /* ' -> " */ u = 39; s = 34; break;
|
||||
case 44: /* , -> < */ u = 44; s = 60; break;
|
||||
|
@ -2928,17 +2957,23 @@ VT100.prototype.fixEvent = function(event) {
|
|||
case 222: /* ' -> " */ u = 39; s = 34; break;
|
||||
default: break;
|
||||
}
|
||||
if (s && (event.charCode == u || event.charCode == 0)) {
|
||||
var fake = [ ];
|
||||
fake.charCode = s;
|
||||
fake.keyCode = event.keyCode;
|
||||
fake.ctrlKey = event.ctrlKey;
|
||||
fake.shiftKey = event.shiftKey;
|
||||
fake.altKey = event.altKey;
|
||||
fake.metaKey = event.metaKey;
|
||||
return fake;
|
||||
} else {
|
||||
var c = this.lastNormalKeyDownEvent.keyCode;
|
||||
if (c >= 65 && c <= 90) {
|
||||
u = c;
|
||||
s = u | 32;
|
||||
}
|
||||
}
|
||||
if (s && (event.charCode == u || event.charCode == 0)) {
|
||||
var fake = [ ];
|
||||
fake.charCode = s;
|
||||
fake.keyCode = event.keyCode;
|
||||
fake.ctrlKey = event.ctrlKey;
|
||||
fake.shiftKey = event.shiftKey;
|
||||
fake.altKey = event.altKey;
|
||||
fake.metaKey = event.metaKey;
|
||||
return fake;
|
||||
}
|
||||
return event;
|
||||
};
|
||||
|
||||
|
@ -3023,10 +3058,8 @@ VT100.prototype.keyDown = function(event) {
|
|||
} else {
|
||||
fake.charCode = 0;
|
||||
fake.keyCode = event.keyCode;
|
||||
if (!alphNumKey && event.shiftKey) {
|
||||
fake = this.fixEvent(fake);
|
||||
}
|
||||
}
|
||||
fake = this.fixEvent(fake);
|
||||
|
||||
this.handleKey(fake);
|
||||
this.lastNormalKeyDownEvent = undefined;
|
||||
|
@ -3141,9 +3174,9 @@ VT100.prototype.keyUp = function(event) {
|
|||
} else {
|
||||
fake.charCode = 0;
|
||||
fake.keyCode = event.keyCode;
|
||||
if (!alphNumKey && (event.ctrlKey || event.altKey || event.metaKey)) {
|
||||
fake = this.fixEvent(fake);
|
||||
}
|
||||
}
|
||||
if (event.ctrlKey || event.altKey || event.metaKey) {
|
||||
fake = this.fixEvent(fake);
|
||||
}
|
||||
this.lastNormalKeyDownEvent = undefined;
|
||||
this.handleKey(fake);
|
||||
|
@ -3351,44 +3384,50 @@ VT100.prototype.respondSecondaryDA = function() {
|
|||
|
||||
|
||||
VT100.prototype.updateStyle = function() {
|
||||
this.style = '';
|
||||
var fg = '';
|
||||
var bg = '';
|
||||
this.style = '';
|
||||
|
||||
if (this.attr & ATTR_UNDERLINE) {
|
||||
this.style = 'text-decoration: underline;';
|
||||
}
|
||||
var bg = (this.attr >> 4) & 0xF;
|
||||
var fg = this.attr & 0xF;
|
||||
if (this.attr & ATTR_REVERSE) {
|
||||
var tmp = bg;
|
||||
bg = fg;
|
||||
fg = tmp;
|
||||
}
|
||||
if ((this.attr & (ATTR_REVERSE | ATTR_DIM)) == ATTR_DIM) {
|
||||
fg = 8; // Dark grey
|
||||
} else if (this.attr & ATTR_BRIGHT) {
|
||||
fg |= 8;
|
||||
this.style = 'font-weight: bold;';
|
||||
this.style += 'text-decoration: underline;';
|
||||
}
|
||||
if (this.attr & ATTR_BLINK) {
|
||||
this.style = 'text-decoration: blink;';
|
||||
this.style += 'text-decoration: blink;';
|
||||
}
|
||||
|
||||
// Default colors
|
||||
if (this.attr & ATTR_DEF_FG) {
|
||||
fg = 'Def';
|
||||
}
|
||||
if (this.attr & ATTR_DEF_BG) {
|
||||
bg = 'Def';
|
||||
}
|
||||
|
||||
// Extended color mode support (256 colors).
|
||||
// Forground color
|
||||
if (this.attrFg) {
|
||||
fg = this.attrFg;
|
||||
}
|
||||
if (this.attrBg) {
|
||||
bg = this.attrBg;
|
||||
// 256 color mode
|
||||
fg = this.attrFg
|
||||
} else if (this.attr & ATTR_DEF_FG) {
|
||||
fg = 'Def';
|
||||
} else {
|
||||
fg = this.attr & 0xF;
|
||||
if (this.attr & ATTR_BRIGHT) {
|
||||
fg |= 8;
|
||||
this.style += 'font-weight: bold;';
|
||||
}
|
||||
}
|
||||
|
||||
this.color = 'ansi' + fg + ' bgAnsi' + bg;
|
||||
// Background color
|
||||
if (this.attrBg) {
|
||||
// 256 color mode
|
||||
bg = this.attrBg
|
||||
} else if (this.attr & ATTR_DEF_BG) {
|
||||
bg = 'Def';
|
||||
} else {
|
||||
bg = (this.attr >> 4) & 0xF;
|
||||
}
|
||||
|
||||
// Reverse colors
|
||||
if (this.attr & ATTR_REVERSE) {
|
||||
var tmpFg = fg;
|
||||
var tmpBg = bg;
|
||||
fg = (tmpBg == 'Def') ? 'DefR' : tmpBg;
|
||||
bg = (tmpFg == 'Def') ? 'DefR' : tmpFg;
|
||||
}
|
||||
|
||||
this.color = 'ansi' + fg + ' bgAnsi' + bg;
|
||||
};
|
||||
|
||||
VT100.prototype.setAttrColors = function(attr) {
|
||||
|
@ -3869,7 +3908,7 @@ VT100.prototype.csim = function() {
|
|||
case 27: this.attr &= ~ ATTR_REVERSE; break;
|
||||
case 38:
|
||||
if (this.npar >= (i+2) && this.par[i+1] == 5) {
|
||||
// Foreground color for extended color mode (256 colors). Escape code is formated
|
||||
// Foreground color for extended color mode (256 colors). Escape code is formatted
|
||||
// as: ESC 38; 5; 0-255. Last parameter is color code in range [0-255]. This is
|
||||
// not VT100 standard.
|
||||
this.attrFg = (this.par[i+2] >= 0 && this.par[i+2] <= 255) ? this.par[i+2] : false;
|
||||
|
@ -3885,7 +3924,7 @@ VT100.prototype.csim = function() {
|
|||
break;
|
||||
case 48:
|
||||
if (this.npar >= (i+2) && this.par[i+1] == 5) {
|
||||
// Background color for extended color mode (256 colors). Escape code is formated
|
||||
// Background color for extended color mode (256 colors). Escape code is formatted
|
||||
// as: ESC 48; 5; 0-255. Last parameter is color code in range [0-255]. This is
|
||||
// not VT100 standard.
|
||||
this.attrBg = (this.par[i+2] >= 0 && this.par[i+2] <= 255) ? this.par[i+2] : false;
|
||||
|
@ -4015,6 +4054,8 @@ VT100.prototype.doControl = function(ch) {
|
|||
/*0*/ case 0x30:
|
||||
/*1*/ case 0x31:
|
||||
/*2*/ case 0x32: this.isEsc = EStitle; this.titleString = ''; break;
|
||||
/*6*/ case 0x36: this.isEsc = ESVTEtitle; break;
|
||||
/*7*/ case 0x37: this.isEsc = ESVTEtitle; break;
|
||||
/*P*/ case 0x50: this.npar = 0; this.par = [ 0, 0, 0, 0, 0, 0, 0 ];
|
||||
this.isEsc = ESpalette; break;
|
||||
/*R*/ case 0x52: // Palette support is not implemented
|
||||
|
@ -4242,6 +4283,13 @@ VT100.prototype.doControl = function(ch) {
|
|||
this.lastCharacter = String.fromCharCode(ch);
|
||||
lineBuf += this.lastCharacter;
|
||||
this.isEsc = ESnormal; break;
|
||||
case ESVTEtitle:
|
||||
// Ignores VTE escape sequences for current directory (OSC6) and current
|
||||
// file (OSC7).
|
||||
if (ch == 0x07 || ch == 0x5C) {
|
||||
this.isEsc = ESnormal;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
this.isEsc = ESnormal; break;
|
||||
}
|
||||
|
|
|
@ -24,14 +24,30 @@
|
|||
color: #ffffff;
|
||||
}
|
||||
|
||||
#vt100 .ansiDefR {
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
#vt100 .bgAnsiDef {
|
||||
background-color: #000000;
|
||||
}
|
||||
|
||||
#vt100 .bgAnsiDefR {
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
#vt100 #scrollable.inverted .ansiDef {
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
#vt100 #scrollable.inverted .ansiDefR {
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
#vt100 #scrollable.inverted .bgAnsiDef {
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
#vt100 #scrollable.inverted .bgAnsiDefR {
|
||||
background-color: #000000;
|
||||
}
|
||||
|
|
32
shellinabox_sshwrapper.sh
Executable file
|
@ -0,0 +1,32 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
set -ex
|
||||
#
|
||||
read -p "SSH remote host (hostname or ip address) [localhost] : " host;
|
||||
[[ -z "${host}" ]] && host=localhost;
|
||||
#
|
||||
read -p "If a puplic_key authentification?: [y/N] : " puplic;
|
||||
#
|
||||
read -p "SSH remote port [22] : " port;
|
||||
[[ -z "${port}" ]] && port=22;
|
||||
#
|
||||
read -p "SSH remote username [pi] : " username;
|
||||
[[ -z "${username}" ]] && username=pi;
|
||||
#
|
||||
if [ "$puplic" == "y" ];
|
||||
then
|
||||
read -p "How is your public_key?: " key;
|
||||
echo $key > ~/.ssh/id_rsa.pub;
|
||||
|
||||
rm ~/.ssh/id_rsa;
|
||||
echo "Enter your private id here and press the enter key for a new line !!!";
|
||||
id=null
|
||||
while [ "$id" != "" ];
|
||||
do
|
||||
read -p "How is your id_rsa key?: " id;
|
||||
echo $id >> ~/.ssh/id_rsa;
|
||||
done
|
||||
exec ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p $port $username@$host;
|
||||
else
|
||||
exec ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p $port $username@$host;
|
||||
fi
|