Project

General

Profile

RE: Problem with ParAd0x's Blowfish » fish_10.ini

Per Amundsen, 02/05/2016 09:53 AM

 
1
;**************
2
;* FiSH 10 mIRC Script - Hugely based on FiSH v1.30 *
3
;* Heavily modified for use in AdiIRC *
4
;**************
5
; "FiSH 10" by the way means "FiSH 2" in binary, and the year is 2010, therefore "FiSH 10".
6

    
7
on *:START: {
8
  ; ********** you can change the blow.ini path here if you like: **********
9
  ; for example to use %appdata%\mIRC:
10
  ; set %blow_ini $shortfn($mircdir $+ blow.ini)  
11
  set %blow_ini $shortfn($nofile($mircexe) $+ blow.ini)
12

    
13
  ; Path to the fish_10.dll
14
  set %FiSH_dll $qt($shortfn($nofile($scriptdir) $+ fish_10.dll)))
15

    
16
  ; this one is just for info:
17
  .dll %FiSH_dll _callMe
18

    
19
  ; and this one is important again:
20
  .dll %FiSH_dll FiSH_SetIniPath %blow_ini
21
}
22

    
23
; *** auto-keyXchange ***
24
on *:OPEN:?:{
25
  if (%autokeyx == [On]) {
26
    var %tmp1 = $dll(%FiSH_dll,FiSH_GetKey10, $network $nick)
27
    if ($len(%tmp1) > 0) {
28
      FiSH.DH1080_INIT $nick
29
    }
30
    unset %tmp1
31
  }
32
}
33

    
34
; Decrypt and echo a encrypted incoming action, halt the default output (mcps)
35
on ^*:ACTION:mcps *:*:{
36
  if ($dll(%FiSH_dll,INI_GetBool,process_incoming 1) == 0) return
37
  var %key = $dll(%FiSH_dll,FiSH_GetKey10, $network $target)
38

    
39
  ; hack, if key is empty, reset the ini path
40
  if ($len(%key) == 0) {
41
    .dll %FiSH_dll FiSH_SetIniPath %blow_ini
42
    %key = $dll(%FiSH_dll,FiSH_GetKey10, $network $target)
43
  }
44

    
45
  if ($len(%key) > 1) {
46
    var %msg = $iif($left($2, 1) == *, $right($2-, $calc($len($2-) - 1)), $2-)
47
    echo $color(action) -trlmbf $iif($chan, $chan, $nick) * $iif($nick($chan, $nick).pnick,  $+ $nick($chan, $nick).color $+ $v1 $+ , $nick) $dll(%FiSH_dll, FiSH_decrypt_msg, %key %msg)
48
    halt
49
  }
50
}
51

    
52
; Decrypt and echo a encrypted incoming action, halt the default output
53
on ^*:ACTION:+OK *:*:{
54
  if ($dll(%FiSH_dll,INI_GetBool,process_incoming 1) == 0) return
55
  var %key = $dll(%FiSH_dll,FiSH_GetKey10, $network $target)
56

    
57
  ; hack, if key is empty, reset the ini path
58
  if ($len(%key) == 0) {
59
    .dll %FiSH_dll FiSH_SetIniPath %blow_ini
60
    %key = $dll(%FiSH_dll,FiSH_GetKey10, $network $target)
61
  }
62

    
63
  if ($len(%key) > 1) {
64
    var %msg = $iif($left($2, 1) == *, $right($2-, $calc($len($2-) - 1)), $2-)
65
    echo $color(action) -trlmbf $iif($chan, $chan, $nick) * $iif($nick($chan, $nick).pnick,  $+ $nick($chan, $nick).color $+ $v1 $+ , $nick) $dll(%FiSH_dll, FiSH_decrypt_msg, %key %msg)
66
    halt
67
  }
68
}
69

    
70
; Decrypt and echo a encrypted incoming message, halt the default output
71
on ^*:TEXT:+OK *:*:{
72
  if ($dll(%FiSH_dll,INI_GetBool,process_incoming 1) == 0) return
73
  var %key = $dll(%FiSH_dll,FiSH_GetKey10, $network $target)
74

    
75
  ; hack, if key is empty, reset the ini path
76
  if ($len(%key) == 0) {
77
    .dll %FiSH_dll FiSH_SetIniPath %blow_ini
78
    %key = $dll(%FiSH_dll,FiSH_GetKey10, $network $target)
79
  }
80

    
81
  if ($len(%key) > 1) {
82
    var %msg = $iif($left($2, 1) == *, $right($2-, $calc($len($2-) - 1)), $2-)
83
    echo -trlmbf $iif($chan, $chan, $nick) < $+ $iif($nick($chan, $nick).pnick,  $+ $nick($chan, $nick).color $+ $v1 $+ , $nick) $+ > $dll(%FiSH_dll, FiSH_decrypt_msg, %key %msg)
84
    halt
85
  }
86
}
87

    
88
; Decrypt and echo a encrypted incoming message, halt the default output (mcps)
89
on ^*:TEXT:mcps *:*:{
90
  if ($dll(%FiSH_dll,INI_GetBool,process_incoming 1) == 0) return
91
  var %key =  $dll(%FiSH_dll,FiSH_GetKey10, $network $target)
92

    
93
  ; hack, if key is empty, reset the ini path
94
  if ($len(%key) == 0) {
95
    .dll %FiSH_dll FiSH_SetIniPath %blow_ini
96
    %key =  $dll(%FiSH_dll,FiSH_GetKey10, $network $target)
97
  }
98

    
99
  if ($len(%key) > 1) {
100
    var %msg = $iif($left($2, 1) == *, $right($2-, $calc($len($2-) - 1)), $2-)
101
    echo -trlmbf $iif($chan, $chan, $nick) < $+ $iif($nick($chan, $nick).pnick,  $+ $nick($chan, $nick).color $+ $v1 $+ , $nick) $+ > $dll(%FiSH_dll, FiSH_decrypt_msg, %key %msg)
102
    halt
103
  }
104
}
105

    
106
; ######################################
107
; ### mark outgoing (own text) START ###
108
on *:INPUT:*:{
109
  if (($left($1,1) == / && !$ctrlenter) || (!$1)) return
110
  if ($dll(%FiSH_dll,INI_GetBool,process_outgoing 1) == 0) return
111
  var %key =  $dll(%FiSH_dll,FiSH_GetKey10,$network $target)
112
  if ($len(%key) > 1) {
113
    var %tmp1 = $readini(%blow_ini,FiSH,plain_prefix)
114
    if (%tmp1 == $null) { %tmp1 = +p }
115
    var %pfxlen = $len(%tmp1)
116
    if (%tmp1 != $left($1,%pfxlen)) {
117
      var %tmp1 = $readini(%blow_ini,FiSH,mark_encrypted)
118

    
119
      if (%mark_style == $null) { %mark_style = 2 }
120
      if (%tmp1 == $null) { %tmp1 = $chr(2) $+ $chr(3) $+ 12· $+ $chr(3) $+ $chr(2) }
121

    
122
      ;### <mynick> own encrypted text [default crypt mark] ###
123
      if (%mark_style == 1) {
124
        var %own_encrypted_text = < $+ $iif($nick($chan,$nick).pnick, $v1, $nick) $+ > $1- $+ $chr(32) $+ %tmp1
125
      }
126

    
127
      ;### <mynick> [default crypt mark] own encrypted text ###
128
      if (%mark_style == 2) {
129
        var %own_encrypted_text = < $+ $iif($nick($chan,$nick).pnick, $v1, $nick) $+ > $+ %tmp1 $1-
130
      }
131

    
132
      ;### <mynick> own encrypted text (the nick brackets are bold+blue) ###
133
      if (%mark_style == 3) {
134
        var %own_encrypted_text = $+($chr(2), $chr(3), 12<, $chr(3), $chr(2)) $+ $iif(($gettok($readini(mirc.ini, options, n2), 30, 44)) && (($me isvoice $chan) || ($me isop $chan)), $left($nick(#, $nick).pnick, 1)) $+ $iif($nick($chan,$nick).pnick, $v1, $nick) $+ $+($chr(2), $chr(3), 12>, $chr(3), $chr(2)) $1-
135
      }
136

    
137
      echo $color(Own text) -t %own_encrypted_text
138
    }
139
    else {
140
      echo $color(Own text) -t  < $+ $iif(($gettok($readini(mirc.ini, options, n2), 30, 44)) && (($me isvoice $chan) || ($me isop $chan)), $left($nick(#, $nick).pnick, 1)) $+ $nick $+ > $right($1-, $calc(0 - %pfxlen))
141
    }
142

    
143
    privmsg $target : $+ +OK $dll(%FiSH_dll, FiSH_encrypt_msg, %key $1-)
144
    halt
145
  }
146
  unset %tmp1
147
}
148
; ### mark outgoing (own text) END ###
149
; ####################################
150

    
151
on *:CONNECT:{
152
  if (%autoset_localip == [On]) {
153
    localinfo FiSH.OWNZ $dll(%FiSH_dll,FiSH_GetMyIP,NOT_USED)
154
  }
155
}
156

    
157
on *:NICK:{
158
  if (($nick == $me) || ($upper($newnick) == $upper($nick))) { return }
159
  if (($query($newnick) == $null) || (%NickTrack != [On])) { return }
160
  var %ky_tmp = $dll(%FiSH_dll,FiSH_GetKey10,$network $nick)
161
  if ($len(%ky_tmp) > 4) {
162
    writeini -n %blow_ini $newnick key %ky_tmp
163
    writeini -n %blow_ini $newnick dh1080_cbc $readini(%blow_ini,$nick,dh1080_cbc)
164
  }
165
  unset %ky_tmp
166
}
167

    
168
on ^*:NOTICE:DH1080_INIT*:?:{
169
  if ($len($2) > 178 && $len($2) < 182) {
170
    query $nick
171
    echo $color(Mode text) -tm $nick *** FiSH: Received DH1080 public key from $nick $+ , sending mine...
172
    var %tempkey $dll(%FiSH_dll,DH1080_gen,NOT_USED)
173
    %FiSH.prv_key = $gettok(%tempkey, 1, 32)
174
    %FiSH.pub_key = $gettok(%tempkey, 2, 32)
175
    unset %tempkey
176
    var %secret = $dll(%FiSH_dll,DH1080_comp, %FiSH.prv_key $2)
177
    if ($3 == CBC) {
178
      .notice $nick DH1080_FINISH %FiSH.pub_key CBC
179
      FiSH.setkey $nick cbc: $+ %secret
180
    }
181
    else {
182
      .notice $nick DH1080_FINISH %FiSH.pub_key
183
      FiSH.setkey $nick %secret
184
    }
185
    unset %FiSH.prv_key
186
    unset %FiSH.pub_key
187
    unset %secret
188
  }
189
  halt
190
}
191

    
192
on ^*:NOTICE:DH1080_FINISH*:?:{
193
  if ( %FiSH.dh [ $+ [ $nick ] ] != 1 ) {
194
    echo "No keyXchange in progress!"
195
    halt
196
  }
197
  if ($len($2) > 178 && $len($2) < 182) {
198
    if ($len(%FiSH.prv_key) == 180 || $len(%FiSH.prv_key) == 181) {
199
      var %secret = $dll(%FiSH_dll,DH1080_comp, %FiSH.prv_key $2)
200
      if ($3 == CBC) FiSH.setkey $nick cbc: $+ %secret
201
      else FiSH.setkey $nick %secret
202
      unset %FiSH.dh $+ [ $nick ]
203
      unset %FiSH.prv_key
204
      unset %FiSH.pub_key
205
      unset %secret
206
    }
207
  }
208
  halt
209
}
210

    
211
alias -l FiSH.WriteKey {
212
  if ($2 == /query) var %cur_contact = $active
213
  else var %cur_contact = $2
214
  if ($3- == $null) return
215

    
216
  $dll(%FiSH_dll,FiSH_WriteKey10,$1 $network %cur_contact $3-)
217

    
218
  var %info = *** FiSH: Key for %cur_contact set to *censored* $iif($gettok($3-,1,58) == cbc, (CBC Mode), )
219

    
220
  if ($window(%cur_contact) == $null) echo $color(Mode text) -at %info
221
  else echo $color(Mode text) -tm %cur_contact %info
222
}
223

    
224
alias FiSH.setkey { FiSH.WriteKey decode_utf8 $1 $2- }
225
alias FiSH.setkey_utf8 { FiSH.WriteKey raw_bytes $1 $2- }
226

    
227
alias FiSH.usechankey {
228
  var %theKey = $readini(%blow_ini,$2,key)
229
  if (%theKey == $null) {
230
    echo $color(Mode text) -at *** FiSH: No valid key for $2 found
231
  }
232
  else {
233
    writeini -n %blow_ini $1 key %theKey
234
    writeini -n %blow_ini $1 date $date
235
    unset %theKey
236
    echo $color(Mode text) -at *** FiSH: Using same key as $2 for $1
237
  }
238
}
239

    
240
alias FiSH.showkey {
241
  if ($1 == /query) var %cur_contact = $active
242
  else var %cur_contact = $1
243

    
244
  %theKey = $dll(%FiSH_dll,FiSH_GetKey10, $network %cur_contact)
245
  if (%theKey != $null) {
246
    window -dCo +l @Blowcrypt-Key -1 -1 500 80
247
    aline @Blowcrypt-Key Key for %cur_contact :
248
    aline -p @Blowcrypt-Key %theKey
249
    unset %theKey
250
  }
251
  else {
252
    echo $color(Mode text) -at *** FiSH: No valid key for %cur_contact found
253
  }
254
}
255

    
256
alias FiSH.removekey {
257
  if ($1 == /query) var %cur_contact = $active
258
  else var %cur_contact = $1
259
  $dll(%FiSH_dll,FiSH_DelKey10,$network %cur_contact)
260
  echo $color(Mode text) -at *** FiSH: Key for %cur_contact has been removed
261
}
262

    
263
alias keyx { FiSH.DH1080_INIT $1 }
264

    
265
alias FiSH.DH1080_INIT {
266
  if ( ($1 == /query) || ($1 == $null) ) var %cur_contact = $active
267
  else var %cur_contact = $1
268
  set %FiSH.dh $+ [ %cur_contact ] 1
269
  var %tempkey $dll(%FiSH_dll,DH1080_gen,NOT_USED)
270
  %FiSH.prv_key = $gettok(%tempkey, 1, 32)
271
  %FiSH.pub_key = $gettok(%tempkey, 2, 32)
272
  unset %tempkey
273
  .NOTICE %cur_contact DH1080_INIT %FiSH.pub_key $iif($dll(%FiSH_dll,INI_GetSectionBool,$network %cur_contact dh1080_cbc 1) == 0,, CBC)
274
  echo $color(Mode text) -tm $nick *** FiSH: Sent my DH1080 public key to %cur_contact $+ , waiting for reply ...
275
}
276

    
277
; Decrypt topic changes if enabled
278
on ^*:TOPIC:#:{
279
  if ($dll(%FiSH_dll,INI_GetSectionBool,$network $chan encrypt_topic 0) != 1) {
280
    return
281
  }
282

    
283
  if ($left($1,3) != +OK && $left($1,4) != mcps) {
284
    return
285
  }
286
  
287
  if ($left($1,3) == +OK) {
288
    var %msg = $right($1-,$calc($len($1-) - 4))
289
  }
290

    
291
  if ($left($1,4) == mcps) {
292
    var %msg = $right($1-,$calc($len($1-) - 5))
293
  }
294

    
295
  var %key = $dll(%FiSH_dll,FiSH_GetKey10,$network $target)
296
  if ($len(%key) > 1) {
297
    var %msg = $iif($left($1,1) == *,$right($1-, $calc($len($1-) - 1)), $1-)
298
    echo $color(topic) -t # * $nick changes topic to: $dll(%FiSH_dll, FiSH_decrypt_msg,%key %msg)
299
    halt
300
  }
301
}
302

    
303
; Decrypt initial topic if enabled
304
raw 332:*:{
305
  if ($dll(%FiSH_dll,INI_GetSectionBool,$network $2 encrypt_topic 0) != 1) {
306
    return
307
  }
308

    
309
  if ($left($3,3) != +OK) {
310
    return
311
  }
312

    
313
  var %key = $dll(%FiSH_dll,FiSH_GetKey10,$network $2)
314
  if ($len(%key) > 1) {
315
    var %msg = $iif($left($3,1) == *,$right($3-, $calc($len($3-) - 1)), $3-)
316
    echo $color(topic) -t $2 * Topic is: $dll(%FiSH_dll, FiSH_decrypt_msg,%key %msg)
317
    halt
318
  }
319
}
320

    
321
alias FiSH.prefix {
322
  if ($1 != $null) {
323
    writeini -n %blow_ini FiSH plain_prefix $1-
324
    flushini mirc.ini
325
    echo $color(Mode text) -at *** FiSH: Plain-prefix set to $1-
326
  }
327
}
328

    
329
alias FiSH.showmyip {
330
  window -dCo +l @Local-IP -1 -1 500 80
331
  aline @Local-IP Your external IP address :
332
  aline -p @Local-IP $dll(%FiSH_dll,FiSH_GetMyIP,FiSH)
333
}
334

    
335
menu channel {
336
  -
337
  FiSH
338
  .Show key :FiSH.showkey $chan
339
  .Set new key :FiSH.setkey $chan $?
340
  .Set new key (UTF-8) :FiSH.setkey_utf8 $chan $?
341
  .Remove key :FiSH.removekey $chan
342
}
343

    
344
menu query {
345
  -
346
  FiSH
347
  .DH1080 keyXchange: FiSH.DH1080_INIT $1
348
  .-
349
  .Show key :FiSH.showkey $1
350
  .Set new key :FiSH.setkey $1 $?
351
  .Set new key (UTF-8) :FiSH.setkey_utf8 $1 $?
352
  .Remove key :FiSH.removekey $1
353
}
354

    
355
menu nicklist {
356
  -
357
  FiSH
358
  .DH1080 keyXchange: FiSH.DH1080_INIT $1
359
  .-
360
  .Show key :FiSH.showkey $1
361
  .Set new key :FiSH.setkey $1 $?
362
  .Set new key (UTF-8) :FiSH.setkey_utf8 $1 $?
363
  .Remove key :FiSH.removekey $1
364
  .Use same key as $chan :FiSH.usechankey $1 $chan
365
}
366

    
367
menu status,channel,nicklist,query {
368
  FiSH
369
  .-
370
  .Set plain-prefix $chr(91) $readini(%blow_ini,FiSH,plain_prefix) $chr(93) :FiSH.prefix $?="Enter new plain-prefix:"
371
  .Auto-KeyXchange $+ $chr(32) $+ %autokeyx
372
  ..Enable :set %autokeyx [On]
373
  ..Disable :set %autokeyx [Off]
374
  .Local IP
375
  ..Set local IP now: localinfo FiSH.OWNZ $dll(%FiSH_dll,FiSH_GetMyIP,FiSH)
376
  ..Set after connecting $+ $chr(32) $+ %autoset_localip
377
  ...Enable :set %autoset_localip [On]
378
  ...Disable :set %autoset_localip [Off]
379
  ..Copy local IP to clipboard: clipboard $dll(%FiSH_dll,FiSH_GetMyIP,FiSH)
380
  ..Show local IP :FiSH.showmyip
381
  .Misc config
382
  ..Encrypt outgoing $iif($dll(%FiSH_dll,INI_GetBool,process_outgoing 1) == 0, [Off], [On])
383
  ...Enable :writeini -n %blow_ini FiSH process_outgoing 1
384
  ...Disable :writeini -n %blow_ini FiSH process_outgoing 0
385
  ..Decrypt incoming $iif($dll(%FiSH_dll,INI_GetBool,process_incoming 1) == 0, [Off], [On])
386
  ...Enable :writeini -n %blow_ini FiSH process_incoming 1
387
  ...Disable :writeini -n %blow_ini FiSH process_incoming 0
388
  ..-
389
  ..Crypt-Mark (Incoming)
390
  ...Prefix :writeini -n %blow_ini FiSH mark_position 2
391
  ...Suffix :writeini -n %blow_ini FiSH mark_position 1
392
  ...Disable :writeini -n %blow_ini FiSH mark_position 0
393
  ..Crypt-Mark (Outgoing) $+ $chr(32) $+ %mark_outgoing
394
  ...Enable :set %mark_outgoing [On]
395
  ...Disable :set %mark_outgoing [Off]
396
  ...-
397
  ...Style 1 :{
398
    set %mark_style 1
399
    set %mark_outgoing [On]
400
  }
401
  ...Style 2 :{
402
    set %mark_style 2
403
    set %mark_outgoing [On]
404
  }
405
  ...Style 3 :{
406
    set %mark_style 3
407
    set %mark_outgoing [On]
408
  }
409
  ..NickTracker $+ $chr(32) $+ %NickTrack
410
  ...Enable :set %NickTrack [On]
411
  ...Disable :set %NickTrack [Off]
412
  ..Encrypt NOTICE $iif($dll(%FiSH_dll,INI_GetBool,encrypt_notice) == 1, [On], [Off])
413
  ...Enable :writeini -n %blow_ini FiSH encrypt_notice 1
414
  ...Disable :writeini -n %blow_ini FiSH encrypt_notice 0
415
  ..Encrypt ACTION $iif($dll(%FiSH_dll,INI_GetBool,encrypt_action) == 1, [On], [Off])
416
  ...Enable :writeini -n %blow_ini FiSH encrypt_action 1
417
  ...Disable :writeini -n %blow_ini FiSH encrypt_action 0
418
  ..-
419
  ..Open blow.ini :run %blow_ini
420
  ..-
421
  ..FiSH 10 - based on FiSH 1.30 by RXD :run http://github.com/flakes/mirc_fish_10
422
}
423

    
424
menu channel {
425
  FiSH
426
  .Misc config
427
  ..Crypt-Mark (Incoming)
428
  ...-
429
  ...Only for $chan $iif($dll(%FiSH_dll, INI_GetSectionBool,$network $chan mark_encrypted $dll(%FiSH_dll, INI_GetBool,mark_encrypted)) == 0, [Off], [On])
430
  ....Enable :dll %FiSH_dll INI_SetSectionBool $network $chan mark_encrypted 1
431
  ....Disable :dll %FiSH_dll INI_SetSectionBool $network $chan mark_encrypted 0
432
  ..Encrypt TOPIC $iif($dll(%FiSH_dll, INI_GetSectionBool,$network $chan encrypt_topic 0) == 1, [On], [Off])
433
  ...Enable :dll %FiSH_dll INI_SetSectionBool $network $chan encrypt_topic 1
434
  ...Disable :dll %FiSH_dll INI_SetSectionBool $network $chan encrypt_topic 0
435
}
436

    
437
menu query {
438
  FiSH
439
  .Misc config
440
  ..Crypt-Mark (Incoming)
441
  ...-
442
  ...Only for $1 $iif($dll(%FiSH_dll, INI_GetSectionBool,$network $1 mark_encrypted $dll(%FiSH_dll,INI_GetBool, mark_encrypted)) == 0, [Off], [On])
443
  ....Enable :dll %FiSH_dll INI_SetSectionBool $network $1 mark_encrypted 1
444
  ....Disable :dll %FiSH_dll INI_SetSectionBool $network $1 mark_encrypted 1
445
  ..CBC key exchange $iif($dll(%FiSH_dll, INI_GetSectionBool,$network $1 dh1080_cbc 1) == 1, [On], [Off])
446
  ...Enable :dll %FiSH_dll INI_SetSectionBool $network $1 dh1080_cbc 1
447
  ...Disable :dll %FiSH_dll INI_SetSectionBool $network $1 dh1080_cbc 0
448
}
    (1-1/1)