This file is indexed.

/usr/share/amsn/amsn-remote is in amsn 0.98.9-1ubuntu3.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
#!/usr/bin/wish8.5
###
### Remote controller program
###

source /usr/share/amsn/amsncore.tcl

set initialize_amsn 1

proc readsocket { } {
	global sock

	set complete 0
	set response ""


	while { [info exists sock] && $complete == 0 } {
		if { [gets $sock tmp] == -1 } {
			.controler.res.txt insert end "Amsn server closed\n" error
			.controler.res.txt yview moveto 1.0
			fileevent $sock readable ""
			destroy .controler
			connect "Amsn server closed"
		} elseif {$tmp != "" } {
			append response $tmp
			append response "\n"
			set complete [info complete $response]
			
			if { $complete } {
				set data [lindex $response 0]
				set colour [lindex $response 1]
				
				.controler.res.txt insert end $data $colour
				.controler.res.txt insert end "\n" $colour				
				.controler.res.txt yview moveto 1.0
			} 
		}
	}

    
}

proc writesocket { } {
    global sock

    set command [.controler.entry get]
    .controler.entry delete 0 end
    .controler.res.txt insert end "\n$command\n" command
    .controler.res.txt yview moveto 1.0

    set command [string map { \; \\\; \" \\\" \[ \\\[ \] \\\] \: \\\: \\ \\\\ \* \\\* \? \\\?} $command]
 #   set command [join $command]


    if { "$command" != "quit" } {
	puts ${sock} $command
	flush $sock
    } else {
	destroy .controler
    }

}

proc authenticate { password } {
    global sock

    puts ${sock} "auth"
    flush $sock
    gets $sock response
    set response [lindex $response 0]

   if { [lindex $response 0] != "auth" } {
	    if { [lindex $response 0] == "wait" } {
		    return "wait"
	    } else {
		    return "fail"
	    }
    } else {
	set hash [::md5::hmac "[lindex $response 1]" "$password"]
	puts $sock "auth2 $hash"
	flush $sock
	gets $sock response
	set response [lindex $response 0]

	if { "$response" ==  "Authentication successfull" } {
	    return "OK"
	} elseif { "$response" == "Authentication failed" } {
	    return "fail"
	} else {
	    return "disabled"
	}
       
    }

}

proc connect { status } {
    global sockDS stat

    set ip [.ip get]

    if { [catch {toplevel .connect}] } {
	destroy .connect
	toplevel .connect
    }
	 
    wm group .connect .


    if { $sockDS == 0 } {
	set stat [catch {socket $ip 63251} sockDS]
	set status "Connected to the server"
    }

    if { $stat != 0 } {

	label .connect.status -text "Error connecting to server\n$sockDS"
	button .connect.ok -text "OK" -command "destroy .connect"

	set sockDS 0

	grid .connect.status -row 0 -column 0
	grid .connect.ok -row 2 -column 1

	bind .connect <Destroy> "grab release .connect"
	grab set .connect
    }  else {
	label .connect.status -text "$status"
	button .connect.ok -text "Connect to account" -command "retreive_port $ip"

	label .connect.acc_l -text "Account :" 
	entry .connect.acc
	label .connect.pass_l -text "Password for remote access :"
	entry .connect.pass -show "*"
	button .connect.cancel -text "Cancel" -command "close $sockDS;set sockDS 0; destroy .connect"

	grid .connect.status -row 0 -column 2
	grid .connect.ok -row 2 -column 3
	grid .connect.cancel -row 3 -column 3
	grid .connect.acc_l -row 2 -column 0
	grid .connect.acc -row 2 -column 2
	grid .connect.pass_l -row 3 -column 0
	grid .connect.pass -row 3 -column 2
	bind .connect <Destroy> {
	    if {"%W" == ".connect"} {   
		grab release .connect
	    }
	}
	bind .connect.acc <Return> "retreive_port $ip"
	bind .connect.pass <Return> "retreive_port $ip"
	grab set .connect
	focus -force .connect.acc
    }

}

proc retreive_port { ip } {
    global sockDS sock
    set account [.connect.acc get]
    set password [.connect.pass get]
    

    puts $sockDS "$account"

    if { [catch { flush $sockDS}] } {
	set sockDS 0
	connect "Disconnected from the DS server"
	return 0
    }

    set port [gets $sockDS]

    if { "$port" == "invalid" } {
	connect "This Amsn Account is invalid"
	return 0
    }
    if { "$port" == "noexist" } {
	connect "The Amsn profile file doesn't exist or you don't have permissions to read from it"
	return 0
    }
    if { "$port" == "versionerror" } {
	connect "The Amsn profile file has an invalid version" 
	return 0
    }

    if { [catch {socket $ip $port} sock] != 0 } {
	connect "This Amsn Account isn't connected"
	return 0
    } else {
	fconfigure $sock -buffering line 
	if { [set auth_response [authenticate "$password"]] == "fail" } {
	    connect "Password incorrect or not set"
	    return 0
	} elseif { $auth_response == "disabled" } {
	    connect "This account doesn't have remote controlling enabled"
	    return 0
	} elseif { $auth_response == "wait" } {
	    connect "Please wait 3 seconds before retrying."
	    return 0
	} else {
	    
	    fileevent $sock readable "readsocket"
	    connect "Connected to Account on port : $port"
	    after 500  control
	    return 1
	}	
    }
}


proc control { } {
    global sock

    toplevel .controler
    wm group .controler .
    wm title .controler "Remote Controler Shell"

   frame .controler.res  -class Degt
    text   .controler.res.txt -height 40 -width 120  \
	-wrap none -background white -foreground black \
	-yscrollcommand ".controler.res.sy set" \
	-xscrollcommand ".controler.res.sx set"
   scrollbar .controler.res.sy -command ".controler.res.txt yview"
   scrollbar .controler.res.sx -orient horizontal -command ".controler.res.txt xview"

   .controler.res.txt tag configure error -foreground red -background white
   .controler.res.txt tag configure command -foreground gray88 -background white
   .controler.res.txt tag configure normal -foreground black -background white
   .controler.res.txt tag configure msgsent -foreground brown -background white
   .controler.res.txt tag configure msgrcv -foreground blue -background white
   .controler.res.txt tag configure event -foreground green -background white


    pack .controler.res.sy -side right -fill y
    pack .controler.res.sx -side bottom -fill x
    pack .controler.res.txt -anchor nw -expand true -fill both

    entry .controler.entry  -width 50
    button .controler.close -text "Close" -command "destroy .controler"
 
    pack .controler.res -expand true -fill both 
    pack .controler.entry -fill x
    pack .controler.res .controler.entry -side top

    bind .controler.entry <Return> "writesocket"

    grab set .controler

    bind .controler <Destroy> {
	if { "%W" == ".controler" } {
	    close $::sock
	    unset ::sock
	    grab release .controler
	}
    }
    focus -force .controler.entry

}

proc main { } {
    global sockDS

   wm group . .
   wm geometry .

   wm title . "Amsn Remote Controller"

   button .con -text "Connect" -command "connect \"Connected to the server\""
   label .lab -text "Enter the IP address of the host : "
   entry .ip

   grid .lab -row 0 -column 0
   grid .ip -row 0 -column 2
   grid .con -row 0 -column 10 -sticky w

   bind .ip <Return> "connect \"Connected to the server\""
    focus -force .ip
}


############################################################
### Look if we are launched from a link
### and set the correct working directory
############################################################

#Fixed by Tomasz Nguyen
set program_dir [file dirname [info script]]
set program [file tail [info script]]


while {[catch {file readlink [file join $program_dir $program]} program]== 0} {
        if {[file pathtype $program] == "absolute"} {
                set program_dir [file dirname $program]
        } else {
                set program_dir [file join $program_dir [file dirname $program]]
        }

        set program [file tail $program]
}

set starting_dir [pwd]
cd $program_dir
set program_dir [pwd]
unset program
#unset program_dir

source [file join $program_dir migmd5.tcl]

set sockDS 0

main