Skip to content

Commit 9b41a3f

Browse files
author
isayan
committed
add Force sort order
1 parent 93b7d7c commit 9b41a3f

File tree

7 files changed

+111
-11
lines changed

7 files changed

+111
-11
lines changed

release/YaguraExtender-v2.2.jar

1.37 KB
Binary file not shown.

src/main/java/extend/util/external/TransUtil.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2298,4 +2298,9 @@ public static BigDecimal toExcelSerial(long epoch_milli) {
22982298
return excel_serial.add(BigDecimal.valueOf(tz_offset)).divide(BigDecimal.valueOf(60 * 60 * 24), 6, RoundingMode.HALF_EVEN).add(BigDecimal.valueOf(25569L));
22992299
}
23002300

2301+
private final static String ORDERD_CHAR = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
2302+
2303+
public static char getOrderdChar(int ord) {
2304+
return ORDERD_CHAR.charAt(ord % ORDERD_CHAR.length());
2305+
}
23012306
}

src/main/java/yagura/model/SendToMenu.java

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import burp.IHttpService;
99
import burp.IMessageEditorController;
1010
import burp.IScanIssue;
11+
import extend.util.external.TransUtil;
1112
import extension.helpers.HttpUtil;
1213
import java.awt.TrayIcon;
1314
import java.awt.event.ActionEvent;
@@ -51,6 +52,21 @@ public List<JMenuItem> createMenuItems(IContextMenuInvocation invocation) {
5152
return this.menuList;
5253
}
5354

