Skip to content

Commit

Permalink
Merge pull request TypeError#2 from TypeError/master
Browse files Browse the repository at this point in the history
Update
  • Loading branch information
Hannah-PortSwigger authored Dec 20, 2019
2 parents 978e5c4 + e24b2ce commit 6a17d15
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 11 deletions.
19 changes: 12 additions & 7 deletions src/BookmarkOptions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,22 @@ class BookmarkOptions(
bookmarksPanel.model.refreshBookmarks()
SwingUtilities.invokeLater {
val bookmarks = bookmarksPanel.bookmarks
val bookmarkRequests = bookmarks.map { callbacks.helpers.bytesToString(it.requestResponse.request) }
val bookmarkResponses =
bookmarks.map { callbacks.helpers.bytesToString(it.requestResponse.response ?: ByteArray(0)) }
val bookmarkRequestResponse = bookmarks.map {
Pair(
callbacks.helpers.bytesToString(it.requestResponse.request),
callbacks.helpers.bytesToString(it.requestResponse.response ?: ByteArray(0))
)
}
val proxyHistory = callbacks.proxyHistory.asSequence()
val bookmarksToAdd = proxyHistory
.filter { it.highlight != null }
.filterNot {
bookmarkRequests.contains(callbacks.helpers.bytesToString(it.request)) &&
bookmarkResponses.contains(
callbacks.helpers.bytesToString(it.response)
)
bookmarkRequestResponse.contains(
Pair(
callbacks.helpers.bytesToString(it.request),
callbacks.helpers.bytesToString(it.response ?: ByteArray(0))
)
)
}
.distinct()
.toList()
Expand Down
40 changes: 37 additions & 3 deletions src/BookmarkTab.kt
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,15 @@ class BookmarksPanel(private val callbacks: IBurpExtenderCallbacks) {
private fun repeatRequest() {
model.refreshBookmarks()
GlobalScope.launch(Dispatchers.IO) {
val requestResponse = callbacks.makeHttpRequest(messageEditor.httpService, requestViewer?.message)
val requestResponse = try {
callbacks.makeHttpRequest(messageEditor.httpService, requestViewer?.message)
} catch (e: java.lang.RuntimeException) {
RequestResponse(requestViewer?.message, null, messageEditor.httpService)
}
withContext(Dispatchers.Swing) {
SwingUtilities.invokeLater {
responseViewer?.setMessage(requestResponse.response, false)
if (repeatInTable.isSelected) {
responseViewer?.setMessage(requestResponse?.response ?: ByteArray(0), false)
if (repeatInTable.isSelected && requestResponse != null) {
createBookmark(requestResponse, repeated = true, proxyHistory = false)
}
}
Expand Down Expand Up @@ -302,4 +306,34 @@ class BookmarksModel : AbstractTableModel() {

}

class RequestResponse(private var req: ByteArray?, private var res: ByteArray?, private var service: IHttpService?) :
IHttpRequestResponse {

override fun getComment(): String? = null

override fun setComment(comment: String?) {}

override fun getRequest(): ByteArray? = req

override fun getHighlight(): String? = null

override fun getHttpService(): IHttpService? = service

override fun getResponse(): ByteArray? = res

override fun setResponse(message: ByteArray?) {
res = message
}

override fun setRequest(message: ByteArray?) {
req = message
}

override fun setHttpService(httpService: IHttpService?) {
service = httpService
}

override fun setHighlight(color: String?) {}
}


2 changes: 1 addition & 1 deletion src/BurpExtender.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class BurpExtender : IBurpExtender {
val tab = BookmarkTab(callbacks)
val table = tab.bookmarkTable
val menuItem = BookmarkMenu(table)
callbacks.stdout.write("Bookmarks [^] v0.4.1".toByteArray())
callbacks.stdout.write("Bookmarks [^] v0.4.3".toByteArray())
callbacks.stdout.write("\nAuthor: Caleb Kinney".toByteArray())
callbacks.stdout.write("\nEmail: caleb@cak.codes".toByteArray())
callbacks.stdout.write("\nGitHub: github.com/cak".toByteArray())
Expand Down

0 comments on commit 6a17d15

Please sign in to comment.