mirror of
https://gogs.blitter.com/RLabs/xs
synced 2024-08-14 10:26:42 +00:00
roulette chaff mode functional.
TODO: corpus mode from a file rather than builtin data
This commit is contained in:
parent
adbc3e690a
commit
3d327b6b7c
1 changed files with 16 additions and 12 deletions
28
xsnet/net.go
28
xsnet/net.go
|
|
@ -69,6 +69,9 @@ type (
|
|||
msecsMin uint //msecs min interval
|
||||
msecsMax uint //msecs max interval
|
||||
szMax uint // max size in bytes
|
||||
|
||||
fromIdx uint // used for corpus-style fill context across
|
||||
fillIdx uint // ..chaff yield calls
|
||||
}
|
||||
|
||||
// Conn is a connection wrapping net.Conn with KEX & session state
|
||||
|
|
@ -1563,6 +1566,8 @@ func (hc *Conn) SetupChaff(mode ChaffMode, msecsMin uint, msecsMax uint, szMax u
|
|||
hc.chaff.mode = mode
|
||||
case ChaffConfigCorpusA:
|
||||
hc.chaff.mode = mode
|
||||
hc.chaff.fillIdx = 0
|
||||
hc.chaff.fromIdx = 0
|
||||
case ChaffConfigRoulette:
|
||||
hc.chaff.mode = mode
|
||||
default:
|
||||
|
|
@ -1579,17 +1584,15 @@ func randBytes(sz uint) (r []byte) {
|
|||
return r
|
||||
}
|
||||
|
||||
func fillBufferWithText(fillerMat string, sz uint) (r []byte) {
|
||||
func fillBufferWithText(fillerMat string, sz uint, fromIdx *uint, fillIdx *uint) (r []byte) {
|
||||
r = make([]byte, sz)
|
||||
fromIdx := 0
|
||||
fillIdx := uint(0)
|
||||
for fillIdx < sz {
|
||||
if fromIdx == len(fillerMat) {
|
||||
fromIdx = /* 0 */ rand.Intn(len(fillerMat))
|
||||
for *fillIdx < sz {
|
||||
if *fromIdx == uint(len(fillerMat)) {
|
||||
*fromIdx = /* 0 */ uint(rand.Intn(len(fillerMat)))
|
||||
}
|
||||
r[fillIdx] = fillerMat[fromIdx]
|
||||
fillIdx++
|
||||
fromIdx++
|
||||
r[*fillIdx] = fillerMat[*fromIdx]
|
||||
*fillIdx++
|
||||
*fromIdx++
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
|
@ -1598,7 +1601,7 @@ func ChaffStrategy(mode ChaffMode) (s ChaffMode) {
|
|||
if mode == ChaffConfigRoulette {
|
||||
s = ChaffMode(int(rand.Intn(ChaffConfigRoulette)))
|
||||
}
|
||||
fmt.Printf("strategy:%v\n", s)
|
||||
//fmt.Printf("strategy:%v\n", s)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -1616,8 +1619,9 @@ func (hc *Conn) chaffHelper() {
|
|||
|
||||
switch strat {
|
||||
case ChaffConfigCorpusA:
|
||||
bufTmp = fillBufferWithText(corpusTextA, hc.chaff.szMax)
|
||||
bufTmp = fillBufferWithText(corpusTextA, hc.chaff.szMax, &hc.chaff.fromIdx, &hc.chaff.fillIdx)
|
||||
case ChaffConfigRand:
|
||||
fallthrough
|
||||
default:
|
||||
bufTmp = randBytes(hc.chaff.szMax)
|
||||
}
|
||||
|
|
@ -1652,6 +1656,6 @@ attempting to decode a live or recorded xs session you should note that this cha
|
|||
text will probably give you no end of difficulties, and that is by design. Have you
|
||||
considered your life path? Snooping on other individuals, either domestic or foreign,
|
||||
is an ethically questionable career and you may be doing more harm than good to democracy,
|
||||
international relations, and general welfare of humanity. Consider buying a nice quiet
|
||||
international relations, and the general welfare of humanity. Consider buying a nice quiet
|
||||
cabin somewhere by a lake, growing food and spending time with those you love.`
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue