def highlight(search, text):
    if can_highlight:
        try:
            Color.default()
            p = 0
            t = len(text)
            s = len(search)
            while p < t:
                q = text.find(search)
                if q < p:
                    q = t
                sys.stdout.write(text[p:q])
                Color.red()
                Color.light()
                sys.stdout.write(text[q:q + s])
                Color.default()
                sys.stdout.write("\r\n")
                p = q + s
        finally:
            Color.default()
    else:
        print text
Beispiel #2
0
def highlight( search, text ):
    if can_highlight:
        try:
            Color.default()
            p = 0
            t = len( text )
            s = len( search )
            while p < t:
                q = text.find( search )
                if q < p:
                    q = t
                sys.stdout.write( text[ p : q ] )
                Color.red()
                Color.light()
                sys.stdout.write( text[ q : q + s ] )
                Color.default()
                sys.stdout.write("\r\n")
                p = q + s
        finally:
            Color.default()
    else:
        print text
            p = 0
            t = len(text)
            s = len(search)
            while p < t:
                q = text.find(search)
                if q < p:
                    q = t
                sys.stdout.write(text[p:q])
                Color.red()
                Color.light()
                sys.stdout.write(text[q:q + s])
                Color.default()
                sys.stdout.write("\r\n")
                p = q + s
        finally:
            Color.default()
    else:
        print text


# Determine if the output is a console or a file.
# Trying to use colors fails if the output is not the console.
can_highlight = Color.can_use_colors()

# When invoked from the command line,
# the first argument is a search string.
if __name__ == "__main__":
    import sys
    search = sys.argv[1]
    reg_search(search)
Beispiel #4
0
            Color.default()
            p = 0
            t = len( text )
            s = len( search )
            while p < t:
                q = text.find( search )
                if q < p:
                    q = t
                sys.stdout.write( text[ p : q ] )
                Color.red()
                Color.light()
                sys.stdout.write( text[ q : q + s ] )
                Color.default()
                sys.stdout.write("\r\n")
                p = q + s
        finally:
            Color.default()
    else:
        print text

# Determine if the output is a console or a file.
# Trying to use colors fails if the output is not the console.
can_highlight = Color.can_use_colors()

# When invoked from the command line,
# the first argument is a search string.
if __name__ == "__main__":
    import sys
    search = sys.argv[1]
    reg_search( search )
def print_console(level,message):
    if (DEBUG_MODE == False):
        return
    try:
        if Color.can_use_colors():
            # Set black background.
            Color.bk_black()
            if (level==SUCCESS_LEVEL):
                Color.green()
                Color.light()                
            elif (level==ERROR_LEVEL):
                Color.red()
                Color.light()
            else:
                Color.white()
        print message
    except:
        print message
    finally:
        Color.reset()
Beispiel #6
0
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

from winappdbg import Color

# Can we use colors?
if Color.can_use_colors():

    # Let's be polite: put everything in a try/except block
    # so we can reset the console colors before quitting.
    try:

        # Set black background.
        Color.bk_black()

        # For each color...
        for color in ("red", "green", "blue", "cyan", "magenta", "yellow",
                      "white"):

            # Set the color.
            function = getattr(Color, color)
            function()
Beispiel #7
0
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

from winappdbg import Color

# Can we use colors?
if Color.can_use_colors():

    # Let's be polite: put everything in a try/except block
    # so we can reset the console colors before quitting.
    try:

        # Set black background.
        Color.bk_black()

        # For each color...
        for color in ( "red", "green", "blue", "cyan", "magenta", "yellow", "white" ):

            # Set the color.
            function = getattr( Color, color )
            function()
def print_console(level, message):
    if (DEBUG_MODE == False):
        return
    try:
        if Color.can_use_colors():
            # Set black background.
            Color.bk_black()
            if (level == SUCCESS_LEVEL):
                Color.green()
                Color.light()
            elif (level == ERROR_LEVEL):
                Color.red()
                Color.light()
            else:
                Color.white()
        print message
    except:
        print message
    finally:
        Color.reset()