55+
private SendToMenuItem getMenuItemCaption(boolean forceSortOrder, int ord, SendToMenuItem menuItem) {
56+
if (forceSortOrder) {
57+
String caption = TransUtil.getOrderdChar(ord) + ") " + menuItem.getCaption();
58+
menuItem.setCaption(caption);
59+
}
60+
return menuItem;
61+
}
62+
63+
private String getMenuItemCaption(boolean forceSortOrder, int ord, String caption) {
64+
if (forceSortOrder)
65+
return TransUtil.getOrderdChar(ord) + ") " + caption;
66+
else
67+
return caption;
68+
}
69+
5470
public void renewMenu(SendToProperty property) {
5571
this.mnuSendTo.setText("Send To");
5672
this.sendToList.clear();
@@ -59,14 +75,15 @@ public void renewMenu(SendToProperty property) {
5975
this.mnuSendTo.removeAll();
6076
this.menuList.add(this.mnuSendTo);
6177
}
78+
BurpExtender.outPrintln("renewMenu:");
6279
List<SendToItem> sendToItemList = property.getSendToItemList();
6380
for (SendToItem item : sendToItemList) {
6481
if (item.isSelected()) {
6582
if (item.getExtend() != null) {
6683
SendToExtend sendToItem = new SendToExtend(item, this.invocation);
6784
if (sendToItem.getExtend() == SendToItem.ExtendType.PASTE_FROM_CLIPBOARD) {
6885
javax.swing.JMenu mnuItem = new javax.swing.JMenu();
69-
mnuItem.setText(item.getCaption());
86+
mnuItem.setText(getMenuItemCaption(property.isForceSortOrder(), this.menuList.size(), item.getCaption()));
7087
List<String> encodingList = BurpExtender.getInstance().getSelectEncodingList();
7188
for (String encoding : encodingList) {
7289
javax.swing.JMenuItem mnuItemEncoding = new javax.swing.JMenuItem();
@@ -85,7 +102,7 @@ public void renewMenu(SendToProperty property) {
85102
}
86103
} else {
87104
javax.swing.JMenuItem mnuItem = new javax.swing.JMenuItem();
88-
mnuItem.setText(item.getCaption());
105+
mnuItem.setText(getMenuItemCaption(property.isForceSortOrder(), this.menuList.size(), item.getCaption()));
89106
sendToList.add(sendToItem);
90107
mnuItem.addActionListener(sendToItem);
91108
if (property.isSubMenu()) {
@@ -98,10 +115,9 @@ public void renewMenu(SendToProperty property) {
98115
}
99116
}
100117
}
101-
102118
} else {
103119
javax.swing.JMenuItem mnuItem = new javax.swing.JMenuItem();
104-
mnuItem.setText(item.getCaption());
120+
mnuItem.setText(getMenuItemCaption(property.isForceSortOrder(), this.menuList.size(), item.getCaption()));
105121
if (item.isServer()) {
106122
SendToMenuItem sendToItem = new SendToServer(item, this.invocation);
107123
sendToItem.addSendToListener(new SendToListener() {
@@ -122,7 +138,6 @@ public void error(SendToEvent evt) {
122138
}
123139

124140
});
125-
126141
sendToList.add(sendToItem);
127142
mnuItem.addActionListener(sendToItem);
128143
if (property.isSubMenu()) {

src/main/java/yagura/model/SendToProperty.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,27 @@ public void setSubMenu(boolean submenu) {
4040
this.submenu = submenu;
4141
}
4242

43+
@Expose
44+
private boolean forceSortOrder = false;
45+
46+
/**
47+
* @return the forceSortOrder
48+
*/
49+
public boolean isForceSortOrder() {
50+
return forceSortOrder;
51+
}
52+
53+
/**
54+
* @param forceSortOrder the forceSortOrder to set
55+
*/
56+
public void setForceSortOrder(boolean forceSortOrder) {
57+
this.forceSortOrder = forceSortOrder;
58+
}
59+
4360
public void setProperty(SendToProperty property) {
4461
this.setSendToItemList(property.getSendToItemList());
4562
this.setSubMenu(property.isSubMenu());
63+
this.setForceSortOrder(property.isForceSortOrder());
4664
}
4765

4866
}

src/main/java/yagura/view/SendToTab.form

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
<Group type="103" groupAlignment="0" attributes="0">
5151
<Group type="102" alignment="0" attributes="0">
5252
<EmptySpace min="-2" pref="1" max="-2" attributes="0"/>
53-
<Component id="jScrollPane1" pref="582" max="32767" attributes="0"/>
53+
<Component id="jScrollPane1" pref="572" max="32767" attributes="0"/>
5454
<EmptySpace max="-2" attributes="0"/>
5555
<Group type="103" groupAlignment="0" attributes="0">
5656
<Component id="btnSendToEdit" alignment="1" min="-2" pref="105" max="-2" attributes="3"/>
@@ -69,7 +69,9 @@
6969
</Group>
7070
<Group type="102" attributes="0">
7171
<Component id="chkSubmenu" min="-2" pref="133" max="-2" attributes="0"/>
72-
<EmptySpace min="0" pref="552" max="32767" attributes="0"/>
72+
<EmptySpace max="-2" attributes="0"/>
73+
<Component id="chkForceSortOrder" min="-2" pref="190" max="-2" attributes="0"/>
74+
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
7375
</Group>
7476
</Group>
7577
<EmptySpace max="-2" attributes="0"/>
@@ -80,7 +82,10 @@
8082
<Group type="103" groupAlignment="0" attributes="0">
8183
<Group type="102" alignment="0" attributes="0">
8284
<EmptySpace max="-2" attributes="0"/>
83-
<Component id="chkSubmenu" min="-2" max="-2" attributes="0"/>
85+
<Group type="103" groupAlignment="3" attributes="0">
86+
<Component id="chkSubmenu" alignment="3" min="-2" max="-2" attributes="0"/>
87+
<Component id="chkForceSortOrder" alignment="3" min="-2" max="-2" attributes="0"/>
88+
</Group>
8489
<EmptySpace max="-2" attributes="0"/>
8590
<Group type="103" groupAlignment="0" attributes="0">
8691
<Group type="102" attributes="0">
@@ -251,6 +256,14 @@
251256
</Component>
252257
</SubComponents>
253258
</Container>
259+
<Component class="javax.swing.JCheckBox" name="chkForceSortOrder">
260+
<Properties>
261+
<Property name="text" type="java.lang.String" value="Force sort order"/>
262+
</Properties>
263+
<Events>
264+
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="chkForceSortOrderActionPerformed"/>
265+
</Events>
266+
</Component>
254267
</SubComponents>
255268
</Container>
256269
</SubComponents>

src/main/java/yagura/view/SendToTab.java

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ private void initComponents() {
5858
chkSubmenu = new javax.swing.JCheckBox();
5959
jScrollPane1 = new javax.swing.JScrollPane();
6060
tableSendTo = new javax.swing.JTable();
61+
chkForceSortOrder = new javax.swing.JCheckBox();
6162

6263
setPreferredSize(new java.awt.Dimension(550, 450));
6364
setLayout(new java.awt.BorderLayout());
@@ -149,6 +150,13 @@ public void keyPressed(java.awt.event.KeyEvent evt) {
149150
tableSendTo.getColumnModel().getColumn(10).setResizable(false);
150151
}
151152

153+
chkForceSortOrder.setText("Force sort order");
154+
chkForceSortOrder.addActionListener(new java.awt.event.ActionListener() {
155+
public void actionPerformed(java.awt.event.ActionEvent evt) {
156+
chkForceSortOrderActionPerformed(evt);
157+
}
158+
});
159+
152160
javax.swing.GroupLayout pnlCenterLayout = new javax.swing.GroupLayout(pnlCenter);
153161
pnlCenter.setLayout(pnlCenterLayout);
154162
pnlCenterLayout.setHorizontalGroup(
@@ -158,7 +166,7 @@ public void keyPressed(java.awt.event.KeyEvent evt) {
158166
.addGroup(pnlCenterLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
159167
.addGroup(pnlCenterLayout.createSequentialGroup()
160168
.addGap(1, 1, 1)
161-
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 582, Short.MAX_VALUE)
169+
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 572, Short.MAX_VALUE)
162170
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
163171
.addGroup(pnlCenterLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
164172
.addComponent(btnSendToEdit, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE)
@@ -172,14 +180,18 @@ public void keyPressed(java.awt.event.KeyEvent evt) {
172180
.addComponent(btnSendToAdd, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE)))
173181
.addGroup(pnlCenterLayout.createSequentialGroup()
174182
.addComponent(chkSubmenu, javax.swing.GroupLayout.PREFERRED_SIZE, 133, javax.swing.GroupLayout.PREFERRED_SIZE)
175-
.addGap(0, 552, Short.MAX_VALUE)))
183+
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
184+
.addComponent(chkForceSortOrder, javax.swing.GroupLayout.PREFERRED_SIZE, 190, javax.swing.GroupLayout.PREFERRED_SIZE)
185+
.addGap(0, 0, Short.MAX_VALUE)))
176186
.addContainerGap())
177187
);
178188
pnlCenterLayout.setVerticalGroup(
179189
pnlCenterLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
180190
.addGroup(pnlCenterLayout.createSequentialGroup()
181191
.addContainerGap()
182-
.addComponent(chkSubmenu)
192+
.addGroup(pnlCenterLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
193+
.addComponent(chkSubmenu)
194+
.addComponent(chkForceSortOrder))
183195
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
184196
.addGroup(pnlCenterLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
185197
.addGroup(pnlCenterLayout.createSequentialGroup()
@@ -345,12 +357,17 @@ private void chkSubmenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FI
345357
private void tableSendToKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tableSendToKeyPressed
346358
}//GEN-LAST:event_tableSendToKeyPressed
347359

360+
private void chkForceSortOrderActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkForceSortOrderActionPerformed
361+
this.firePropertyChange(TabbetOption.SENDTO_PROPERTY, null, this.getSendToProperty());
362+
}//GEN-LAST:event_chkForceSortOrderActionPerformed
363+
348364
// Variables declaration - do not modify//GEN-BEGIN:variables
349365
private javax.swing.JButton btnSendToAdd;
350366
private javax.swing.JButton btnSendToDownArraw;
351367
private javax.swing.JButton btnSendToEdit;
352368
private javax.swing.JButton btnSendToRemove;
353369
private javax.swing.JButton btnSendToUpArraw;
370+
private javax.swing.JCheckBox chkForceSortOrder;
354371
private javax.swing.JCheckBox chkSubmenu;
355372
private javax.swing.JScrollPane jScrollPane1;
356373
private javax.swing.JPanel pnlCenter;
@@ -419,12 +436,14 @@ private void showSendToItemDlg(boolean editMode) {
419436
public void setSendToProperty(SendToProperty sendToProperty) {
420437
this.setSendToItemList(sendToProperty.getSendToItemList());
421438
this.chkSubmenu.setSelected(sendToProperty.isSubMenu());
439+
this.chkForceSortOrder.setSelected(sendToProperty.isForceSortOrder());
422440
}
423441

424442
public SendToProperty getSendToProperty() {
425443
SendToProperty sendToProperty = new SendToProperty();
426444
sendToProperty.setSendToItemList(this.getSendToItemList());
427445
sendToProperty.setSubMenu(this.chkSubmenu.isSelected());
446+
sendToProperty.setForceSortOrder(this.chkForceSortOrder.isSelected());
428447
return sendToProperty;
429448
}
430449

src/test/java/extend/util/external/TransUtilTest.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -954,4 +954,34 @@ public void testStringBuilder() {
954954
System.out.println("append:" + b.toString());
955955
}
956956

957+
958+
959+
@Test
960+
public void testOrderdChar() {
961+
{
962+
char ord = TransUtil.getOrderdChar(0);
963+
assertEquals(ord, '0');
964+
}
965+
{
966+
char ord = TransUtil.getOrderdChar(10);
967+
assertEquals(ord, 'A');
968+
}
969+
{
970+
char ord = TransUtil.getOrderdChar(9 + 26);
971+
assertEquals(ord, 'Z');
972+
}
973+
{
974+
char ord = TransUtil.getOrderdChar(10 + 26);
975+
assertEquals(ord, 'a');
976+
}
977+
{
978+
char ord = TransUtil.getOrderdChar(9 + 26 + 26);
979+
assertEquals(ord, 'z');
980+
}
981+
{
982+
char ord = TransUtil.getOrderdChar(10 + 26 + 26);
983+
assertEquals(ord, '0');
984+
}
985+
}
986+
957987
}

0 commit comments

Comments
 (0)