20 Oct 2022
sort
是 Go
裏面數一數二常用的package,下面介紹三種函式。
Ints
最基本的整數由小到大排序。
package main
import (
"fmt"
"sort"
)
func main() {
s := []int{5, 2, 6, 3, 1, 4} // unsorted
sort.Ints(s)
fmt.Println(s)
// [1 2 3 4 5 6]
}
Strings
最基本的字串由小到大排序。
package main
import (
"fmt"
"sort"
)
func main() {
s := []string{"Go", "Bravo", "Gopher", "Alpha", "Grin", "Delta"}
sort.Strings(s)
fmt.Println(s)
// [Alpha Bravo Delta Go Gopher Grin]
}
Slice
依照給訂的規則來排序,並不保證 stable ,如果想要確保 stable ,可以用另一個函式叫做 SliceStable
import (
"fmt"
"sort"
)
func main() {
people := []struct {
Name string
Age int
}{
{"Gopher", 7},
{"Alice", 55},
{"Vera", 24},
{"Bob", 75},
}
sort.Slice(people, func(i, j int) bool { return people[i].Name < people[j].Name })
fmt.Println("By name:", people)
// By name: [{Alice 55} {Bob 75} {Gopher 7} {Vera 24}]
sort.Slice(people, func(i, j int) bool { return people[i].Age < people[j].Age })
fmt.Println("By age:", people)
// By age: [{Gopher 7} {Vera 24} {Alice 55} {Bob 75}]
}
18 Oct 2022
An integer can be converted to string by Itoa
function which is in strconv
library.
Example :
import (
"fmt"
"reflect"
"strconv"
)
func main() {
nums1 := 10
fmt.Println(nums1, reflect.TypeOf(nums1))
str := strconv.Itoa(nums1)
fmt.Println(str, reflect.TypeOf(str))
}
06 Oct 2022
I encounter below error when run command anchor build
.
error[E0635]: unknown feature `proc_macro_span_shrink`
Solution is downgrading proc-macro2 to 1.0.43 :
cargo update -p proc-macro2 --precise 1.0.43
Reference
29 Sep 2022
PicoGym Exclusive / Forensics
Description
I thought that my password was super-secret, but it turns out that passwords passed over the AIR can be CRACKED, especially if I used the same wireless network password as one in the rockyou.txt credential dump.
Use this ‘pcap file’ and the rockyou wordlist. The flag should be entered in the picoCTF{XXXXXX} format.
Prereguisite
Aircrack-Ng, which is a network software suite consisting of a detector, packet sniffer, WEP and WPA/WPA2-PSK cracker and analysis tool for 802.11 wireless LANs.
Writeup
- Download the pcap file and rockyou wordlist.
- Crack
aircrack-ng -w rockyou.txt wpa-ing_out.pcap
28 Sep 2022
PicoCTF 2019 / Forensics
Description
We found this packet capture and key. Recover the flag.
Prereguisite
ssldump, which is an SSL/TLS network protocol analyzer.
Writeup
- Download packet capture and key.
ssldump -r capture.pcap -k picopico.key -d > output
vim output
- Search our flag.