FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
sqlmap/extra/beep/beep.py at master · getcode2git/sqlmap · GitHub
getcode2git
/
sqlmap
Public
forked from
sqlmapproject/sqlmap
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
sqlmap
/
extra
/
beep
/
beep.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
96 lines (70 loc) · 2.49 KB
Breadcrumbs
sqlmap
/
extra
/
beep
/
beep.py
Copy path
File metadata and controls
96 lines (70 loc) · 2.49 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
#!/usr/bin/env python
"""
beep.py - Make a beep sound
Copyright (c) 2006-2015 sqlmap developers (http://sqlmap.org/)
See the file 'doc/COPYING' for copying permission
"""
import
os
import
subprocess
import
sys
import
wave
BEEP_WAV_FILENAME
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
"beep.wav"
)
def
beep
():
try
:
if
subprocess
.
mswindows
:
_win_wav_play
(
BEEP_WAV_FILENAME
)
elif
sys
.
platform
==
"darwin"
:
_mac_beep
()
elif
sys
.
platform
==
"linux2"
:
_linux_wav_play
(
BEEP_WAV_FILENAME
)
else
:
_speaker_beep
()
except
:
_speaker_beep
()
def
_speaker_beep
():
sys
.
stdout
.
write
(
'
\a
'
)
# doesn't work on modern Linux systems
try
:
sys
.
stdout
.
flush
()
except
IOError
:
pass
def
_mac_beep
():
import
Carbon
.
Snd
Carbon
.
Snd
.
SysBeep
(
1
)
def
_win_wav_play
(
filename
):
import
winsound
winsound
.
PlaySound
(
filename
,
winsound
.
SND_FILENAME
)
def
_linux_wav_play
(
filename
):
for
_
in
(
"aplay"
,
"paplay"
,
"play"
):
if
not
os
.
system
(
"%s '%s' 2>/dev/null"
%
(
_
,
filename
)):
return
import
ctypes
PA_STREAM_PLAYBACK
=
1
PA_SAMPLE_S16LE
=
3
BUFFSIZE
=
1024
class
struct_pa_sample_spec
(
ctypes
.
Structure
):
_fields_
=
[(
"format"
,
ctypes
.
c_int
), (
"rate"
,
ctypes
.
c_uint32
), (
"channels"
,
ctypes
.
c_uint8
)]
pa
=
ctypes
.
cdll
.
LoadLibrary
(
"libpulse-simple.so.0"
)
wave_file
=
wave
.
open
(
filename
,
"rb"
)
pa_sample_spec
=
struct_pa_sample_spec
()
pa_sample_spec
.
rate
=
wave_file
.
getframerate
()
pa_sample_spec
.
channels
=
wave_file
.
getnchannels
()
pa_sample_spec
.
format
=
PA_SAMPLE_S16LE
error
=
ctypes
.
c_int
(
0
)
pa_stream
=
pa
.
pa_simple_new
(
None
,
filename
,
PA_STREAM_PLAYBACK
,
None
,
"playback"
,
ctypes
.
byref
(
pa_sample_spec
),
None
,
None
,
ctypes
.
byref
(
error
))
if
not
pa_stream
:
raise
Exception
(
"Could not create pulse audio stream: %s"
%
pa
.
strerror
(
ctypes
.
byref
(
error
)))
while
True
:
latency
=
pa
.
pa_simple_get_latency
(
pa_stream
,
ctypes
.
byref
(
error
))
if
latency
==
-
1
:
raise
Exception
(
"Getting latency failed"
)
buf
=
wave_file
.
readframes
(
BUFFSIZE
)
if
not
buf
:
break
if
pa
.
pa_simple_write
(
pa_stream
,
buf
,
len
(
buf
),
ctypes
.
byref
(
error
)):
raise
Exception
(
"Could not play file"
)
wave_file
.
close
()
if
pa
.
pa_simple_drain
(
pa_stream
,
ctypes
.
byref
(
error
)):
raise
Exception
(
"Could not simple drain"
)
pa
.
pa_simple_free
(
pa_stream
)
if
__name__
==
"__main__"
:
beep
()
Back
|
FazBrowse Home
|
New Git URL