Major rewrite

* use dep for vendoring
* lets encrypt
* moved web to transfer.sh-web repo
* single command install
* added first tests
This commit is contained in:
Remco
2017-03-22 18:09:21 +01:00
parent 6d68ad982f
commit cb6e5cb0c7
1917 changed files with 424197 additions and 260688 deletions

24
vendor/github.com/dutchcoders/go-clamd/.gitignore generated vendored Normal file
View File

@@ -0,0 +1,24 @@
# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so
# Folders
_obj
_test
# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out
*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*
_testmain.go
*.exe
*.test
*.prof

10
vendor/github.com/dutchcoders/go-clamd/.travis.yml generated vendored Normal file
View File

@@ -0,0 +1,10 @@
language: go
go:
- 1.1
- 1.2
- 1.3
- release
- tip
script:
- go test -v ./...

22
vendor/github.com/dutchcoders/go-clamd/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,22 @@
The MIT License (MIT)
Copyright (c) 2014 dutchcoders
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

35
vendor/github.com/dutchcoders/go-clamd/README.md generated vendored Normal file
View File

@@ -0,0 +1,35 @@
go-clamd
========
Interface to clamd (clamav daemon). You can use go-clamd to implement virus detection capabilities to your application.
[![GoDoc](https://godoc.org/github.com/dutchcoders/go-clamd?status.svg)](https://godoc.org/github.com/dutchcoders/go-clamd)
[![Build Status](https://travis-ci.org/dutchcoders/go-clamd.svg?branch=master)](https://travis-ci.org/dutchcoders/go-clamd)
## Examples
```
c := clamd.NewClamd("/tmp/clamd.socket")
reader := bytes.NewReader(clamd.EICAR)
response, err := c.ScanStream(reader)
for s := range response {
fmt.Printf("%v %v\n", s, err)
}
```
## Contributions
Contributions are welcome.
## Creators
**Remco Verhoef**
- <https://twitter.com/remco_verhoef>
- <https://twitter.com/dutchcoders>
## Copyright and license
Code and documentation copyright 2011-2014 Remco Verhoef. Code released under [the MIT license](LICENSE).

311
vendor/github.com/dutchcoders/go-clamd/clamd.go generated vendored Normal file
View File

@@ -0,0 +1,311 @@
/*
Open Source Initiative OSI - The MIT License (MIT):Licensing
The MIT License (MIT)
Copyright (c) 2013 DutchCoders <http://github.com/dutchcoders/>
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
package clamd
import (
"errors"
"fmt"
"io"
"net/url"
"strings"
)
const (
RES_OK = "OK"
RES_FOUND = "FOUND"
RES_ERROR = "ERROR"
RES_PARSE_ERROR = "PARSE ERROR"
)
type Clamd struct {
address string
}
type Stats struct {
Pools string
State string
Threads string
Memstats string
Queue string
}
type ScanResult struct {
Raw string
Description string
Path string
Hash string
Size int
Status string
}
var EICAR = []byte(`X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*`)
func (c *Clamd) newConnection() (conn *CLAMDConn, err error) {
var u *url.URL
if u, err = url.Parse(c.address); err != nil {
return
}
switch u.Scheme {
case "tcp":
conn, err = newCLAMDTcpConn(u.Host)
case "unix":
conn, err = newCLAMDUnixConn(u.Path)
default:
conn, err = newCLAMDUnixConn(c.address)
}
return
}
func (c *Clamd) simpleCommand(command string) (chan *ScanResult, error) {
conn, err := c.newConnection()
if err != nil {
return nil, err
}
err = conn.sendCommand(command)
if err != nil {
return nil, err
}
ch, wg, err := conn.readResponse()
go func() {
wg.Wait()
conn.Close()
}()
return ch, err
}
/*
Check the daemon's state (should reply with PONG).
*/
func (c *Clamd) Ping() error {
ch, err := c.simpleCommand("PING")
if err != nil {
return err
}
select {
case s := (<-ch):
switch s.Raw {
case "PONG":
return nil
default:
return errors.New(fmt.Sprintf("Invalid response, got %s.", s))
}
}
return nil
}
/*
Print program and database versions.
*/
func (c *Clamd) Version() (chan *ScanResult, error) {
dataArrays, err := c.simpleCommand("VERSION")
return dataArrays, err
}
/*
On this command clamd provides statistics about the scan queue, contents of scan
queue, and memory usage. The exact reply format is subject to changes in future
releases.
*/
func (c *Clamd) Stats() (*Stats, error) {
ch, err := c.simpleCommand("STATS")
if err != nil {
return nil, err
}
stats := &Stats{}
for s := range ch {
if strings.HasPrefix(s.Raw, "POOLS") {
stats.Pools = strings.Trim(s.Raw[6:], " ")
} else if strings.HasPrefix(s.Raw, "STATE") {
stats.State = s.Raw
} else if strings.HasPrefix(s.Raw, "THREADS") {
stats.Threads = s.Raw
} else if strings.HasPrefix(s.Raw, "QUEUE") {
stats.Queue = s.Raw
} else if strings.HasPrefix(s.Raw, "MEMSTATS") {
stats.Memstats = s.Raw
} else if strings.HasPrefix(s.Raw, "END") {
} else {
// return nil, errors.New(fmt.Sprintf("Unknown response, got %s.", s))
}
}
return stats, nil
}
/*
Reload the databases.
*/
func (c *Clamd) Reload() error {
ch, err := c.simpleCommand("RELOAD")
if err != nil {
return err
}
select {
case s := (<-ch):
switch s.Raw {
case "RELOADING":
return nil
default:
return errors.New(fmt.Sprintf("Invalid response, got %s.", s))
}
}
return nil
}
func (c *Clamd) Shutdown() error {
_, err := c.simpleCommand("SHUTDOWN")
if err != nil {
return err
}
return err
}
/*
Scan file or directory (recursively) with archive support enabled (a full path is
required).
*/
func (c *Clamd) ScanFile(path string) (chan *ScanResult, error) {
command := fmt.Sprintf("SCAN %s", path)
ch, err := c.simpleCommand(command)
return ch, err
}
/*
Scan file or directory (recursively) with archive and special file support disabled
(a full path is required).
*/
func (c *Clamd) RawScanFile(path string) (chan *ScanResult, error) {
command := fmt.Sprintf("RAWSCAN %s", path)
ch, err := c.simpleCommand(command)
return ch, err
}
/*
Scan file in a standard way or scan directory (recursively) using multiple threads
(to make the scanning faster on SMP machines).
*/
func (c *Clamd) MultiScanFile(path string) (chan *ScanResult, error) {
command := fmt.Sprintf("MULTISCAN %s", path)
ch, err := c.simpleCommand(command)
return ch, err
}
/*
Scan file or directory (recursively) with archive support enabled and dont stop
the scanning when a virus is found.
*/
func (c *Clamd) ContScanFile(path string) (chan *ScanResult, error) {
command := fmt.Sprintf("CONTSCAN %s", path)
ch, err := c.simpleCommand(command)
return ch, err
}
/*
Scan file or directory (recursively) with archive support enabled and dont stop
the scanning when a virus is found.
*/
func (c *Clamd) AllMatchScanFile(path string) (chan *ScanResult, error) {
command := fmt.Sprintf("ALLMATCHSCAN %s", path)
ch, err := c.simpleCommand(command)
return ch, err
}
/*
Scan a stream of data. The stream is sent to clamd in chunks, after INSTREAM,
on the same socket on which the command was sent. This avoids the overhead
of establishing new TCP connections and problems with NAT. The format of the
chunk is: <length><data> where <length> is the size of the following data in
bytes expressed as a 4 byte unsigned integer in network byte order and <data> is
the actual chunk. Streaming is terminated by sending a zero-length chunk. Note:
do not exceed StreamMaxLength as defined in clamd.conf, otherwise clamd will
reply with INSTREAM size limit exceeded and close the connection
*/
func (c *Clamd) ScanStream(r io.Reader, abort chan bool) (chan *ScanResult, error) {
conn, err := c.newConnection()
if err != nil {
return nil, err
}
go func() {
for {
_, allowRunning := <-abort
if !allowRunning {
break
}
}
conn.Close()
}()
conn.sendCommand("INSTREAM")
for {
buf := make([]byte, CHUNK_SIZE)
nr, err := r.Read(buf)
if nr > 0 {
conn.sendChunk(buf[0:nr])
}
if err != nil {
break
}
}
err = conn.sendEOF()
if err != nil {
return nil, err
}
ch, wg, err := conn.readResponse()
go func() {
wg.Wait()
conn.Close()
}()
return ch, nil
}
func NewClamd(address string) *Clamd {
clamd := &Clamd{address: address}
return clamd
}

178
vendor/github.com/dutchcoders/go-clamd/conn.go generated vendored Normal file
View File

@@ -0,0 +1,178 @@
/*
Open Source Initiative OSI - The MIT License (MIT):Licensing
The MIT License (MIT)
Copyright (c) 2013 DutchCoders <http://github.com/dutchcoders/>
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
package clamd
import (
"bufio"
"fmt"
"io"
"net"
"regexp"
"strconv"
"strings"
"sync"
"time"
)
const CHUNK_SIZE = 1024
const TCP_TIMEOUT = time.Second * 2
var resultRegex = regexp.MustCompile(
`^(?P<path>[^:]+): ((?P<desc>[^:]+)(\((?P<virhash>([^:]+)):(?P<virsize>\d+)\))? )?(?P<status>FOUND|ERROR|OK)$`,
)
type CLAMDConn struct {
net.Conn
}
func (conn *CLAMDConn) sendCommand(command string) error {
commandBytes := []byte(fmt.Sprintf("n%s\n", command))
_, err := conn.Write(commandBytes)
return err
}
func (conn *CLAMDConn) sendEOF() error {
_, err := conn.Write([]byte{0, 0, 0, 0})
return err
}
func (conn *CLAMDConn) sendChunk(data []byte) error {
var buf [4]byte
lenData := len(data)
buf[0] = byte(lenData >> 24)
buf[1] = byte(lenData >> 16)
buf[2] = byte(lenData >> 8)
buf[3] = byte(lenData >> 0)
a := buf
b := make([]byte, len(a))
for i := range a {
b[i] = a[i]
}
conn.Write(b)
_, err := conn.Write(data)
return err
}
func (c *CLAMDConn) readResponse() (chan *ScanResult, *sync.WaitGroup, error) {
var wg sync.WaitGroup
wg.Add(1)
reader := bufio.NewReader(c)
ch := make(chan *ScanResult)
go func() {
defer func() {
close(ch)
wg.Done()
}()
for {
line, err := reader.ReadString('\n')
if err == io.EOF {
return
}
if err != nil {
return
}
line = strings.TrimRight(line, " \t\r\n")
ch <- parseResult(line)
}
}()
return ch, &wg, nil
}
func parseResult(line string) *ScanResult {
res := &ScanResult{}
res.Raw = line
matches := resultRegex.FindStringSubmatch(line)
if len(matches) == 0 {
res.Description = "Regex had no matches"
res.Status = RES_PARSE_ERROR
return res
}
for i, name := range resultRegex.SubexpNames() {
switch name {
case "path":
res.Path = matches[i]
case "desc":
res.Description = matches[i]
case "virhash":
res.Hash = matches[i]
case "virsize":
i, err := strconv.Atoi(matches[i])
if err == nil {
res.Size = i
}
case "status":
switch matches[i] {
case RES_OK:
case RES_FOUND:
case RES_ERROR:
break
default:
res.Description = "Invalid status field: " + matches[i]
res.Status = RES_PARSE_ERROR
return res
}
res.Status = matches[i]
}
}
return res
}
func newCLAMDTcpConn(address string) (*CLAMDConn, error) {
conn, err := net.DialTimeout("tcp", address, TCP_TIMEOUT)
if err != nil {
if nerr, isOk := err.(net.Error); isOk && nerr.Timeout() {
return nil, nerr
}
return nil, err
}
return &CLAMDConn{Conn: conn}, err
}
func newCLAMDUnixConn(address string) (*CLAMDConn, error) {
conn, err := net.Dial("unix", address)
if err != nil {
return nil, err
}
return &CLAMDConn{Conn: conn}, err
}

View File

@@ -0,0 +1,72 @@
/*
Open Source Initiative OSI - The MIT License (MIT):Licensing
The MIT License (MIT)
Copyright (c) 2013 DutchCoders <http://github.com/dutchcoders/>
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
package main
import (
_ "bytes"
"fmt"
"github.com/dutchcoders/go-clamd"
)
func main() {
fmt.Println("Made with <3 DutchCoders")
c := clamd.NewClamd("/tmp/clamd.socket")
_ = c
/*
reader := bytes.NewReader(clamd.EICAR)
response, err := c.ScanStream(reader)
for s := range response {
fmt.Printf("%v %v\n", s, err)
}
response, err = c.ScanFile(".")
for s := range response {
fmt.Printf("%v %v\n", s, err)
}
response, err = c.Version()
for s := range response {
fmt.Printf("%v %v\n", s, err)
}
*/
err := c.Ping()
fmt.Printf("Ping: %v\n", err)
stats, err := c.Stats()
fmt.Printf("%v %v\n", stats, err)
err = c.Reload()
fmt.Printf("Reload: %v\n", err)
// response, err = c.Shutdown()
// fmt.Println(response)
}

23
vendor/github.com/dutchcoders/go-virustotal/.gitignore generated vendored Normal file
View File

@@ -0,0 +1,23 @@
# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so
# Folders
_obj
_test
# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out
*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*
_testmain.go
*.exe
*.test

View File

@@ -0,0 +1,10 @@
language: go
go:
- 1.1
- 1.2
- 1.3
- release
- tip
script:
- go test -v ./...

21
vendor/github.com/dutchcoders/go-virustotal/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2014 dutchcoders
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

38
vendor/github.com/dutchcoders/go-virustotal/README.md generated vendored Normal file
View File

@@ -0,0 +1,38 @@
go-virustotal
=============
VirusTotal public api interface implementation in Golang.
[![GoDoc](https://godoc.org/github.com/dutchcoders/go-virustotal?status.svg)](https://godoc.org/github.com/dutchcoders/go-virustotal)
[![Build Status](https://travis-ci.org/dutchcoders/go-virustotal.svg?branch=master)](https://travis-ci.org/dutchcoders/go-virustotal)
Usage
=====
You can also set the environment variable VIRUSTOTAL_APIKEY to the api key.
```
go run ./bin/vt.go --apikey {key} (--debug) scan {file} {file} ...
go run ./bin/vt.go --apikey {key} (--debug) rescan {hash} {hash} ...
go run ./bin/vt.go --apikey {key} (--debug) report 99017f6eebbac24f351415dd410d522d
go run ./bin/vt.go --apikey {key} (--debug) scan-url {url} {url} ...
go run ./bin/vt.go --apikey {key} (--debug) report-url www.google.com
go run ./bin/vt.go --apikey {key} (--debug) ipaddress 90.156.201.27
go run ./bin/vt.go --apikey {key} (--debug) domain 027.ru
go run ./bin/vt.go --apikey {key} (--debug) --resource 99017f6eebbac24f351415dd410d522d comment "How to disinfect you from this file... #disinfect #zbot"
```
## Contributions
Contributions are welcome.
## Creators
**Remco Verhoef**
- <https://twitter.com/remco_verhoef>
- <https://twitter.com/dutchcoders>
## Copyright and license
Code and documentation copyright 2011-2014 Remco Verhoef. Code released under [the MIT license](LICENSE).

View File

@@ -0,0 +1,361 @@
/*
Open Source Initiative OSI - The MIT License (MIT):Licensing
The MIT License (MIT)
Copyright (c) 2013 DutchCoders <http://github.com/dutchcoders/>
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
package virustotal
import (
"bytes"
"encoding/json"
"fmt"
"io"
"io/ioutil"
"mime/multipart"
"net/http"
"net/url"
"path/filepath"
"strings"
)
type VirusTotal struct {
apikey string
}
type VirusTotalResponse struct {
ResponseCode int `json:"response_code"`
Message string `json:"verbose_msg"`
}
type ScanResponse struct {
VirusTotalResponse
ScanId string `json:"scan_id"`
Sha1 string `json:"sha1"`
Resource string `json:"resource"`
Sha256 string `json:"sha256"`
Permalink string `json:"permalink"`
Md5 string `json:"md5"`
}
type FileScan struct {
Detected bool `json:"detected"`
Version string `json:"version"`
Result string `json:"result"`
Update string `json:"update"`
}
type ReportResponse struct {
VirusTotalResponse
Resource string `json:"resource"`
ScanId string `json:"scan_id"`
Sha1 string `json:"sha1"`
Sha256 string `json:"sha256"`
Md5 string `json:"md5"`
Scandate string `json:"scan_date"`
Positives int `json:"positives"`
Total int `json:"total"`
Permalink string `json:"permalink"`
Scans map[string]FileScan `json:"scans"`
}
func (sr *ScanResponse) String() string {
return fmt.Sprintf("scanid: %s, resource: %s, permalink: %s, md5: %s", sr.ScanId, sr.Resource, sr.Permalink, sr.Md5)
}
type ScanUrlResponse struct {
ScanResponse
}
type RescanResponse struct {
ScanResponse
}
func (sr *RescanResponse) String() string {
return fmt.Sprintf("scanid: %s, resource: %s, permalink: %s, md5: %s", sr.ScanId, sr.Resource, sr.Permalink, sr.Md5)
}
type DetectedUrl struct {
ScanDate string `json:"scan_date"`
Url string `json:"url"`
Positives int `json:"positives"`
Total int `json:"total"`
}
type Resolution struct {
LastResolved string `json:"last_resolved"`
Hostname string `json:"hostname"`
}
type IpAddressReportResponse struct {
VirusTotalResponse
Resolutions []Resolution `json:"resolutions"`
DetectedUrls []DetectedUrl `json:"detected_urls"`
}
type DomainReportResponse struct {
VirusTotalResponse
Resolutions []Resolution `json:"resolutions"`
DetectedUrls []DetectedUrl `json:"detected_urls"`
}
type CommentResponse struct {
VirusTotalResponse
}
func NewVirusTotal(apikey string) (*VirusTotal, error) {
vt := &VirusTotal{apikey: apikey}
return vt, nil
}
func (vt *VirusTotal) DomainReport(domain string) (*DomainReportResponse, error) {
u, err := url.Parse("https://www.virustotal.com/vtapi/v2/domain/report")
u.RawQuery = url.Values{"apikey": {vt.apikey}, "domain": {domain}}.Encode()
resp, err := http.Get(u.String())
if err != nil {
return nil, err
}
defer resp.Body.Close()
contents, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, err
}
var domainReportResponse = &DomainReportResponse{}
err = json.Unmarshal(contents, &domainReportResponse)
return domainReportResponse, err
}
func (vt *VirusTotal) ScanUrl(url2 *url.URL) (*ScanResponse, error) {
u, err := url.Parse("https://www.virustotal.com/vtapi/v2/url/scan")
params := url.Values{"apikey": {vt.apikey}, "url": {url2.String()}}
resp, err := http.PostForm(u.String(), params)
if err != nil {
return nil, err
}
defer resp.Body.Close()
contents, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, err
}
var scanResponse = &ScanResponse{}
err = json.Unmarshal(contents, &scanResponse)
return scanResponse, err
}
func (vt *VirusTotal) Report(resource string) (*ReportResponse, error) {
u, err := url.Parse("https://www.virustotal.com/vtapi/v2/file/report")
params := url.Values{"apikey": {vt.apikey}, "resource": {resource}}
resp, err := http.PostForm(u.String(), params)
if err != nil {
return nil, err
}
defer resp.Body.Close()
contents, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, err
}
var reportResponse = &ReportResponse{}
err = json.Unmarshal(contents, &reportResponse)
return reportResponse, err
}
func (vt *VirusTotal) ReportUrl(url2 *url.URL) (*ReportResponse, error) {
params := url.Values{"apikey": {vt.apikey}, "resource": {url2.String()}}
u, err := url.Parse("https://www.virustotal.com/vtapi/v2/url/report")
resp, err := http.PostForm(u.String(), params)
if err != nil {
return nil, err
}
defer resp.Body.Close()
contents, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, err
}
var reportResponse = &ReportResponse{}
err = json.Unmarshal(contents, &reportResponse)
return reportResponse, err
}
func (vt *VirusTotal) Comment(resource string, comment string) (*CommentResponse, error) {
u, err := url.Parse("https://www.virustotal.com/vtapi/v2/comments/put")
params := url.Values{"apikey": {vt.apikey}, "resource": {resource}, "comment": {comment}}
resp, err := http.PostForm(u.String(), params)
if err != nil {
return nil, err
}
defer resp.Body.Close()
contents, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, err
}
var commentResponse = &CommentResponse{}
err = json.Unmarshal(contents, &commentResponse)
return commentResponse, err
}
func (vt *VirusTotal) IpAddressReport(ip string) (*IpAddressReportResponse, error) {
u, err := url.Parse("http://www.virustotal.com/vtapi/v2/ip-address/report")
u.RawQuery = url.Values{"apikey": {vt.apikey}, "ip": {ip}}.Encode()
resp, err := http.Get(u.String())
if err != nil {
return nil, err
}
defer resp.Body.Close()
contents, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, err
}
var ipAddressReportResponse = &IpAddressReportResponse{}
err = json.Unmarshal(contents, &ipAddressReportResponse)
return ipAddressReportResponse, err
}
func (vt *VirusTotal) Rescan(hash []string) (*RescanResponse, error) {
resource := strings.Join(hash, ",")
resp, err := http.PostForm("https://www.virustotal.com/vtapi/v2/file/rescan", url.Values{"apikey": {vt.apikey}, "resource": {resource}})
if err != nil {
return nil, err
}
defer resp.Body.Close()
contents, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, err
}
var rescanResponse = &RescanResponse{}
err = json.Unmarshal(contents, &rescanResponse)
return rescanResponse, err
}
func (vt *VirusTotal) Scan(path string, file io.Reader) (*ScanResponse, error) {
params := map[string]string{
"apikey": vt.apikey,
}
request, err := newfileUploadRequest("http://www.virustotal.com/vtapi/v2/file/scan", params, path, file)
if err != nil {
return nil, err
}
client := &http.Client{}
resp, err := client.Do(request)
if err != nil {
return nil, err
}
defer resp.Body.Close()
contents, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, err
}
var scanResponse = &ScanResponse{}
err = json.Unmarshal(contents, &scanResponse)
return scanResponse, err
}
// Creates a new file upload http request with optional extra params
func newfileUploadRequest(uri string, params map[string]string, path string, file io.Reader) (*http.Request, error) {
body := &bytes.Buffer{}
writer := multipart.NewWriter(body)
for key, val := range params {
_ = writer.WriteField(key, val)
}
part, err := writer.CreateFormFile("file", filepath.Base(path))
if err != nil {
return nil, err
}
_, err = io.Copy(part, file)
err = writer.Close()
if err != nil {
return nil, err
}
req, err := http.NewRequest("POST", uri, body)
req.Header.Set("Content-Type", writer.FormDataContentType())
return req, err
}

View File

@@ -0,0 +1,3 @@
{
"directory": "transfersh-web/bower_components"
}

View File

@@ -0,0 +1,14 @@
build/
pkg/
dist/
bin/
*.pyc
*.egg-info/
.tmp
.vagrant
bower_components/
node_modules/
letsencrypt.cache

View File

@@ -0,0 +1,308 @@
'use strict';
// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to match all subfolders:
// 'test/spec/**/*.js'
module.exports = function (grunt) {
// load all grunt tasks
require('load-grunt-tasks')(grunt);
// show elapsed time at the end
require('time-grunt')(grunt);
// configurable paths
var yeomanConfig = {
app: require('./bower.json').appPath || 'src',
dist: 'dist/'
};
grunt.initConfig({
yeoman: yeomanConfig,
watch: {
less: {
files: ['<%= yeoman.app %>/styles/{,*/}*.less'],
tasks: ['less']
},
gruntfile: {
files: ['Gruntfile.js']
},
includes: {
files: ['<%= yeoman.app %>/*.html', '.tmp/*.html'],
tasks: ['includes:server']
},
livereload: {
options: {
livereload: '<%= connect.options.livereload %>'
},
files: [
'<%= yeoman.app %>/*.html',
'{.tmp,<%= yeoman.app %>}/styles/{,*/}*.css',
'{.tmp,<%= yeoman.app %>}/scripts/{,*/}*.js',
'<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
],
tasks: ['includes:server']
}
},
connect: {
options: {
port: 9000,
// change this to '0.0.0.0' to access the server from outside
hostname: 'localhost',
livereload: 35729
},
livereload: {
options: {
open: true,
base: [
'.tmp',
'<%= yeoman.app %>'
]
}
},
test: {
options: {
port: 9001,
base: [
'.tmp',
'test',
'<%= yeoman.app %>'
]
}
},
dist: {
options: {
base: '<%= yeoman.dist %>'
}
}
},
clean: {
dist: {
files: [{
dot: true,
src: [
'.tmp',
'<%= yeoman.dist %>/*',
'!<%= yeoman.dist %>/.git*'
]
}]
},
server: '.tmp'
},
jshint: {
options: {
jshintrc: '.jshintrc',
reporter: require('jshint-stylish')
},
all: [
'Gruntfile.js',
'<%= yeoman.app %>/scripts/{,*/}*.js',
'!<%= yeoman.app %>/scripts/vendor/*',
'test/spec/{,*/}*.js'
]
},
less: {
dist: {
files: {
'<%= yeoman.app %>/styles/main.css': ['<%= yeoman.app %>/styles/main.less']
},
options: {
sourceMap: true,
sourceMapFilename: '<%= yeoman.app %>/styles/main.css.map',
sourceMapBasepath: '<%= yeoman.app %>/',
sourceMapRootpath: '/'
}
}
},
includes: {
build: {
cwd: '<%= yeoman.app %>',
src: ['*.html', 'includes/*.html'],
dest: '<%= yeoman.dist %>',
options: {
flatten: true,
banner: ''
}
},
server: {
cwd: '<%= yeoman.app %>',
src: ['*.html', 'includes/*.html'],
dest: '.tmp/',
options: {
flatten: true,
banner: ''
}
}
},
// not used since Uglify task does concat,
// but still available if needed
/*concat: {
dist: {}
},*/
// not enabled since usemin task does concat and uglify
// check index.html to edit your build targets
// enable this task if you prefer defining your build targets here
/*uglify: {
dist: {}
},*/
rev: {
dist: {
files: {
src: [
'<%= yeoman.dist %>/scripts/{,*/}*.js',
'<%= yeoman.dist %>/styles/{,*/}*.css',
'<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
'<%= yeoman.dist %>/fonts/{,*/}*.*'
]
}
}
},
useminPrepare: {
html: '<%= yeoman.app %>/*.html',
options: {
dest: '<%= yeoman.dist %>'
}
},
usemin: {
html: ['<%= yeoman.dist %>/{,*/}*.html'],
css: ['<%= yeoman.dist %>/styles/{,*/}*.css'],
options: {
dirs: ['<%= yeoman.dist %>']
}
},
imagemin: {
dist: {
files: [{
expand: true,
cwd: '<%= yeoman.app %>/images',
src: '{,*/}*.{png,jpg,jpeg}',
dest: '<%= yeoman.dist %>/images'
}]
}
},
cssmin: {
dist: {
files: {
'<%= yeoman.dist %>/styles/main.css': [
'.tmp/styles/{,*/}*.css',
'<%= yeoman.app %>/styles/{,*/}*.css'
]
}
}
},
htmlmin: {
dist: {
options: {
/*removeCommentsFromCDATA: true,
// https://github.com/yeoman/grunt-usemin/issues/44
//collapseWhitespace: true,
collapseBooleanAttributes: true,
removeAttributeQuotes: true,
removeRedundantAttributes: true,
useShortDoctype: true,
removeEmptyAttributes: true,
removeOptionalTags: true*/
},
files: [{
expand: true,
cwd: '<%= yeoman.app %>',
src: '*.html',
dest: '<%= yeoman.dist %>'
}]
}
},
copy: {
dist: {
files: [{
expand: true,
dot: true,
cwd: '<%= yeoman.app %>',
dest: '<%= yeoman.dist %>',
src: [
'*.{ico,png,txt}',
'fonts/{,*/}*.*',
'.htaccess',
'index.txt',
'404.txt',
'images/{,*/}*.{webp,gif,svg}'
]
}]
},
server: {
files: [{
expand: true,
dot: true,
cwd: '<%= yeoman.app %>/bower_components/font-awesome/fonts/',
dest: '<%= yeoman.app %>/fonts/font-awesome',
src: ['*']
}, {
expand: true,
dot: true,
cwd: '<%= yeoman.app %>/bower_components/bootstrap/dist/fonts/',
dest: '<%= yeoman.app %>/fonts/glyphicons',
src: ['*']
}]
}
},
concurrent: {
dist: [
'less',
'imagemin',
'htmlmin'
]
}
});
grunt.registerTask('serve', function (target) {
if (target === 'dist') {
return grunt.task.run(['build', 'connect:dist:keepalive']);
}
grunt.task.run([
'clean:server',
'less',
'includes:server',
'copy:server',
'connect:livereload',
'watch'
]);
});
grunt.registerTask('server', function () {
grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
grunt.task.run(['serve']);
});
grunt.registerTask('test', [
'clean:server',
'less',
'copy:server',
'connect:test',
]);
grunt.registerTask('build', [
'clean:dist',
'copy:server',
'useminPrepare',
'concurrent',
'cssmin',
'concat',
'includes:build',
'uglify',
'copy',
'usemin',
]);
grunt.registerTask('default', [
'jshint',
'test',
'build'
]);
};

202
vendor/github.com/dutchcoders/transfer.sh-web/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,202 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@@ -0,0 +1,5 @@
package web
//go:generate go-bindata -pkg web -o bindata_gen.go -ignore \.map\$ dist/...
var Prefix = "dist"

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,25 @@
{
"name": "transfer.sh",
"version": "0.0.0",
"moduleType": [
"node"
],
"private": true,
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"transfersh-web/bower_components",
"test",
"tests"
],
"dependencies": {
"bootstrap": "~3.0.0",
"modernizr": "~2.6.2",
"uri.js": "~1.14.1",
"typed.js": "https://github.com/mattboldt/typed.js.git",
"realistic-typewriter.js": "https://github.com/fardjad/realistic-typewriter.js.git",
"animate.less": "*",
"jquery-waypoints": "https://github.com/imakewebthings/jquery-waypoints.git#~2.0.5"
}
}

View File

@@ -0,0 +1,34 @@
{
"name": "transfer.sh",
"version": "0.0.0",
"dependencies": {
"wiredep": "^1.8.6"
},
"devDependencies": {
"grunt": "~0.4.5",
"grunt-concurrent": "~1.0.0",
"grunt-contrib-clean": "~0.6.0",
"grunt-contrib-concat": "~0.5.0",
"grunt-contrib-connect": "~0.8.0",
"grunt-contrib-copy": "~0.6.0",
"grunt-contrib-cssmin": "~0.10.0",
"grunt-contrib-htmlmin": "~0.3.0",
"grunt-contrib-imagemin": "0.8.1",
"grunt-contrib-jshint": "~0.10.0",
"grunt-contrib-less": "~0.11.4",
"grunt-contrib-uglify": "~0.6.0",
"grunt-contrib-watch": "~0.6.1",
"grunt-include-replace": "^2.0.0",
"grunt-includes": "^0.4.5",
"grunt-rev": "~0.1.0",
"grunt-svgmin": "1.0.0",
"grunt-usemin": "~2.4.0",
"jshint-stylish": "~1.0.0",
"load-grunt-tasks": "~0.6.0",
"matchdep": "~0.3.0",
"time-grunt": "~1.0.0"
},
"engines": {
"node": ">=0.8.0"
}
}