Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command-Line plugin skips end of code block #2795

Closed
borari opened this issue Mar 8, 2021 · 4 comments
Closed

Command-Line plugin skips end of code block #2795

borari opened this issue Mar 8, 2021 · 4 comments

Comments

@borari
Copy link

borari commented Mar 8, 2021

Information:

  • Prism version: 1.23.0
  • Plugins: line-highlight, command-line, normalize-whitespace, toolbar, copy-to-clipboard
  • Environment: Browser

Does the latest version of Prism from the download page also have this issue?
Yes, I am using the latest version of Prism (1.23.0).

Description
While using the Command-Line plugin to create code blocks, I am experiencing an issue where some final output lines are not being displayed as a part of the command-line block. They are instead being displayed as what appears to be lines from a regular code block.

It appears that the issue might be due to the alignment of the prompt block, as you can see the alignment of the prompts and final line becoming further offset in the second example below. This tracks with my observation that there does not appear to be a definite line count threshold for triggering this issue, but that the issue is more pronounced in code blocks with higher line counts.

Example
Code Block HTML:

    <pre class="command-line language-shell" data-output="2-31" data-user="root" data-host="kali">
        <code>
wfuzz -c --hc 200 -z file,&quot;sqli-authbypass.txt&quot; -d &quot;username=FUZZ&amp;password=password123&quot; http://10.10.10.185/login.php 2&gt;&amp;1 | tee -a ./wfuzz-80-sqli-loginphp.txt

Warning: Pycurl is not compiled against Openssl. Wfuzz might not work correctly when fuzzing SSL sites. Check Wfuzz&#x27;s documentation for more information.

********************************************************
* Wfuzz 2.4.5 - The Web Fuzzer                         *
********************************************************

Target: http://10.10.10.185/login.php
Total requests: 191

===================================================================
ID           Response   Lines    Word     Chars       Payload
===================================================================

000000035:   302        117 L    277 W    4221 Ch     &quot;&#x27; or 1=1 -- s&quot;
000000036:   302        117 L    277 W    4221 Ch     &quot;&#x27; or 1=1 # s&quot;
000000038:   302        117 L    277 W    4221 Ch     &quot;&#x27; or 1=1 limit 1 -- s&quot;
000000039:   302        117 L    277 W    4221 Ch     &quot;&#x27; or 1=1 limit 1 # s&quot;
000000072:   302        117 L    277 W    4221 Ch     &quot;admin&#x27; -- s&quot;
000000073:   302        117 L    277 W    4221 Ch     &quot;admin&#x27; # s&quot;
000000075:   302        117 L    277 W    4221 Ch     &quot;admin&#x27; or 1=1 -- s&quot;
000000076:   302        117 L    277 W    4221 Ch     &quot;admin&#x27; or 1=1 # s&quot;
000000078:   302        117 L    277 W    4221 Ch     &quot;admin&#x27; or 1=1 limit 1 -- s&quot;
000000081:   302        117 L    277 W    4221 Ch     &quot;admin&#x27; or &#x27;1&#x27;=&#x27;1&quot;
000000079:   302        117 L    277 W    4221 Ch     &quot;admin&#x27; or 1=1 limit 1 # s&quot;

Total time: 0.500885
Processed Requests: 191
Filtered Requests: 180
Requests/sec.: 381.3248
        </code>
    </pre>

Unexpected Display:
image

HTML source for multiple input lines in single block:

    <pre class="command-line language-shell" data-output="2-3, 5-9, 11-21" data-user="www-data" data-host="ubuntu">
        <code>
/usr/bin/script -qc /bin/bash /dev/null
/usr/bin/script -qc /bin/bash /dev/null

ls -lAh /var/www
ls -lAh /var/www
total 8.0K
drwxr-xr-x 4 www-data www-data 4.0K Mar 17  2020 Magic
drwxr-xr-x 2 root     root     4.0K Dec  3  2019 html

ls -lAh /var/www/Magic
ls -lAh
total 44K
-rwx---r-x 1 www-data www-data  162 Oct 18  2019 .htaccess
drwxrwxr-x 6 www-data www-data 4.0K Jun  6  2019 assets
-rw-r--r-- 1 www-data www-data  881 Oct 16  2019 db.php5
drwxr-xr-x 4 www-data www-data 4.0K Apr 14  2020 images
-rw-rw-r-- 1 www-data www-data 4.5K Oct 22  2019 index.php
-rw-r--r-- 1 www-data www-data 5.5K Oct 22  2019 login.php
-rw-r--r-- 1 www-data www-data   72 Oct 18  2019 logout.php
-rw-r--r-- 1 www-data www-data 4.5K Oct 22  2019 upload.php
        </code>
    </pre>

Misaligned Display:
image

@borari
Copy link
Author

borari commented Mar 8, 2021

This issue seems to be linked to Issue #1132. I was able to fix the examples above by adding 'display: block' to the 'pre[class*="language-"]' block in my prism.js file.

Expected display w/ single input line:
image

Expected display w/ multiple input lines:
image

@RunDevelopment
Copy link
Member

The issue is most likely the spaces between the <pre> and <code> elements and the newline after the opening <code> tag. Could you please try the following:

<pre class="command-line language-shell" data-output="2-3, 5-9, 11-21" data-user="www-data" data-host="ubuntu"><code>/usr/bin/script -qc /bin/bash /dev/null
/usr/bin/script -qc /bin/bash /dev/null

ls -lAh /var/www
ls -lAh /var/www
total 8.0K
drwxr-xr-x 4 www-data www-data 4.0K Mar 17  2020 Magic
drwxr-xr-x 2 root     root     4.0K Dec  3  2019 html

ls -lAh /var/www/Magic
ls -lAh
total 44K
-rwx---r-x 1 www-data www-data  162 Oct 18  2019 .htaccess
drwxrwxr-x 6 www-data www-data 4.0K Jun  6  2019 assets
-rw-r--r-- 1 www-data www-data  881 Oct 16  2019 db.php5
drwxr-xr-x 4 www-data www-data 4.0K Apr 14  2020 images
-rw-rw-r-- 1 www-data www-data 4.5K Oct 22  2019 index.php
-rw-r--r-- 1 www-data www-data 5.5K Oct 22  2019 login.php
-rw-r--r-- 1 www-data www-data   72 Oct 18  2019 logout.php
-rw-r--r-- 1 www-data www-data 4.5K Oct 22  2019 upload.php
</code></pre>

This issue seems to be linked to Issue #1132.

I don't this being related.

@RunDevelopment
Copy link
Member

I investigated this a bit more and it seems like my initial guess was wrong. In fact, I cannot reproduce this issue at all.

(Example project.)

My new guess is that your custom theme somehow interferes with the Command line plugin. Please provide a simple example project that reproduces your issue.

@RunDevelopment
Copy link
Member

Closed because of inactivity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants