initial commit

This commit is contained in:
erinn 2018-10-09 16:49:20 -07:00
parent f90c9080ac
commit caf9f0e558
5 changed files with 110 additions and 84 deletions

9
LICENSE Normal file
View File

@ -0,0 +1,9 @@
MIT License
Copyright (c) 2018 Open Privacy Research Society
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.

28
README.md Normal file
View File

@ -0,0 +1,28 @@
## sendafriend
quickly send files between machines by piping them on the command line, with bidirectional authentication and metadata resistance via tor (built on cwtch)
includes a way to quickly exchange onion addresses using a low-entropy shared secret (using pairwise socialist millionaires' protocol on a bbs)
note that we only support files up to 64k right now, sorry :( (a fix for this is in the works)
## installation
requires you to have go installed and your gopath configured correctly (sorry)
`go get openprivacy.ca/openprivacy/sendafriend`
## usage
one-time setup, on both machines:
`sendafriend pair [make-up-a-name]`
activate the receiver first:
`sendafriend receive [made-up-name] > file.ext`
then the sender:
`sendafriend send [made-up-name] < file.ext`
## <3
made with love by errorinn

44
main.go
View File

@ -1,16 +1,16 @@
package main
import (
"bufio"
"cwtch.im/cwtch/model"
libpeer "cwtch.im/cwtch/peer"
"os"
"fmt"
"github.com/sethvargo/go-diceware/diceware"
"bufio"
"math/big"
"time"
"log"
"io/ioutil"
"cwtch.im/cwtch/model"
"log"
"math/big"
"os"
"time"
)
func driftoff() {
@ -80,7 +80,7 @@ func main() {
os.Exit(1)
}
_, exists := peer.GetProfile().GetCustomAttribute(os.Args[3]+"_name")
_, exists := peer.GetProfile().GetCustomAttribute(os.Args[3] + "_name")
if !exists {
fmt.Printf("um you don't have anyone with that onion address in your list")
os.Exit(1)
@ -91,7 +91,7 @@ func main() {
//todo: unset old one
fmt.Printf("okay, i'll remember that %v is named %v\n", os.Args[3], os.Args[2])
case "info":
fmt.Printf("your name is currently %v and your address is currently %v\n", peer.GetProfile().Name, peer.GetProfile().Onion);
fmt.Printf("your name is currently %v and your address is currently %v\n", peer.GetProfile().Name, peer.GetProfile().Onion)
case "list":
contacts := peer.GetContacts()
for i := range contacts {
@ -104,7 +104,7 @@ func main() {
os.Exit(1)
}
_, exists := peer.GetProfile().GetCustomAttribute(os.Args[3]+"_name")
_, exists := peer.GetProfile().GetCustomAttribute(os.Args[3] + "_name")
if exists {
fmt.Printf("woah you already have someone named %v\n", os.Args[3])
os.Exit(1)
@ -119,7 +119,7 @@ func main() {
os.Exit(1)
}
onion, exists := peer.GetProfile().GetCustomAttribute(os.Args[2]+"_onion")
onion, exists := peer.GetProfile().GetCustomAttribute(os.Args[2] + "_onion")
if !exists {
fmt.Printf("you don't seem to have a contact named %v\n", os.Args[2])
}
@ -135,7 +135,7 @@ func main() {
fmt.Printf("sending data...\n")
reader := bufio.NewReader(os.Stdin)
packet := make([]byte, 1024)
packet := make([]byte, 65531)
br, _ := reader.Read(packet)
connection.SendPacket(packet[:br])
@ -145,13 +145,13 @@ func main() {
os.Exit(1)
}
_, exists := peer.GetProfile().GetCustomAttribute(os.Args[2]+"_name")
_, exists := peer.GetProfile().GetCustomAttribute(os.Args[2] + "_name")
if exists {
fmt.Printf("woah you already have someone named %v\n", os.Args[2])
os.Exit(1)
}
verifyOnion, exists := peer.GetProfile().GetCustomAttribute(os.Args[2]+"_onion")
verifyOnion, exists := peer.GetProfile().GetCustomAttribute(os.Args[2] + "_onion")
if !exists {
fmt.Fprintf(os.Stderr, "hmm you don't have a contact named %v\n", os.Args[2])
os.Exit(1)
@ -170,7 +170,10 @@ func main() {
peer.SetPeerDataHandler(processData)
fmt.Fprintf(os.Stderr, "waiting for %v to send...\n", os.Args[2])
peer.Listen()
err = peer.Listen()
if err != nil {
fmt.Printf("error listening for connections: %v\n", err)
}
case "hide":
if len(os.Args) != 3 {
fmt.Fprintf(os.Stderr, "example: sendafriend hide bob\n")
@ -181,7 +184,7 @@ func main() {
fmt.Printf("enter a secret that only the two of you would know [%v]: ", suggestedSecret[0])
in := bufio.NewReader(os.Stdin)
secret, _ := in.ReadString('\n')
secret = secret[:len(secret) - 1]
secret = secret[:len(secret)-1]
if secret == "" {
secret = suggestedSecret[0]
@ -234,7 +237,10 @@ func main() {
return tlv2arr(out)
}
ephemeralPeer.SetPeerDataHandler(processData)
ephemeralPeer.Listen()
err = ephemeralPeer.Listen()
if err != nil {
fmt.Printf("error running ephemeral onion: %v\n", err)
}
fmt.Println("press enter to cancel the game and exit")
reader := bufio.NewReader(os.Stdin)
@ -248,7 +254,7 @@ func main() {
fmt.Print("enter a secret that only the two of you would know: ")
in := bufio.NewReader(os.Stdin)
secret, _ := in.ReadString('\n')
secret = secret[:len(secret) - 1]
secret = secret[:len(secret)-1]
ephemeralPeer, err := libpeer.NewCwtchPeer("Alice", "alicepass", "")
if err != nil {
@ -269,7 +275,7 @@ func main() {
messages := group.GetTimeline()
for i := len(messages) - 1; i >= 0; i-- {
fmt.Printf("checking advert %d/%d...\n", len(messages) - i, len(messages))
fmt.Printf("checking advert %d/%d...\n", len(messages)-i, len(messages))
//fmt.Printf("%v <%v> %v\n", messages[i].Timestamp, messages[i].PeerID, messages[i].Message)
if messages[i].Message == "be gay do crimes" {
@ -286,4 +292,4 @@ func main() {
}
peer.Save()
}
}

112
smp.go
View File

@ -1,3 +1,35 @@
/*
Copyright (c) 2009 The Go Authors. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
//
// original: https://github.com/golang/crypto/tree/e3636079e1a4c1f337f212cc5cd2aca108f6c900/otr
//
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
@ -9,34 +41,30 @@
package main
import (
libpeer "cwtch.im/cwtch/peer"
import (
"bytes"
"crypto/sha256"
"hash"
"math/big"
"errors"
"io"
"crypto/rand"
"encoding/base64"
"strconv"
"crypto/aes"
"crypto/cipher"
"crypto/hmac"
"crypto/subtle"
"crypto/sha1"
"crypto/dsa"
"crypto/hmac"
"crypto/rand"
"crypto/sha1"
"crypto/sha256"
"crypto/subtle"
libpeer "cwtch.im/cwtch/peer"
"encoding/base64"
"encoding/hex"
"errors"
"fmt"
"hash"
"io"
"math/big"
"os"
"strconv"
"time"
)
func arr2tlv(data[] byte) tlv {
func arr2tlv(data []byte) tlv {
var typ, len uint16
typ = (uint16(data[0]) << 8) + uint16(data[1])
len = (uint16(data[2]) << 8) + uint16(data[3])
@ -44,13 +72,13 @@ func arr2tlv(data[] byte) tlv {
}
func tlv2arr(t tlv) []byte {
ret := make([]byte, 4 + len(t.data))
ret := make([]byte, 4+len(t.data))
ret[0] = byte(t.typ >> 8)
ret[1] = byte(t.typ & 0xFF)
ret[2] = byte(t.length >> 8)
ret[3] = byte(t.length & 0xFF)
for i := 0; i < len(t.data); i++ {
ret[4 + i] = t.data[i]
ret[4+i] = t.data[i]
}
return ret
}
@ -101,12 +129,6 @@ func doSMP(onion string, secret string, friendname string, longtermonion string)
return wishandaprayer, success
}
type smpFailure string
func (s smpFailure) Error() string {
@ -661,44 +683,6 @@ func hashMPIs(h hash.Hash, magic byte, mpis ...*big.Int) []byte {
return h.Sum(nil)
}
// SecurityChange describes a change in the security state of a Conversation.
type SecurityChange int

View File

@ -1 +0,0 @@
hmph