This file is indexed.

/usr/bin/btmaketorrentgui is in bittornado-gui 0.3.18-10.2.

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
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
#! /usr/bin/python

# Written by Bram Cohen
# modified for multitracker by John Hoffman
# see LICENSE.txt for license information

from BitTornado import PSYCO
if PSYCO.psyco:
    try:
        import psyco
        assert psyco.__version__ >= 0x010100f0
        psyco.full()
    except:
        pass

from sys import argv, version

from BitTornado.BT1.makemetafile import make_meta_file, completedir
from threading import Event, Thread
from BitTornado.bencode import bdecode
import sys
from os import getcwd
from os.path import join, isdir
try:
    import wx
except:
    print 'wxPython is either not installed or has not been installed properly.'
    sys.exit(1)

try:
    True
except:
    True = 1
    False = 0

wxEVT_INVOKE = wx.NewEventType()

def EVT_INVOKE(win, func):
    win.Connect(-1, -1, wxEVT_INVOKE, func)

class InvokeEvent(wx.PyEvent):
    def __init__(self, func, args, kwargs):
        wx.PyEvent.__init__(self)
        self.SetEventType(wxEVT_INVOKE)
        self.func = func
        self.args = args
        self.kwargs = kwargs

class DownloadInfo:
    def __init__(self):
        frame = wx.Frame(None, -1, 'BitTorrent Torrent File Maker', size = wx.Size(550, 410))
        self.frame = frame

        panel = wx.Panel(frame, -1)

        gridSizer = wx.FlexGridSizer(cols = 2, rows = 2, vgap = 0, hgap = 8)
        
        gridSizer.Add(wx.StaticText(panel, -1, 'make torrent of:'))

        b = wx.BoxSizer(wx.HORIZONTAL)
        self.dirCtl = wx.TextCtrl(panel, -1, '')
        b.Add(self.dirCtl, 1, wx.EXPAND)
        b.Add((10, 10), 0, wx.EXPAND)
        
        button = wx.Button(panel, -1, 'dir', size = (30,20))
        wx.EVT_BUTTON(frame, button.GetId(), self.selectdir)
        b.Add(button, 0)

        button2 = wx.Button(panel, -1, 'file', size = (30,20))
        wx.EVT_BUTTON(frame, button2.GetId(), self.selectfile)
        b.Add(button2, 0)

        gridSizer.Add(b, 0, wx.EXPAND)
        gridSizer.Add(wx.StaticText(panel, -1, ''))
        gridSizer.Add(wx.StaticText(panel, -1, ''))

        gridSizer.Add(wx.StaticText(panel, -1, 'announce url:'))
        self.annCtl = wx.TextCtrl(panel, -1, 'http://my.tracker:6969/announce')
        gridSizer.Add(self.annCtl, 0, wx.EXPAND)
        gridSizer.Add(wx.StaticText(panel, -1, ''))
        gridSizer.Add(wx.StaticText(panel, -1, ''))

        a = wx.FlexGridSizer(cols = 1)
        a.Add(wx.StaticText(panel, -1, 'announce list:'))
        a.Add(wx.StaticText(panel, -1, ''))
        abutton = wx.Button(panel, -1, 'copy\nannounces\nfrom\ntorrent', size = (50,70))
        wx.EVT_BUTTON(frame, abutton.GetId(), self.announcecopy)
        a.Add(abutton, 0, wx.EXPAND)
        gridSizer.Add(a, 0, wx.EXPAND)
        
        self.annListCtl = wx.TextCtrl(panel, -1, '\n\n\n\n\n', wx.Point(-1,-1), (400,120),
                                            wx.TE_MULTILINE|wx.HSCROLL|wx.TE_DONTWRAP)
        gridSizer.Add(self.annListCtl, -1, wx.EXPAND)

        gridSizer.Add(wx.StaticText(panel, -1, ''))
        exptext = wx.StaticText(panel, -1,
                "a list of announces separated by commas " +
                "or whitespace and on several lines -\n" +
                "trackers on the same line will be tried randomly," +
                "and all the trackers on one line\n" +
                "will be tried before the trackers on the next line.")
        exptext.SetFont(wx.Font(6, wx.DEFAULT, wx.NORMAL, wx.NORMAL, False))
        gridSizer.Add(exptext)

        gridSizer.Add(wx.StaticText(panel, -1, ''))
        gridSizer.Add(wx.StaticText(panel, -1, ''))

        gridSizer.Add(wx.StaticText(panel, -1, 'piece size:'))
        self.piece_length = wx.Choice(panel, -1,
                 choices = ['automatic', '2MiB', '1MiB', '512KiB', '256KiB', '128KiB', '64KiB', '32KiB'])
        self.piece_length_list = [0,       21,     20,      19,       18,       17,      16,      15]
        self.piece_length.SetSelection(0)
        gridSizer.Add(self.piece_length)
        
        gridSizer.Add(wx.StaticText(panel, -1, ''))
        gridSizer.Add(wx.StaticText(panel, -1, ''))

        gridSizer.Add(wx.StaticText(panel, -1, 'comment:'))
        self.commentCtl = wx.TextCtrl(panel, -1, '')
        gridSizer.Add(self.commentCtl, 0, wx.EXPAND)

        gridSizer.AddGrowableCol(1)
 
        border = wx.BoxSizer(wx.VERTICAL)
        border.Add(gridSizer, 0, wx.EXPAND | wx.NORTH | wx.EAST | wx.WEST, 25)
        b2 = wx.Button(panel, -1, 'make')
        border.Add((10, 10), 1, wx.EXPAND)
        border.Add(b2, 0, wx.ALIGN_CENTER | wx.SOUTH, 20)
        wx.EVT_BUTTON(frame, b2.GetId(), self.complete)
        panel.SetSizer(border)
        panel.SetAutoLayout(True)

        panel.DragAcceptFiles(True)
        wx.EVT_DROP_FILES(panel, self.selectdrop)

    def selectdir(self, x):
        dl = wx.DirDialog(self.frame, style = wx.DD_DEFAULT_STYLE | wx.DD_NEW_DIR_BUTTON)
        if dl.ShowModal() == wx.ID_OK:
            self.dirCtl.SetValue(dl.GetPath())

    def selectfile(self, x):
        dl = wx.FileDialog (self.frame, 'Choose file or directory to use', style = wx.FD_OPEN)
        if dl.ShowModal() == wx.ID_OK:
            self.dirCtl.SetValue(dl.GetPath())

    def selectdrop(self, x):
        print x

        list = x.m_files
        self.dirCtl.SetValue(x[0])

    def announcecopy(self, x):
        dl = wx.FileDialog (self.frame, 'Choose .torrent file to use', '', '', '*.torrent', wx.FD_OPEN)
        if dl.ShowModal() == wx.ID_OK:
            try:
                h = open(dl.GetPath(), 'rb')
                metainfo = bdecode(h.read())
                h.close()
                self.annCtl.SetValue(metainfo['announce'])
                if metainfo.has_key('announce-list'):
                    list = []
                    for tier in metainfo['announce-list']:
                        for tracker in tier:
                            list += [tracker, ', ']
                        del list[-1]
                        list += ['\n']
                    liststring = ''
                    for i in list:
                        liststring += i
                    self.annListCtl.SetValue(liststring+'\n\n')
                else:
                    self.annListCtl.SetValue('')
            except:
                return

    def getannouncelist(self):
        list = []
        for t in self.annListCtl.GetValue().split('\n'):
            tier = []
            t = t.replace(',',' ')
            for tr in t.split(' '):
                if tr != '':
                    tier += [tr]
            if len(tier)>0:
                list.append(tier)
        return list
    
    def complete(self, x):
        if self.dirCtl.GetValue() == '':
            dlg = wx.MessageDialog(self.frame, message = 'You must select a\n file or directory',
                caption = 'Error', style = wx.OK | wx.ICON_ERROR)
            dlg.ShowModal()
            dlg.Destroy()
            return
        params = {'piece_size_pow2': self.piece_length_list[self.piece_length.GetSelection()]}
        annlist = self.getannouncelist()
        if len(annlist)>0:
            params['real_announce_list'] = annlist
        comment = self.commentCtl.GetValue()
        if comment != '':
            params['comment'] = comment
        try:
            CompleteDir(self.dirCtl.GetValue(), self.annCtl.GetValue(), params)
        except:
            print_exc()


