Exemplo n.º 1
0
func returnPw(pwch chan string) {
	var pwd string
	select {
	case pw := <-pwch:
		pwd = pw
	case <-time.After(750 * time.Millisecond):
		say("Generating...")
		pwd = <-pwch
	}

	if *noTerminal {
		fmt.Print(pwd)
		return
	}

	before, err := clipboard.ReadAll()
	clipboard.WriteAll(pwd)
	say("\nPassword copied to clipboard! ")
	time.Sleep(5 * time.Second)
	say("Cleaning clipboard in 5 seconds...")
	time.Sleep(5 * time.Second)
	if err != nil {
		clipboard.WriteAll("")
	} else {
		clipboard.WriteAll(before)
	}
	say("\n...again? or CTRL+C\n")
}
Exemplo n.º 2
0
func writeToClipboard(buffer *bytes.Buffer) {
	clipboardOutput := buffer.String()
	if clipboardOutput != "" {
		clipboard.WriteAll(clipboardOutput)
		fmt.Printf("nw: wrote \"%s\" to clipboard\n", clipboardOutput)
	}
}
Exemplo n.º 3
0
Arquivo: add.go Projeto: schmich/ward
func (app *App) runAdd(login, realm, note string, copyPassword bool) {
	db := app.openStore()
	defer db.Close()

	if login == "" {
		login = readInput("Login: "******"Password")

	if realm == "" {
		realm = readInput("Realm: ")
	}

	if note == "" {
		note = readInput("Note: ")
	}

	db.AddCredential(&store.Credential{
		Login:    login,
		Password: password,
		Realm:    realm,
		Note:     note,
	})

	printSuccess("Credential added. ")

	if copyPassword {
		clipboard.WriteAll(password)
		fmt.Println("Password copied to the clipboard.")
	} else {
		fmt.Println()
	}
}
Exemplo n.º 4
0
func (yt *YouTube) generateOauthURLAndExit() {
	// Redirect user to Google's consent page to ask for permission
	// for the scopes specified above.
	url := yt.config.AuthCodeURL("state", oauth2.AccessTypeOffline, oauth2.ApprovalForce)
	clipboard.WriteAll(url)
	log.Fatalln("Visit the following URL to generate an auth code, then rerun with -auth=<code> (It has also been copied to your clipboard):\n%s", url)
}
Exemplo n.º 5
0
func add(name string, password []byte) error {
	clipboard.WriteAll(string(password))

	p := Password{}
	p.Salt = randBytes(8)

	key = pbkdf2.Key(key, p.Salt, 4096, 32, sha1.New)

	session, err := aes.NewCipher(key)
	if err != nil {
		return err
	}
	password = pad(password)

	pass_ciphered := make([]byte, aes.BlockSize+len(password))
	iv := pass_ciphered[:aes.BlockSize]
	if _, err := io.ReadFull(rand.Reader, iv); err != nil {
		return err
	}

	mode := cipher.NewCBCEncrypter(session, iv)
	mode.CryptBlocks(pass_ciphered[aes.BlockSize:], password)
	p.Pass = pass_ciphered

	logins[name] = p
	return nil
}
Exemplo n.º 6
0
func processClipboard() {
	val, _ := clipboard.ReadAll()
	if lastClipboardValue != val {
		lastClipboardValue = val
		found := false
		for _, urlPattern := range urls {
			m, _ := regexp.MatchString(
				"\\A"+strings.Replace(urlPattern, "*", "(.*)", -1)+"\\z",
				val)
			if m {
				found = true
				break
			}
		}
		if found {
			go func() {
				min := minify(val)
				if len(min) > 0 {
					clipboard.WriteAll(min)
					lastClipboardValue = min
				}
			}()
		}
	}
}
Exemplo n.º 7
0
func Example() {
	clipboard.WriteAll("日本語")
	text, _ := clipboard.ReadAll()
	fmt.Println(text)

	// Output:
	// 日本語
}
Exemplo n.º 8
0
func writeClipBoard() {
	shortened := <-shortenChan
	err := clipboard.WriteAll(shortened)
	if err != nil {
		log.Fatal(err)
	}
	writerChan <- "wrote " + shortened + " to the clipboard\n"
}
Exemplo n.º 9
0
// Copy the selection to the system clipboard
func (v *View) Copy() {
	if v.cursor.HasSelection() {
		if !clipboard.Unsupported {
			clipboard.WriteAll(v.cursor.GetSelection())
		} else {
			messenger.Error("Clipboard is not supported on your system")
		}
	}
}
Exemplo n.º 10
0
func action(context *cli.Context) {
	text := readClipboard()
	res := httpGet(text)
	json := unmarshal(res)
	if json.Errormessage != "" {
		fmt.Fprintln(os.Stderr, json.Errormessage)
		os.Exit(1)
	}
	clipboard.WriteAll(json.Shorturl)
	fmt.Println("Write the value to clipboard: " + json.Shorturl)
}
Exemplo n.º 11
0
func main() {

	out, err := ioutil.ReadAll(os.Stdin)
	if err != nil {
		panic(err)
	}

	if err := clipboard.WriteAll(string(out)); err != nil {
		panic(err)
	}
}
Exemplo n.º 12
0
func (b *BrowserCode) CopyToClipboard() error {
	encoded, err := b.Encode()
	if err != nil {
		return err
	}
	err = clipboard.WriteAll(encoded)
	if err != nil {
		return err
	}
	return nil

}
Exemplo n.º 13
0
func KeyFuncClearBefore(this *Buffer) Result {
	var killbuf bytes.Buffer
	for i := 0; i < this.Cursor; i++ {
		killbuf.WriteRune(this.Buffer[i])
	}
	clipboard.WriteAll(killbuf.String())
	keta := this.Delete(0, this.Cursor)
	Backspace(keta)
	this.Cursor = 0
	this.Repaint(0, keta)
	return CONTINUE
}
Exemplo n.º 14
0
func copyPass(siteName string) {
	decrypted, _ := getDecryptedData()
	value, ok := decrypted[siteName]
	if ok {
		err := clipboard.WriteAll(value)
		check(err)
		fmt.Println("The password has been copied to the clipboard")
	} else {
		fmt.Println("Not found")
		os.Exit(1)
	}
}
Exemplo n.º 15
0
Arquivo: add.go Projeto: schmich/ward
func (app *App) runGen(login, realm, note string, copyPassword bool, generator *passgen.Generator) {
	passwordChan := make(chan *passwordResult)
	go func() {
		password, err := generator.Generate()
		passwordChan <- &passwordResult{password: password, err: err}
	}()

	db := app.openStore()
	defer db.Close()

	if login == "" {
		login = readInput("Login: "******"" {
		realm = readInput("Realm: ")
	}

	if note == "" {
		note = readInput("Note: ")
	}

	var result *passwordResult
	select {
	case result = <-passwordChan:
		fmt.Println("Password: (generated)")
	default:
		fmt.Println("Password: (generating)")
		result = <-passwordChan
	}

	if result.err != nil {
		printError("%s\n", result.err)
		return
	}

	db.AddCredential(&store.Credential{
		Login:    login,
		Password: result.password,
		Realm:    realm,
		Note:     note,
	})

	printSuccess("Credential added. ")

	if copyPassword {
		clipboard.WriteAll(result.password)
		fmt.Println("Generated password copied to the clipboard.")
	} else {
		fmt.Println()
	}
}
Exemplo n.º 16
0
func main() {
	r := regexp.MustCompile(`^“([^“”]+)”[^“”]+Excerpt From:[^“”]+“[^“”]+” iBooks.`)
	for true {
		clipContent, _ := clipboard.ReadAll()
		matchedGroups := r.FindStringSubmatch(clipContent)
		if len(matchedGroups) > 0 {
			stripped := matchedGroups[1]
			clipboard.WriteAll(stripped)
			fmt.Println("\n\n" + stripped)
		}
		time.Sleep(50)
	}
}
Exemplo n.º 17
0
func copyThenClear(text string, d time.Duration) error {
	signals := make(chan os.Signal, 1)
	signal.Notify(signals, os.Interrupt, os.Kill)
	defer signal.Stop(signals)
	original, err := clipboard.ReadAll()
	if err != nil {
		return err
	}
	err = clipboard.WriteAll(text)
	if err != nil {
		return err
	}
	select {
	case <-signals:
	case <-time.After(d):
	}
	current, _ := clipboard.ReadAll()
	if current == text {
		return clipboard.WriteAll(original)
	}
	return nil
}
Exemplo n.º 18
0
func main() {
	var domain, salt, master, note string = "", "", "", ""
	var pass_length int = 14

	if len(os.Args) == 1 {
		fmt.Printf("Usage: %s domain [password-length]\n", os.Args[0])
		os.Exit(1)
	}

	if len(os.Args) > 1 {
		// We do have domain
		domain = strings.TrimSpace(os.Args[1])
		display_notes(domain)
	}

	if len(os.Args) > 2 {
		// We do have password length
		p_length, err := strconv.Atoi(os.Args[2])
		if err != nil {
			fmt.Printf("Password Length should be a number\n")
			os.Exit(1)
		}
		pass_length = p_length
	}

	reader := bufio.NewReader(os.Stdin)

	fmt.Printf("Enter salt. Hit enter to leave it blank: ")
	salt, _ = reader.ReadString('\n')
	salt = strings.TrimRight(salt, "\n")

	fmt.Printf("Enter note to save. Hit enter to leave it blank: ")
	note, _ = reader.ReadString('\n')
	note = strings.TrimRight(note, "\n")

	if len(note) > 0 {
		add_note(domain, note)
	}

	fmt.Printf("Enter Master password. Hit enter to abort: ")
	master = string(gopass.GetPasswdMasked()[:])

	if len(master) == 0 {
		os.Exit(1)
	}

	password := gen_pwd(domain+salt, master)[:pass_length]
	clipboard.WriteAll(password)
	fmt.Println(password, "copied to your clipboard")
}
Exemplo n.º 19
0
func cp(args []string) {
	if len(args) != 1 {
		fmt.Fprintln(os.Stderr, "Usage: passman cp <service>")
		return
	}
	services, err := loadServices(getPasswd())
	gobro.CheckErr(err, "Password invalid")
	service := services.Get(args[0])
	if service.Name != "" {
		clipboard.WriteAll(service.Password)
	} else {
		fmt.Printf("'%s' not found\n", args[0])
	}
}
Exemplo n.º 20
0
Arquivo: copy.go Projeto: schmich/ward
func (app *App) runCopy(query []string) {
	db := app.openStore()
	defer db.Close()

	credential := findCredential(db, query)
	if credential == nil {
		return
	}

	clipboard.WriteAll(credential.Password)
	identifier := formatCredential(credential)

	printSuccess("Password for %s copied to the clipboard.\n", identifier)
}
Exemplo n.º 21
0
//Execute runs the current command.
func (c *CopyCommand) Execute(w io.Writer, s Storage) {
	for _, list := range s.Lists {
		for key, entries := range list {
			if key == c.List || c.List == "" {
				for _, entry := range entries {
					for key, value := range entry {
						if key == c.Entry {
							clipboard.WriteAll(value)
						}
					}
				}
			}
		}
	}
}
Exemplo n.º 22
0
func (c *listCommand) Execute(args []string) (err error) {
	masker := func(x string) string {
		if c.Unmask {
			return x
		}
		if c.Clipboard {
			if err := clipboard.WriteAll(x); err != nil {
				fmt.Fprintf(os.Stderr, "error copying to clipboard: %s", err)
			}
		}
		return strings.Repeat("*", len(x))
	}

	db, err := v3.Open(c.Path, makePassphraseFn(c.Passphrase, nil))
	if err != nil {
		return err
	}

	var re *regexp.Regexp
	if c.Filter != "" {
		re, err = regexp.Compile(c.Filter)
		if err != nil {
			return err
		}
	}

	for _, record := range db.Records() {
		if re != nil &&
			!re.MatchString(record.Group()) &&
			!re.MatchString(record.Title()) {
			continue
		}
		fmt.Println("[", record.UUID(), "]")
		printFields([]fieldDescription{
			{"Title", record.Title()},
			{"Username", record.Username()},
			{"Password", masker(record.Password())},
			{"Notes", record.Notes()},
			{"Group", record.Group()},
			{"URL", record.URL()},
			{"Ctime", record.Ctime()},
			{"Atime", record.Atime()},
			{"Mtime", record.Mtime()},
		})
		fmt.Println()
	}
	return nil
}
Exemplo n.º 23
0
func addPass(siteName string, generatePass bool) {
	decrypted, auth := getDecryptedData()
	var sitePass string
	if generatePass {
		sitePass = generateRandomString(32)[:32]
		err := clipboard.WriteAll(sitePass)
		check(err)
		fmt.Println("The password has been copied to the clipboard")
	} else {
		fmt.Printf("Password for %s:", siteName)
		sitePass = string(gopass.GetPasswd())
	}
	decrypted[siteName] = sitePass
	encrypted := encryptStorage(auth, decrypted)
	writeFile(cfg.storageFile, encrypted)
}
Exemplo n.º 24
0
func main() {
	if len(os.Args) != 2 {
		fmt.Fprintf(os.Stderr, "Usage: %s <site_address>\n", os.Args[0])
		os.Exit(1)
	}
	passwd := ""
	for passwd == "" {
		if passwd, err := gopass.GetPass(os.Args[1] + " password: "******"" {
				clipboard.WriteAll(generate(passwd, os.Args[1]))
				break
			}
		} else {
			panic(err)
		}
	}
}
Exemplo n.º 25
0
Arquivo: copy.go Projeto: tobischo/kp2
func copyCmd(cmd *cobra.Command, args []string) error {
	selectors := strings.Split(strings.Join(args, " "), "/")

	entry, err := readEntry(selectors, &db.Content.Root.Groups[0])
	if err != nil {
		return err
	}

	if err := clipboard.WriteAll(entry.GetPassword()); err != nil {
		return err
	}

	markAsAccessed(entry)

	fmt.Printf("UserName: %s\n", entry.GetContent("UserName"))

	return nil
}
Exemplo n.º 26
0
func main() {
	text, err := clipboard.ReadAll()
	if err != nil {
		fmt.Fprintln(os.Stderr, err)
		os.Exit(1)
	}

	re := regexp.MustCompile(`\r?\n`)
	line := re.ReplaceAllString(text, "")

	if err := clipboard.WriteAll(line); err != nil {
		fmt.Fprintln(os.Stderr, err)
		os.Exit(1)
	}

	fmt.Print(line)
	os.Exit(0)
}
Exemplo n.º 27
0
func KeyFuncWordRubout(this *Buffer) Result {
	org_cursor := this.Cursor
	for this.Cursor > 0 && unicode.IsSpace(this.Buffer[this.Cursor-1]) {
		this.Cursor--
	}
	i := this.CurrentWordTop()
	var killbuf bytes.Buffer
	for j := i; j < org_cursor; j++ {
		killbuf.WriteRune(this.Buffer[j])
	}
	clipboard.WriteAll(killbuf.String())
	keta := this.Delete(i, org_cursor-i)
	if i >= this.ViewStart {
		Backspace(keta)
	} else {
		Backspace(this.GetWidthBetween(this.ViewStart, org_cursor))
	}
	this.Cursor = i
	this.Repaint(i, keta)
	return CONTINUE
}
Exemplo n.º 28
0
Arquivo: utils.go Projeto: github/hub
func printBrowseOrCopy(args *Args, msg string, openBrowser bool, performCopy bool) {
	if performCopy {
		if err := clipboard.WriteAll(msg); err != nil {
			ui.Errorf("Error copying %s to clipboard:\n%s\n", msg, err.Error())
		}
	}

	if openBrowser {
		launcher, err := utils.BrowserLauncher()
		utils.Check(err)
		args.Replace(launcher[0], "", launcher[1:]...)
		args.AppendParams(msg)
	}

	if !openBrowser && !performCopy {
		args.AfterFn(func() error {
			ui.Println(msg)
			return nil
		})
	}
}
Exemplo n.º 29
0
func KeyFuncClearAfter(this *Buffer) Result {
	w := this.GetWidthBetween(this.ViewStart, this.Cursor)
	i := this.Cursor
	bs := 0

	var killbuf bytes.Buffer
	for j := this.Cursor; j < this.Length; j++ {
		killbuf.WriteRune(this.Buffer[j])
	}
	clipboard.WriteAll(killbuf.String())

	for i < this.Length && w < this.ViewWidth {
		w1 := GetCharWidth(this.Buffer[i])
		PutRunes(' ', w1)
		i++
		w += w1
		bs += w1
	}
	Backspace(bs)
	this.Length = this.Cursor
	return CONTINUE
}
Exemplo n.º 30
0
func read(name string) error {
	p, ok := logins[name]

	if !ok {
		return fmt.Errorf("no such key")
	}
	key = pbkdf2.Key(key, p.Salt, 4096, 32, sha1.New)
	session, err := aes.NewCipher(key)
	if err != nil {
		return err
	}
	pass_ciphered := p.Pass
	iv := pass_ciphered[:aes.BlockSize]
	pass_ciphered = pass_ciphered[aes.BlockSize:]

	pass_plain := make([]byte, len(pass_ciphered))
	mode := cipher.NewCBCDecrypter(session, iv)
	mode.CryptBlocks(pass_plain, pass_ciphered)

	clipboard.WriteAll(string(pass_plain))
	return nil
}