-
Notifications
You must be signed in to change notification settings - Fork 411
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Send termshark's current pcap with magic wormhole
This commit implements a new console command, "wormhole", that allows you to transfer termshark's open pcap using magic wormhole - https://github.com/magic-wormhole/magic-wormhole. Magic wormhole is a secure and convenient way of getting files from one machine to another. The sender generates a wormhole code e.g. $ wormhole send foo Sending 1.9 kB file named 'foo' Wormhole code is: 9-phonetic-goldfish On the other computer, please run: wormhole receive 9-phonetic-goldfish and then the receiver references the code: $ wormhole receive 9-phonetic-goldfish Receiving file (1.9 kB) into: foo ok? (y/N): y ... Received file written to foo When you run termshark's wormhole command, termshark generates a wormhole code and displays it in a dialog. You can then use magic wormhole locally to transfer the pcap to your desktop. The purpose of this is to make it easy to get a pcap into Wireshark. Termshark can be fine for a quick analysis, but Wireshark is much more powerful :-) To make this process even easier, you can pair this new command with the tmux-wormhole tmux plugin. You can find it here: https://github.com/gcla/tmux-wormhole. This can help if your tmux is local, and within that tmux you are sshed to a remote machine and using termshark there. As long as the remote machine has internet access, you should be able to magic-wormhole the pcap. Once you see termshark's wormhole code on the screen, hit the plugin hotkey - C-b w by default - and the plugin will detect the code and let you download and open the pcap. If your desktop association for pcap files is Wireshark, then it should open in Wireshark. Here's a demo of it in action: https://drive.google.com/file/d/16qCXyjWS8smzjOeJLGZiplib3frgK4F5/view?usp=sharing This implementation uses psanford/wormhole-william, a Go implementation of the magic wormhole protocol.
- Loading branch information
Showing
8 changed files
with
514 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// Copyright 2019-2020 Graham Clark. All rights reserved. Use of this source | ||
// code is governed by the MIT license that can be found in the LICENSE | ||
// file. | ||
|
||
// Package ui contains user-interface functions and helpers for termshark. | ||
package ui | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/gcla/gowid" | ||
"github.com/gcla/gowid/widgets/dialog" | ||
"github.com/gcla/gowid/widgets/framed" | ||
"github.com/gcla/termshark/v2" | ||
"github.com/gcla/termshark/v2/widgets/wormhole" | ||
log "github.com/sirupsen/logrus" | ||
) | ||
|
||
//====================================================================== | ||
|
||
var CurrentWormholeWidget *wormhole.Widget | ||
|
||
func openWormhole(app gowid.IApp) { | ||
|
||
var numWords int | ||
if CurrentWormholeWidget == nil { | ||
numWords = termshark.ConfInt("main.wormhole-length", 2) | ||
} else { | ||
numWords = CurrentWormholeWidget.CodeLength() | ||
} | ||
|
||
if CurrentWormholeWidget == nil { | ||
var err error | ||
CurrentWormholeWidget, err = wormhole.New(Loader.PcapPdml, app, wormhole.Options{ | ||
ErrorHandler: func(err error, app gowid.IApp) { | ||
msg := fmt.Sprintf("Problem sending pcap: %v", err) | ||
log.Error(msg) | ||
OpenError(msg, app) | ||
}, | ||
CodeLength: numWords, | ||
TransitRelayAddress: termshark.ConfString("main.wormhole-transit-relay", ""), | ||
RendezvousURL: termshark.ConfString("main.wormhole-rendezvous-url", ""), | ||
}) | ||
if err != nil { | ||
msg := fmt.Sprintf("%v", err) | ||
log.Error(msg) | ||
OpenError(msg, app) | ||
return | ||
} | ||
} | ||
|
||
wormholeDialog := dialog.New( | ||
framed.NewSpace( | ||
CurrentWormholeWidget, | ||
), | ||
dialog.Options{ | ||
Buttons: []dialog.Button{dialog.CloseD}, | ||
NoShadow: true, | ||
BackgroundStyle: gowid.MakePaletteRef("dialog"), | ||
BorderStyle: gowid.MakePaletteRef("dialog"), | ||
ButtonStyle: gowid.MakePaletteRef("dialog-button"), | ||
}, | ||
) | ||
|
||
// space for the frame; then XXX-word1-word2-... - max length of word in | ||
// pgp word list is 11. Yuck. | ||
maxl := (2 * 3) + len(" - cancelled!") + wormhole.UpperBoundOnLength(numWords) | ||
|
||
wormholeDialog.Open(appView, ratioupto(0.8, maxl), app) | ||
} | ||
|
||
//====================================================================== | ||
// Local Variables: | ||
// mode: Go | ||
// fill-column: 110 | ||
// End: |
Oops, something went wrong.