HTTP Copy: Difference between revisions

From Coolscript
Jump to navigation Jump to search
No edit summary
No edit summary
Line 15: Line 15:
  my $uploadpath='/path/to/upload/';
  my $uploadpath='/path/to/upload/';


The server script is able to send syslog messages, if this is an option then the syslog module must be to be installed<br>
The server script is able to send syslog messages, if this is an option then the syslog module must be installed<br>
using cpan, build-essential is needed to do this:
using cpan, build-essential is needed to do this:



Revision as of 14:48, 18 October 2019

HTTP copy (HCP) is a small perl script which allows you to upload data through your Apache Server to disk.
The script has been tested on Debian 10 (Buster) but should work on other distros as well.
It was made to establish an alternative to scp without the need of dealing with PAM or Shell issues.
HCP is using the HTTP POST method and there shouldn't be a size limit unless you define one.
HCP comes with the client script (hcp.pl) and the Server (cgi) script.


Usage:

perl hcp.pl -f <filename> -url <url> -u <username> -p <password> -g (optional gzip data)
Sample:
perl hcp.pl -f c:\path\to\file\myfile.doc  -url https://myserver.com -u myUser -p myPwd -g


Server script index.cgi, you need to specify the upload path within the script:

my $uploadpath='/path/to/upload/';

The server script is able to send syslog messages, if this is an option then the syslog module must be installed
using cpan, build-essential is needed to do this:

apt-get install build-essential
cpan install Net::Syslog

Then specify the ip to your syslog server in index.cgi:

my $SyslogHost='192.168.1.1';


Apache sample configuration, it allows http/https using basic auth

<Directory "/var/www/hcp.my-server.com/cgi-bin">
 Options ExecCGI
 DirectoryIndex index.cgi
 Order allow,deny
 Allow from all
 #Make sure to enable the Apache cgi and perl module
 AddHandler cgi-script .cgi .pl
 AuthName "HCP Access"
 AuthType Basic
 AuthUserFile /var/www/hcp.my-server.com/.htpasswd.users
 Require valid-user
</Directory>
 
# =================================================
# SSL/TLS settings
# =================================================
<VirtualHost *:443>
 ServerName hcp.my-server.com
 DocumentRoot /var/www/hcp.my-server.com/cgi-bin
 ErrorLog /var/log/apache2/hcp.my-server.com.error.log
 CustomLog /var/log/apache2/hcp.my-server.com.log common
 SSLStrictSNIVHostCheck off
 SSLCertificateFile /path/.../fullchain.pem
 SSLCertificateKeyFile /path/.../privkey.pem
 SSLHonorCipherOrder On
 SSLProtocol +ALL -SSLv3 -SSLv2
 SSLCipherSuite DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:AES256-SHA:AES128-SHA
</VirtualHost>


<VirtualHost *:80>
 ServerName hcp.my-server.com
 DocumentRoot /var/www/hcp.my-server.com/cgi-bin
 ErrorLog /var/log/apache2/hcp.my-server.com.error.log
 CustomLog /var/log/apache2/hcp.my-server.com.access.log common
</VirtualHost>



Download the script
Download