from traceback import print_exc

class CompleteDir:
    def __init__(self, d, a, params):
        self.d = d
        self.a = a
        self.params = params
        self.flag = Event()
        self.separatetorrents = False

        if isdir(d):
            self.choicemade = Event()
            frame = wx.Frame(None, -1, 'BitTorrent make torrent', size = (1,1))
            self.frame = frame
            panel = wx.Panel(frame, -1)
            gridSizer = wx.FlexGridSizer(cols = 1, vgap = 8, hgap = 8)
            gridSizer.AddGrowableRow(1)
            gridSizer.Add(wx.StaticText(panel, -1,
                    'Do you want to make a separate .torrent'),0,wx.ALIGN_CENTER)
            gridSizer.Add(wx.StaticText(panel, -1,
                    'for every item in this directory?'),0,wx.ALIGN_CENTER)
            gridSizer.Add(wx.StaticText(panel, -1, ''))

            b = wx.FlexGridSizer(cols = 3, hgap = 10)
            yesbut = wx.Button(panel, -1, 'Yes')
            def saidyes(e, self = self):
                self.frame.Destroy()
                self.separatetorrents = True
                self.begin()
            wx.EVT_BUTTON(frame, yesbut.GetId(), saidyes)
            b.Add(yesbut, 0)

            nobut = wx.Button(panel, -1, 'No')
            def saidno(e, self = self):
                self.frame.Destroy()
                self.begin()
            wx.EVT_BUTTON(frame, nobut.GetId(), saidno)
            b.Add(nobut, 0)

            cancelbut = wx.Button(panel, -1, 'Cancel')
            def canceled(e, self = self):
                self.frame.Destroy()                
            wx.EVT_BUTTON(frame, cancelbut.GetId(), canceled)
            b.Add(cancelbut, 0)
            gridSizer.Add(b, 0, wx.ALIGN_CENTER)
            border = wx.BoxSizer(wx.HORIZONTAL)
            border.Add(gridSizer, 1, wx.EXPAND | wx.ALL, 4)
            
            panel.SetSizer(border)
            panel.SetAutoLayout(True)
            frame.Show()
            border.Fit(panel)
            frame.Fit()
            
        else:
            self.begin()

    def begin(self):
        if self.separatetorrents:
            frame = wx.Frame(None, -1, 'BitTorrent make directory', size = wx.Size(550, 250))
        else:
            frame = wx.Frame(None, -1, 'BitTorrent make torrent', size = wx.Size(550, 250))
        self.frame = frame

        panel = wx.Panel(frame, -1)
        gridSizer = wx.FlexGridSizer(cols = 1, vgap = 15, hgap = 8)

        if self.separatetorrents:
            self.currentLabel = wx.StaticText(panel, -1, 'checking file sizes')
        else:
            self.currentLabel = wx.StaticText(panel, -1, 'building ' + self.d + '.torrent')
        gridSizer.Add(self.currentLabel, 0, wx.EXPAND)
        self.gauge = wx.Gauge(panel, -1, range = 1000, style = wx.GA_SMOOTH)
        gridSizer.Add(self.gauge, 0, wx.EXPAND)
        gridSizer.Add((10, 10), 1, wx.EXPAND)
        self.button = wx.Button(panel, -1, 'cancel')
        gridSizer.Add(self.button, 0, wx.ALIGN_CENTER)
        gridSizer.AddGrowableRow(2)
        gridSizer.AddGrowableCol(0)

        g2 = wx.FlexGridSizer(cols = 1, vgap = 15, hgap = 8)
        g2.Add(gridSizer, 1, wx.EXPAND | wx.ALL, 25)
        g2.AddGrowableRow(0)
        g2.AddGrowableCol(0)
        panel.SetSizer(g2)
        panel.SetAutoLayout(True)
        wx.EVT_BUTTON(frame, self.button.GetId(), self.done)
        wx.EVT_CLOSE(frame, self.done)
        EVT_INVOKE(frame, self.onInvoke)
        frame.Show(True)
        Thread(target = self.complete).start()

    def complete(self):
        try:
            if self.separatetorrents:
                completedir(self.d, self.a, self.params, self.flag,
                            self.valcallback, self.filecallback)
            else:
                make_meta_file(self.d, self.a, self.params, self.flag,
                            self.valcallback, progress_percent = 1)
            if not self.flag.isSet():
                self.currentLabel.SetLabel('Done!')
                self.gauge.SetValue(1000)
                self.button.SetLabel('Close')
                self.frame.Refresh()
        except (OSError, IOError), e:
            self.currentLabel.SetLabel('Error!')
            self.button.SetLabel('Close')
            dlg = wx.MessageDialog(self.frame, message = 'Error - ' + str(e),
                caption = 'Error', style = wx.OK | wx.ICON_ERROR)
            dlg.ShowModal()
            dlg.Destroy()

    def valcallback(self, amount):
        self.invokeLater(self.onval, [amount])

    def onval(self, amount):
        self.gauge.SetValue(int(amount * 1000))

    def filecallback(self, f):
        self.invokeLater(self.onfile, [f])

    def onfile(self, f):
        self.currentLabel.SetLabel('building ' + join(self.d, f) + '.torrent')

    def onInvoke(self, event):
        if not self.flag.isSet():
            apply(event.func, event.args, event.kwargs)

    def invokeLater(self, func, args = [], kwargs = {}):
        if not self.flag.isSet():
            wx.PostEvent(self.frame, InvokeEvent(func, args, kwargs))

    def done(self, event):
        self.flag.set()
        self.frame.Destroy()

class btWxApp(wx.App):
    def OnInit(self):
        d = DownloadInfo()
        d.frame.Show(True)
        self.SetTopWindow(d.frame)
        return True

if __name__ == '__main__':
    btWxApp().MainLoop()